Revision 61064
Added by Konstantinos Triantafyllou almost 3 years ago
FrontEndLinkURIAuthenticationSuccessHandler.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import com.google.gson.Gson; |
4 | 4 |
import com.google.gson.JsonParser; |
5 |
import com.nimbusds.jwt.JWT; |
|
6 | 5 |
import eu.dnetlib.openaire.user.login.utils.JWTGenerator; |
7 |
import io.jsonwebtoken.Jwt; |
|
8 |
import io.jsonwebtoken.Jwts; |
|
9 | 6 |
import org.apache.log4j.Logger; |
10 | 7 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
11 | 8 |
import org.springframework.security.core.Authentication; |
12 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
13 | 9 |
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; |
14 | 10 |
import org.springframework.session.FindByIndexNameSessionRepository; |
15 |
import org.springframework.session.Session; |
|
16 | 11 |
|
17 | 12 |
import javax.servlet.http.Cookie; |
18 | 13 |
import javax.servlet.http.HttpServletRequest; |
19 | 14 |
import javax.servlet.http.HttpServletResponse; |
20 | 15 |
import java.io.IOException; |
21 |
import java.text.ParseException; |
|
22 |
import java.util.Arrays; |
|
23 | 16 |
import java.util.Base64; |
24 | 17 |
import java.util.Date; |
25 | 18 |
import java.util.regex.Matcher; |
... | ... | |
37 | 30 |
private String frontDomain; |
38 | 31 |
|
39 | 32 |
@Override |
40 |
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IllegalArgumentException, IOException { |
|
41 |
|
|
33 |
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IllegalArgumentException, IOException { |
|
42 | 34 |
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication; |
43 | 35 |
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail()); |
44 | 36 |
try { |
45 |
|
|
46 |
// Cookie jwt = new Cookie("XCsrfToken", JWTGenerator.generateToken(authOIDC, "my-very-secret")); |
|
47 | 37 |
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(JWTGenerator.generateJsonToken(authOIDC))); |
48 | 38 |
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue()); |
49 | 39 |
String regex = "^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$"; |
Also available in: Unified diff
[Login-core]: Revert openAIREUser on cookie. Change authorities mapper to cover provide roles.