-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10972 from IQSS/10959-bearer-token-auth-ext
Handle unregistered users in BearerTokenAuthMechanism and implement user registration mechanism
- Loading branch information
Showing
34 changed files
with
1,958 additions
and
668 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
Extends the OIDC API auth mechanism (available through feature flag ``api-bearer-auth``) to properly handle cases | ||
where ``BearerTokenAuthMechanism`` successfully validates the token but cannot identify any Dataverse user because there | ||
is no account associated with the token. | ||
|
||
To register a new user who has authenticated via an OIDC provider, a new endpoint has been | ||
implemented (``/users/register``). A feature flag named ``api-bearer-auth-provide-missing-claims`` has been implemented | ||
to allow | ||
sending missing user claims in the request JSON. This is useful when the identity provider does not supply the necessary | ||
claims. However, this flag will only be considered if the ``api-bearer-auth`` feature flag is enabled. If the latter is | ||
not enabled, the ``api-bearer-auth-provide-missing-claims`` flag will be ignored. | ||
|
||
A feature flag named ``api-bearer-auth-handle-tos-acceptance-in-idp`` has been implemented. When enabled, it specifies | ||
that Terms of Service acceptance is managed by the identity provider, eliminating the need to explicitly include the | ||
acceptance in the user registration request JSON. |
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
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
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
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
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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/edu/harvard/iq/dataverse/api/auth/AuthUtil.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,24 @@ | ||
package edu.harvard.iq.dataverse.api.auth; | ||
|
||
import java.util.Optional; | ||
|
||
public class AuthUtil { | ||
|
||
private static final String BEARER_AUTH_SCHEME = "Bearer"; | ||
|
||
/** | ||
* Extracts the Bearer token from the provided HTTP Authorization header value. | ||
* <p> | ||
* Validates that the header value starts with the "Bearer" scheme as defined in RFC 6750. | ||
* If the header is null, empty, or does not start with "Bearer ", an empty {@link Optional} is returned. | ||
* | ||
* @param headerParamBearerToken the raw HTTP Authorization header value containing the Bearer token | ||
* @return An {@link Optional} containing the raw Bearer token if present and valid; otherwise, an empty {@link Optional} | ||
*/ | ||
public static Optional<String> extractBearerTokenFromHeaderParam(String headerParamBearerToken) { | ||
if (headerParamBearerToken != null && headerParamBearerToken.toLowerCase().startsWith(BEARER_AUTH_SCHEME.toLowerCase() + " ")) { | ||
return Optional.of(headerParamBearerToken); | ||
} | ||
return Optional.empty(); | ||
} | ||
} |
Oops, something went wrong.