Skip to content

Commit

Permalink
[ALS-5514] Fix NPE. Token does not contain "email" replaced with uid.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 committed Jan 25, 2024
1 parent 5908fee commit 4a782d9
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import edu.harvard.dbmi.avillach.util.HttpClientUtil;
import edu.harvard.dbmi.avillach.util.response.PICSUREResponse;
import edu.harvard.hms.dbmi.avillach.auth.JAXRSConfiguration;
import edu.harvard.hms.dbmi.avillach.auth.data.entity.Connection;
import edu.harvard.hms.dbmi.avillach.auth.data.entity.User;
import edu.harvard.hms.dbmi.avillach.auth.data.repository.ConnectionRepository;
import edu.harvard.hms.dbmi.avillach.auth.data.repository.RoleRepository;
import edu.harvard.hms.dbmi.avillach.auth.data.repository.UserRepository;
import edu.harvard.hms.dbmi.avillach.auth.rest.UserService;
import edu.harvard.hms.dbmi.avillach.auth.utils.AuthUtils;
Expand All @@ -31,12 +28,6 @@ public class OktaOAuthAuthenticationService {
@Inject
private UserRepository userRepository;

@Inject
private RoleRepository roleRepository;

@Inject
private ConnectionRepository connectionRepository;

@Inject
private AuthUtils authUtil;

Expand All @@ -57,7 +48,7 @@ public Response authenticate(UriInfo uriInfo, Map<String, String> authRequest) {
User user = initializeUser(introspectResponse);

if (user == null) {
logger.info("LOGIN FAILED ___ USER NOT FOUND ___ " + userToken.get("email").asText() + ":" + userToken.get("sub").asText() + " ___");
logger.info("LOGIN FAILED ___ USER NOT FOUND ___ " + userToken.get("uid").asText() + ":" + userToken.get("sub").asText() + " ___");
return PICSUREResponse.error(" LOGIN FAILED ___ USER NOT FOUND ___ ");
}

Expand Down Expand Up @@ -146,7 +137,6 @@ private JsonNode introspectToken(JsonNode userToken) {

// get the access token string from the response
String accessToken = userToken.get("access_token").asText();
logger.info("introspectToken - Access Token: " + accessToken);
String oktaIntrospectUrl = "https://" + JAXRSConfiguration.idp_provider_uri + "/oauth2/default/v1/introspect";
String payload = "token_type_hint=access_token&token=" + accessToken;
return doOktaRequest(oktaIntrospectUrl, payload);
Expand All @@ -162,7 +152,6 @@ private JsonNode introspectToken(JsonNode userToken) {
*/
private JsonNode handleCodeTokenExchange(UriInfo uriInfo, String code) {
String redirectUri = "https://" + uriInfo.getBaseUri().getHost() + "/psamaui/login";
logger.info(redirectUri);
String queryString = "grant_type=authorization_code" + "&code=" + code + "&redirect_uri=" + redirectUri;
String oktaTokenUrl = "https://" + JAXRSConfiguration.idp_provider_uri + "/oauth2/default/v1/token";

Expand Down

0 comments on commit 4a782d9

Please sign in to comment.