Unverified Commit ebf5654b authored by Féry Mathieu (Mathius)'s avatar 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
......@@ -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;
}
}
......@@ -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);
}
}
......@@ -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/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment