Skip to content

Commit 3c07ef2

Browse files
author
rcsoyer
committed
refactoring - after adding the scope openind, the principal is now an OidcUser which extends from Oauth2User
1 parent f0af328 commit 3c07ef2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/org/acme/authorization_server/application/web/LoginSuccessHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import lombok.extern.slf4j.Slf4j;
99
import org.acme.authorization_server.domain.service.SecurityService;
1010
import org.springframework.security.core.Authentication;
11-
import org.springframework.security.oauth2.core.user.OAuth2User;
11+
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
1212
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
1313
import org.springframework.stereotype.Component;
1414

@@ -24,7 +24,7 @@ public void onAuthenticationSuccess(final HttpServletRequest request,
2424
final HttpServletResponse response,
2525
final Authentication authentication)
2626
throws ServletException, IOException {
27-
final String userName = ((OAuth2User) authentication.getPrincipal()).getAttribute("email");
27+
final String userName = ((OidcUser) authentication.getPrincipal()).getEmail();
2828
securityService.setAuthenticationContext(userName);
2929
super.onAuthenticationSuccess(request, response, authentication);
3030
}

0 commit comments

Comments
 (0)