Skip to content

Commit

Permalink
Add signature back into OAuth API (not deprectated after all)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Dec 14, 2023
1 parent 42625c2 commit 72be5ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ public WdkOAuthClientWrapper(WdkModel wdkModel) throws WdkModelException {
}
}

public ValidatedToken getValidatedIdTokenFromAuth(String authCode, String redirectUri) {
return _client.getValidatedAuthToken(_config, authCode, redirectUri);
public ValidatedToken getAuthTokenFromAuthCode(String authCode, String redirectUri) {
return _client.getAuthTokenFromAuthCode(_config, authCode, redirectUri);
}

public ValidatedToken getValidatedIdTokenFromCredentials(String email, String password, String redirectUrl) {
return _client.getValidatedAuthToken(_config, email, password, redirectUrl);
public ValidatedToken getAuthTokenFromCredentials(String email, String password, String redirectUrl) {
return _client.getAuthTokenFromUsernamePassword(_config, email, password, redirectUrl);
}

public ValidatedToken getValidatedBearerTokenFromAuth(String authCode, String redirectUri) {
return _client.getValidatedBearerToken(_config, authCode, redirectUri);
public ValidatedToken getBearerTokenFromAuth(String authCode, String redirectUri) {
return _client.getBearerTokenFromAuthCode(_config, authCode, redirectUri);
}

public ValidatedToken getValidatedBearerTokenFromCredentials(String email, String password, String redirectUrl) {
return _client.getValidatedBearerToken(_config, email, password, redirectUrl);
public ValidatedToken getBearerTokenFromCredentials(String email, String password, String redirectUrl) {
return _client.getBearerTokenFromUsernamePassword(_config, email, password, redirectUrl);
}

public User getUserFromValidatedToken(ValidatedToken token, UserFactory userFactory) {
Claims claims = token.getTokenContents();

User user = new RegisteredUser(_wdkModel,
Long.parseLong(claims.getSubject()),
claims.get("email", String.class),
"deprecated", // user signature
claims.get(IdTokenFields.email.name(), String.class),
claims.get(IdTokenFields.signature.name(), String.class),
claims.get(IdTokenFields.preferred_username.name(), String.class));

// have to hit the user data endpoint for this for user details; bearer token does not include all fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Response processOauthLogin(
WdkOAuthClientWrapper client = new WdkOAuthClientWrapper(wdkModel);

// Use auth code to get the bearer token, then convert to User
ValidatedToken bearerToken = client.getValidatedBearerTokenFromAuth(authCode, appUrl);
ValidatedToken bearerToken = client.getBearerTokenFromAuth(authCode, appUrl);
User newUser = client.getUserFromValidatedToken(bearerToken, wdkModel.getUserFactory());

// transfer ownership from guest to logged-in user
Expand Down Expand Up @@ -209,7 +209,7 @@ public Response processDbLogin(@HeaderParam(REFERRER_HEADER_KEY) String referrer
WdkOAuthClientWrapper client = new WdkOAuthClientWrapper(wdkModel);

// Use passed credentials to get the bearer token, then convert to User
ValidatedToken bearerToken = client.getValidatedBearerTokenFromCredentials(request.getEmail(), request.getPassword(), appUrl);
ValidatedToken bearerToken = client.getBearerTokenFromCredentials(request.getEmail(), request.getPassword(), appUrl);

User newUser = client.getUserFromValidatedToken(bearerToken, wdkModel.getUserFactory());

Expand Down

0 comments on commit 72be5ba

Please sign in to comment.