feat: try to support custom OAuth provider (#667)

* feat: try to support private provider

* fix: modify code according to code review

* feat: set example values for custom params
This commit is contained in:
halozhy
2022-04-16 17:17:45 +08:00
committed by GitHub
parent 530330bd66
commit 287f60353c
9 changed files with 224 additions and 12 deletions

View File

@ -107,6 +107,9 @@ const authInfo = {
Steam: {
endpoint: "https://steamcommunity.com/openid/login",
},
Custom: {
endpoint: "https://example.com/",
},
};
const otherProviderInfo = {
@ -184,6 +187,9 @@ const otherProviderInfo = {
export function getProviderLogo(provider) {
if (provider.category === "OAuth") {
if (provider.type === "Custom") {
return provider.customLogo;
}
return `${Setting.StaticBaseUrl}/img/social_${provider.type.toLowerCase()}.png`;
} else {
return otherProviderInfo[provider.category][provider.type].logo;
@ -308,5 +314,7 @@ export function getAuthUrl(application, provider, method) {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Steam") {
return `${endpoint}?openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.realm=${window.location.origin}&openid.return_to=${redirectUri}?state=${state}`;
} else if (provider.type === "Custom") {
return `${provider.customAuthUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${provider.customScope}&response_type=code&state=${state}`;
}
}