-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes the Google OAuth library which is in maintainance mode with a supported library (nimbusds via pac4j) The library requires that the Issuer is set to enforce security and there is no option to disable this requirement as it is mandated in the specificiation. As such users must first update to 4.355.v3a_fb_fca_b_96d4 to set the Issuer before updating to this version. fixes: #313
- Loading branch information
Showing
34 changed files
with
1,039 additions
and
2,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/org/jenkinsci/plugins/oic/AnythingGoesTokenValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.jenkinsci.plugins.oic; | ||
|
||
import com.nimbusds.jose.JWSAlgorithm; | ||
import com.nimbusds.jwt.JWT; | ||
import com.nimbusds.jwt.JWTClaimsSet; | ||
import com.nimbusds.oauth2.sdk.ParseException; | ||
import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; | ||
import com.nimbusds.oauth2.sdk.id.Issuer; | ||
import com.nimbusds.openid.connect.sdk.Nonce; | ||
import com.nimbusds.openid.connect.sdk.SubjectType; | ||
import com.nimbusds.openid.connect.sdk.claims.IDTokenClaimsSet; | ||
import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import org.pac4j.core.exception.TechnicalException; | ||
import org.pac4j.oidc.config.OidcConfiguration; | ||
import org.pac4j.oidc.profile.creator.TokenValidator; | ||
|
||
public class AnythingGoesTokenValidator extends TokenValidator { | ||
|
||
public static final Logger LOGGER = Logger.getLogger(AnythingGoesTokenValidator.class.getName()); | ||
|
||
public AnythingGoesTokenValidator() { | ||
super(createFakeOidcConfiguration()); | ||
} | ||
|
||
@Override | ||
public IDTokenClaimsSet validate(final JWT idToken, final Nonce expectedNonce) { | ||
// validation is disabled, so everything is valid. | ||
try { | ||
return new IDTokenClaimsSet(idToken.getJWTClaimsSet()); | ||
} catch (ParseException | java.text.ParseException e) { | ||
LOGGER.log( | ||
Level.WARNING, | ||
"Token validation is disabled, but the token is corrupt and claims will not be represted.", | ||
e); | ||
try { | ||
return new IDTokenClaimsSet(new JWTClaimsSet.Builder().build()); | ||
} catch (ParseException e1) { | ||
throw new TechnicalException("could not create and empty IDTokenClaimsSet"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Annoyingly the super class needs an OidcConfiguration with some values set, | ||
* which if we are not validating we may not actually have (e.g. jwks_url). | ||
* So we need a configuration with this set just so the validator can say "this is valid". | ||
*/ | ||
private static OidcConfiguration createFakeOidcConfiguration() { | ||
try { | ||
OidcConfiguration config = new OidcConfiguration(); | ||
config.setClientId("ignored"); | ||
config.setSecret("ignored"); | ||
OIDCProviderMetadata providerMetadata = new OIDCProviderMetadata( | ||
new Issuer("http://ignored"), List.of(SubjectType.PUBLIC), new URI("http://ignored.and.invalid./")); | ||
providerMetadata.setIDTokenJWSAlgs(List.of(JWSAlgorithm.HS256)); | ||
config.setProviderMetadata(providerMetadata); | ||
config.setPreferredJwsAlgorithm(JWSAlgorithm.HS256); | ||
config.setClientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC); | ||
return config; | ||
} catch (URISyntaxException e) { | ||
// should never happen the urls we are using are valid | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
src/main/java/org/jenkinsci/plugins/oic/JenkinsAwareConnectionFactory.java
This file was deleted.
Oops, something went wrong.
106 changes: 0 additions & 106 deletions
106
src/main/java/org/jenkinsci/plugins/oic/OicJsonWebTokenVerifier.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.