Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mathieu Féry
M1Alma WebAndCloud Server
Commits
ebf5654b
Unverified
Commit
ebf5654b
authored
Dec 06, 2021
by
Féry Mathieu (Mathius)
Browse files
feat(oauth): Add fetch of picture from oauth import
parent
4ad40661
Pipeline
#34314
passed with stages
in 5 minutes and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/univnantes/webandcloud/api/core/oauth/OAuthProviderUserData.java
View file @
ebf5654b
...
...
@@ -25,6 +25,10 @@ public class OAuthProviderUserData implements BaseProperty {
private
String
name
;
private
String
email
;
private
String
nickname
;
private
boolean
uriPropertyFetched
=
false
;
private
String
uri
;
private
boolean
uriRegexPropertyFetched
=
false
;
private
String
uriRegex
;
/**
* Basic Constructor of OAuthProviderUserData
...
...
@@ -121,4 +125,32 @@ public class OAuthProviderUserData implements BaseProperty {
}
return
nickname
;
}
/**
* Getter for uri
*
* @return uri
*/
@Nullable
public
String
getUri
()
{
if
(
uriPropertyFetched
==
false
)
{
uri
=
service
.
getSpecificProperty
(
"uri"
,
this
);
uriPropertyFetched
=
true
;
}
return
uri
;
}
/**
* Getter for uriRegex
*
* @return uriRegex
*/
@Nullable
public
String
getUriRegex
()
{
if
(
uriRegexPropertyFetched
==
false
)
{
uriRegex
=
service
.
getSpecificProperty
(
"uri.regex"
,
this
);
uriRegexPropertyFetched
=
true
;
}
return
uriRegex
;
}
}
src/main/java/fr/univnantes/webandcloud/api/services/oauth/OAuthUserDataService.java
View file @
ebf5654b
...
...
@@ -84,6 +84,13 @@ public class OAuthUserDataService {
firstName
=
nameSplit
[
0
];
}
}
return
new
User
(
null
,
nickName
,
email
,
null
,
null
);
String
uri
;
if
(
userData
.
getUriRegex
()
!=
null
)
{
uri
=
userData
.
getUriRegex
();
uri
=
uri
.
replace
(
"$id"
,
extractPropertyOf
(
userData
.
getId
(),
receivedData
));
uri
=
uri
.
replace
(
"$uri"
,
extractPropertyOf
(
userData
.
getUri
(),
receivedData
));
}
else
uri
=
extractPropertyOf
(
userData
.
getUri
(),
receivedData
);
return
new
User
(
null
,
nickName
,
email
,
uri
,
null
);
}
}
src/main/resources/oauthConfig.properties
View file @
ebf5654b
...
...
@@ -5,6 +5,7 @@ oauth.gitlab.authorizeEndpoint=authorize
oauth.gitlab.scope
=
openid+email+profile
oauth.gitlab.userEndpoint
=
userinfo
oauth.gitlab.userData.id
=
sub
oauth.gitlab.userData.uri
=
picture
oauth.gitlabNantes.provider
=
https://gitlab.univ-nantes.fr/
oauth.gitlabNantes.parent
=
gitlab
...
...
@@ -29,6 +30,8 @@ oauth.discord.scope=identify email
oauth.discord.authOpts
=
prompt=none
oauth.discord.userEndpoint
=
v6/users/@me
oauth.discord.userData.nickname
=
username
oauth.discord.userData.uri
=
avatar
oauth.discord.userData.uri.regex
=
https://cdn.discordapp.com/avatars/$id/$uri
oauth.google.provider
=
https://google.com/
oauth.google.tokenEndpoint
=
https://oauth2.googleapis.com/token
...
...
@@ -39,6 +42,7 @@ oauth.google.withCodeVerification=false
oauth.google.userData.id
=
sub
oauth.google.userData.firstName
=
given_name
oauth.google.userData.lastName
=
family_name
oauth.google.userData.uri
=
picture
oauth.zoom.provider
=
https://zoom.us/
oauth.zoom.baseOAuthEndpoint
=
oauth/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment