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
3d74249f
Commit
3d74249f
authored
2 years ago
by
Eduard Frankford
Browse files
Options
Downloads
Patches
Plain Diff
fix pmd
parent
a8d8a731
Branches
Branches containing commit
3 merge requests
!177
2023 März Release
,
!171
Fixed #369 und added automatic user registration in gitlab
,
!146
Put the sonar-analyze job into a separate stage
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/at/ac/uibk/gitsearch/security/oauth2/UserDetailsFetcher.java
+8
-12
8 additions, 12 deletions
...ac/uibk/gitsearch/security/oauth2/UserDetailsFetcher.java
with
8 additions
and
12 deletions
src/main/java/at/ac/uibk/gitsearch/security/oauth2/UserDetailsFetcher.java
+
8
−
12
View file @
3d74249f
...
...
@@ -2,7 +2,6 @@ package at.ac.uibk.gitsearch.security.oauth2;
import
at.ac.uibk.gitsearch.domain.Authority
;
import
at.ac.uibk.gitsearch.service.dto.AdminUserDTO
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
@@ -12,7 +11,6 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.function.Consumer
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -97,21 +95,21 @@ public class UserDetailsFetcher {
String
email
=
(
String
)
oidcUser
.
getAttribute
(
"email"
);
User
gitUser
=
gitLabApi
.
getUserApi
().
getUserByEmail
(
email
);
if
(
gitUser
==
null
)
{
// try to create the user
gitUser
=
setUp
NewGitLabUserFor
(
oidcUser
);
gitUser
=
create
NewGitLabUserFor
(
oidcUser
);
String
generatedPassword
=
generatePassword
();
gitLabApi
.
getUserApi
().
createUser
(
gitUser
,
generatedPassword
,
true
);
gitUser
=
gitLabApi
.
getUserApi
().
getUserByEmail
(
email
);
if
(
gitUser
==
null
)
{
// gitUser still null. Something went wrong?
u
.
setLastModifiedDate
(
Instant
.
now
());
modified
=
true
;
return
new
UserDetailsInfo
(
userToken
,
modified
);
u
.
setLastModifiedDate
(
Instant
.
now
());
modified
=
true
;
return
new
UserDetailsInfo
(
userToken
,
modified
);
}
}
}
userToken
=
requestGitLabUserToken
(
gitUser
,
gitLabApi
);
List
<
Membership
>
memberships
=
gitLabApi
.
getUserApi
().
getMemberships
(
gitUser
.
getId
());
...
...
@@ -139,11 +137,10 @@ public class UserDetailsFetcher {
}
private
String
generatePassword
()
{
return
RandomStringUtils
.
random
(
8
,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz=%$-."
);
return
RandomStringUtils
.
random
(
8
,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz=%$-."
);
}
private
User
setUp
NewGitLabUserFor
(
final
OidcUser
oidcUser
)
{
private
User
create
NewGitLabUserFor
(
final
OidcUser
oidcUser
)
{
User
gitUser
=
new
User
();
String
email
=
oidcUser
.
getEmail
();
gitUser
.
setEmail
(
email
);
...
...
@@ -155,7 +152,6 @@ public class UserDetailsFetcher {
gitUser
.
setUsername
(
userName
);
return
gitUser
;
}
Optional
<
ImpersonationToken
>
requestGitLabUserToken
(
final
User
gitUser
,
final
GitLabApi
gitLabApi
)
throws
GitLabApiException
{
...
...
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