This is the codeAbility Sharing Platform! Learn more about the
codeAbility Sharing Platform
.
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
codeAbility Sharing Platform
Manage
Activity
Members
Labels
Plan
Issues
43
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
development
sharing
codeAbility Sharing Platform
Commits
465cec3d
Commit
465cec3d
authored
4 years ago
by
Michael Breu
Browse files
Options
Downloads
Patches
Plain Diff
GitLab Gruppen werden jetzt auch im JWT gespeichert.
parent
e1bd276b
2 merge requests
!17
Initial Merge to Prepare Release 1.0.0
,
!1
Resolve "Metadaten konsolideren"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/at/ac/uibk/gitsearch/security/oauth2/SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport.java
+10
-1
10 additions, 1 deletion
...questAwareAuthenticationSuccessHandlerWithJWTSupport.java
with
10 additions
and
1 deletion
src/main/java/at/ac/uibk/gitsearch/security/oauth2/SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport.java
+
10
−
1
View file @
465cec3d
...
@@ -2,7 +2,9 @@ package at.ac.uibk.gitsearch.security.oauth2;
...
@@ -2,7 +2,9 @@ package at.ac.uibk.gitsearch.security.oauth2;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.Cookie
;
...
@@ -11,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -11,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken
;
import
org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken
;
import
org.springframework.security.oauth2.core.oidc.user.OidcUser
;
import
org.springframework.security.oauth2.core.oidc.user.OidcUser
;
import
org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
;
import
org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
;
...
@@ -41,8 +44,14 @@ public class SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport extends
...
@@ -41,8 +44,14 @@ public class SavedRequestAwareAuthenticationSuccessHandlerWithJWTSupport extends
if
(
authentication
instanceof
OAuth2AuthenticationToken
)
{
if
(
authentication
instanceof
OAuth2AuthenticationToken
)
{
OAuth2AuthenticationToken
oAuthA
=
(
OAuth2AuthenticationToken
)
authentication
;
OAuth2AuthenticationToken
oAuthA
=
(
OAuth2AuthenticationToken
)
authentication
;
String
mail
=
((
OidcUser
)
((
OAuth2AuthenticationToken
)
authentication
).
getPrincipal
()).
getEmail
();
String
mail
=
((
OidcUser
)
((
OAuth2AuthenticationToken
)
authentication
).
getPrincipal
()).
getEmail
();
List
<
String
>
gitLabGroups
=
(
List
<
String
>)
((
OidcUser
)
((
OAuth2AuthenticationToken
)
authentication
).
getPrincipal
()).
getClaims
().
get
(
"groups"
);
String
idToken
=
oAuthA
.
getPrincipal
().
getAttribute
(
"idToken"
);
String
idToken
=
oAuthA
.
getPrincipal
().
getAttribute
(
"idToken"
);
authenticationForToken
=
new
SimpleAuthentication
(
new
SimplePrincipal
(
mail
),
authentication
.
getAuthorities
());
List
<
GrantedAuthority
>
roles
=
new
ArrayList
<>();
roles
.
addAll
(
authentication
.
getAuthorities
());
for
(
String
gitLabGroup:
gitLabGroups
)
{
roles
.
add
(
new
SimpleGrantedAuthority
(
gitLabGroup
));
}
authenticationForToken
=
new
SimpleAuthentication
(
new
SimplePrincipal
(
mail
),
roles
);
authenticationForToken
.
setAuthenticated
(
authentication
.
isAuthenticated
());
authenticationForToken
.
setAuthenticated
(
authentication
.
isAuthenticated
());
}
}
String
token
=
tokenProvider
.
createToken
(
authenticationForToken
,
REQUEST_TOKEN_LIVETIME
*
1000L
);
// 200 secs (for Debugging)
String
token
=
tokenProvider
.
createToken
(
authenticationForToken
,
REQUEST_TOKEN_LIVETIME
*
1000L
);
// 200 secs (for Debugging)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment