Feature/readme (#29)

* feat: update frontend resource

* fix: oauth2 login callback exception

* feat: update README
This commit is contained in:
vran
2022-03-03 23:12:26 +08:00
committed by GitHub
parent 905d7d5543
commit b1b3d55147
113 changed files with 341 additions and 58 deletions

View File

@@ -43,10 +43,10 @@ public class GithubOpenAuthHandler implements OpenAuthHandler {
public OAuthProcessResult process(OauthAppPojo app, Map<String, String[]> requestParams) {
String clientId = app.getClientId();
String clientSecret = app.getClientSecret();
String baseUrl = app.getResourceUrl();
String authUrl = app.getAuthUrl();
String code = requestParams.get("code")[0];
JsonNode tokenNode = githubRemoteService.getToken(baseUrl, clientId, clientSecret, code)
JsonNode tokenNode = githubRemoteService.getToken(authUrl, clientId, clientSecret, code)
.get("access_token");
if (tokenNode == null) {
throw new DatabasirAuthenticationException(DomainErrors.NETWORK_ERROR.exception());
@@ -55,8 +55,9 @@ public class GithubOpenAuthHandler implements OpenAuthHandler {
if (StringUtils.isBlank(accessToken)) {
throw new CredentialsExpiredException("授权失效,请重新登陆");
}
String resourceUrl = app.getResourceUrl();
String email = null;
for (JsonNode node : githubRemoteService.getEmail(baseUrl, accessToken)) {
for (JsonNode node : githubRemoteService.getEmail(resourceUrl, accessToken)) {
if (node.get("primary").asBoolean()) {
email = node.get("email").asText();
}
@@ -64,7 +65,7 @@ public class GithubOpenAuthHandler implements OpenAuthHandler {
if (StringUtils.isBlank(email)) {
throw new CredentialsExpiredException("授权失效,请重新登陆");
}
JsonNode profile = githubRemoteService.getProfile(baseUrl, accessToken);
JsonNode profile = githubRemoteService.getProfile(resourceUrl, accessToken);
String nickname = profile.get("name").asText();
String avatar = profile.get("avatar_url").asText();
OAuthProcessResult result = new OAuthProcessResult();

View File

@@ -37,6 +37,7 @@ public class GitlabOpenAuthHandler implements OpenAuthHandler {
.queryParam("redirect_uri", redirectUri)
.queryParam("response_type", "code")
.queryParam("state", redirectUri)
.queryParam("scope", "read_user")
.encode()
.build()
.toUriString();