@@ -2248,73 +2248,70 @@ public String getCSPNonce() {
2248
2248
2249
2249
public String getFacebookLoginURL () {
2250
2250
return "https://www.facebook.com/dialog/oauth?client_id=" + CONF .facebookAppId () +
2251
- "&response_type=code&scope=email&state=" + getParaAppId () +
2252
- "&redirect_uri=" + getParaEndpoint () + "/facebook_auth" + getHostUrlParam () ;
2251
+ "&response_type=code&scope=email&state=" + getStateParam () +
2252
+ "&redirect_uri=" + getParaEndpoint () + "/facebook_auth" ;
2253
2253
}
2254
2254
2255
2255
public String getGoogleLoginURL () {
2256
2256
return "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + CONF .googleAppId () +
2257
- "&response_type=code&scope=openid%20profile%20email&state=" + getParaAppId () +
2258
- "&redirect_uri=" + getParaEndpoint () + "/google_auth" + getHostUrlParam () ;
2257
+ "&response_type=code&scope=openid%20profile%20email&state=" + getStateParam () +
2258
+ "&redirect_uri=" + getParaEndpoint () + "/google_auth" ;
2259
2259
}
2260
2260
2261
2261
public String getGitHubLoginURL () {
2262
2262
return "https://github.com/login/oauth/authorize?response_type=code&client_id=" + CONF .githubAppId () +
2263
- "&scope=user%3Aemail&state=" + getParaAppId () +
2264
- "&redirect_uri=" + getParaEndpoint () + "/github_auth" + getHostUrlParam () ;
2263
+ "&scope=user%3Aemail&state=" + getStateParam () +
2264
+ "&redirect_uri=" + getParaEndpoint () + "/github_auth" ;
2265
2265
}
2266
2266
2267
2267
public String getLinkedInLoginURL () {
2268
2268
return "https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=" + CONF .linkedinAppId () +
2269
- "&scope=r_liteprofile%20r_emailaddress&state=" + getParaAppId () +
2270
- "&redirect_uri=" + getParaEndpoint () + "/linkedin_auth" + getHostUrlParam () ;
2269
+ "&scope=r_liteprofile%20r_emailaddress&state=" + getStateParam () +
2270
+ "&redirect_uri=" + getParaEndpoint () + "/linkedin_auth" ;
2271
2271
}
2272
2272
2273
2273
public String getTwitterLoginURL () {
2274
- return getParaEndpoint () + "/twitter_auth?state=" + getParaAppId ();
2274
+ return getParaEndpoint () + "/twitter_auth?state=" + getStateParam ();
2275
2275
}
2276
2276
2277
2277
public String getMicrosoftLoginURL () {
2278
2278
return "https://login.microsoftonline.com/" + CONF .microsoftTenantId () +
2279
2279
"/oauth2/v2.0/authorize?response_type=code&client_id=" + CONF .microsoftAppId () +
2280
- "&scope=https%3A%2F%2Fgraph.microsoft.com%2Fuser.read&state=" + getParaAppId () +
2281
- "&redirect_uri=" + getParaEndpoint () + "/microsoft_auth" + getHostUrlParam () ;
2280
+ "&scope=https%3A%2F%2Fgraph.microsoft.com%2Fuser.read&state=" + getStateParam () +
2281
+ "&redirect_uri=" + getParaEndpoint () + "/microsoft_auth" ;
2282
2282
}
2283
2283
2284
2284
public String getSlackLoginURL () {
2285
2285
return "https://slack.com/oauth/v2/authorize?response_type=code&client_id=" + CONF .slackAppId () +
2286
- "&user_scope=identity.basic%20identity.email%20identity.team%20identity.avatar&state=" + getParaAppId () +
2287
- "&redirect_uri=" + getParaEndpoint () + "/slack_auth" + getHostUrlParam () ;
2286
+ "&user_scope=identity.basic%20identity.email%20identity.team%20identity.avatar&state=" + getStateParam () +
2287
+ "&redirect_uri=" + getParaEndpoint () + "/slack_auth" ;
2288
2288
}
2289
2289
2290
2290
public String getAmazonLoginURL () {
2291
2291
return "https://www.amazon.com/ap/oa?response_type=code&client_id=" + CONF .amazonAppId () +
2292
- "&scope=profile&state=" + getParaAppId () +
2293
- "&redirect_uri=" + getParaEndpoint () + "/amazon_auth" + getHostUrlParam () ;
2292
+ "&scope=profile&state=" + getStateParam () +
2293
+ "&redirect_uri=" + getParaEndpoint () + "/amazon_auth" ;
2294
2294
}
2295
2295
2296
2296
public String getOAuth2LoginURL () {
2297
2297
return CONF .oauthAuthorizationUrl ("" ) + "?" +
2298
2298
"response_type=code&client_id=" + CONF .oauthAppId ("" ) +
2299
2299
"&scope=" + CONF .oauthScope ("" ) + getOauth2StateParam ("" ) +
2300
- "&redirect_uri=" + getParaEndpoint () + "/oauth2_auth" + getOauth2AppidParam ("" ) +
2301
- getHostUrlParam (CONF .oauthAppidInStateParamEnabled ("" ));
2300
+ "&redirect_uri=" + getParaEndpoint () + "/oauth2_auth" + getOauth2AppidParam ("" );
2302
2301
}
2303
2302
2304
2303
public String getOAuth2SecondLoginURL () {
2305
2304
return CONF .oauthAuthorizationUrl ("second" ) + "?" +
2306
2305
"response_type=code&client_id=" + CONF .oauthAppId ("second" ) +
2307
2306
"&scope=" + CONF .oauthScope ("second" ) + getOauth2StateParam ("second" ) +
2308
- "&redirect_uri=" + getParaEndpoint () + "/oauth2_auth" + getOauth2AppidParam ("second" ) +
2309
- getHostUrlParam (CONF .oauthAppidInStateParamEnabled ("second" ));
2307
+ "&redirect_uri=" + getParaEndpoint () + "/oauth2_auth" + getOauth2AppidParam ("second" );
2310
2308
}
2311
2309
2312
2310
public String getOAuth2ThirdLoginURL () {
2313
2311
return CONF .oauthAuthorizationUrl ("third" ) + "?" +
2314
2312
"response_type=code&client_id=" + CONF .oauthAppId ("third" ) +
2315
2313
"&scope=" + CONF .oauthScope ("third" ) + getOauth2StateParam ("third" ) +
2316
- "&redirect_uri=" + getParaEndpoint () + "/oauth2_auth" + getOauth2AppidParam ("third" ) +
2317
- getHostUrlParam (CONF .oauthAppidInStateParamEnabled ("third" ));
2314
+ "&redirect_uri=" + getParaEndpoint () + "/oauth2_auth" + getOauth2AppidParam ("third" );
2318
2315
}
2319
2316
2320
2317
public String getParaEndpoint () {
@@ -2326,19 +2323,20 @@ public String getParaAppId() {
2326
2323
}
2327
2324
2328
2325
private String getOauth2StateParam (String a ) {
2329
- return "&state=" + (CONF .oauthAppidInStateParamEnabled (a ) ? getParaAppId () : UUID .randomUUID ().toString ());
2326
+ return "&state=" + (CONF .oauthAppidInStateParamEnabled (a ) ? getStateParam () : UUID .randomUUID ().toString ());
2330
2327
}
2331
2328
2332
2329
private String getOauth2AppidParam (String a ) {
2333
2330
return CONF .oauthAppidInStateParamEnabled (a ) ? "" : "?appid=" + getParaAppId ();
2334
2331
}
2335
2332
2336
- private String getHostUrlParam () {
2337
- return getHostUrlParam (true );
2338
- }
2339
-
2340
- private String getHostUrlParam (boolean isSingleParam ) {
2341
- return StringUtils .isBlank (CONF .hostUrlAliases ()) ? "" : ((isSingleParam ? "?" : "&" ) + "host_url=" + CONF .serverUrl ());
2333
+ private String getStateParam () {
2334
+ if (StringUtils .isBlank (CONF .hostUrlAliases ())) {
2335
+ return getParaAppId ();
2336
+ } else {
2337
+ int index = Arrays .asList (CONF .hostUrlAliases ().split ("\\ s*,\\ s*" )).indexOf (CONF .serverUrl ());
2338
+ return getParaAppId () + (index >= 0 ? "|" + index : "" );
2339
+ }
2342
2340
}
2343
2341
2344
2342
public String getFirstConfiguredLoginURL () {
0 commit comments