Skip to content

Commit 2e13bff

Browse files
committed
fix: change oauth url format to allow whole base url
1 parent e12e0e5 commit 2e13bff

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/Oauth2KeycloakAuthConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.lowcoder.sdk.auth;
22

3-
import static org.lowcoder.sdk.auth.constants.Oauth2Constants.INSTANCE_ID_PLACEHOLDER;
3+
import static org.lowcoder.sdk.auth.constants.Oauth2Constants.BASE_URL_PLACEHOLDER;
44
import static org.lowcoder.sdk.auth.constants.Oauth2Constants.REALM_PLACEHOLDER;
55

66
import com.fasterxml.jackson.annotation.JsonCreator;
@@ -15,7 +15,7 @@
1515
@Getter
1616
public class Oauth2KeycloakAuthConfig extends Oauth2SimpleAuthConfig
1717
{
18-
protected String instanceId;
18+
protected String baseUrl;
1919
protected String realm;
2020

2121
@JsonCreator
@@ -27,12 +27,12 @@ public Oauth2KeycloakAuthConfig(
2727
@JsonProperty("sourceName") String sourceName,
2828
@JsonProperty("clientId") String clientId,
2929
@JsonProperty("clientSecret") String clientSecret,
30-
@JsonProperty("instanceId") String instanceId,
30+
@JsonProperty("baseUrl") String baseUrl,
3131
@JsonProperty("realm") String realm,
3232
@JsonProperty("authType") String authType)
3333
{
3434
super(id, enable, enableRegister, source, sourceName, clientId, clientSecret, authType);
35-
this.instanceId = instanceId;
35+
this.baseUrl = baseUrl;
3636
this.realm = realm;
3737
}
3838

@@ -42,7 +42,7 @@ public Oauth2KeycloakAuthConfig(
4242
public String replaceAuthUrlClientIdPlaceholder(String url)
4343
{
4444
return super.replaceAuthUrlClientIdPlaceholder(url)
45-
.replace(INSTANCE_ID_PLACEHOLDER, instanceId)
45+
.replace(BASE_URL_PLACEHOLDER, baseUrl)
4646
.replace(REALM_PLACEHOLDER, realm);
4747
}
4848

server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/Oauth2OryAuthConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.lowcoder.sdk.auth;
22

3-
import static org.lowcoder.sdk.auth.constants.Oauth2Constants.INSTANCE_ID_PLACEHOLDER;
3+
import static org.lowcoder.sdk.auth.constants.Oauth2Constants.BASE_URL_PLACEHOLDER;
44

55
import javax.annotation.Nullable;
66

@@ -14,7 +14,7 @@
1414
@Getter
1515
public class Oauth2OryAuthConfig extends Oauth2SimpleAuthConfig {
1616

17-
protected String instanceId;
17+
protected String baseUrl;
1818

1919
@JsonCreator
2020
public Oauth2OryAuthConfig(
@@ -25,14 +25,14 @@ public Oauth2OryAuthConfig(
2525
String sourceName,
2626
String clientId,
2727
String clientSecret,
28-
String instanceId,
28+
String baseUrl,
2929
String authType) {
3030
super(id, enable, enableRegister, source, sourceName, clientId, clientSecret, authType);
31-
this.instanceId = instanceId;
31+
this.baseUrl = baseUrl;
3232
}
3333

3434
@Override
3535
public String replaceAuthUrlClientIdPlaceholder(String url) {
36-
return super.replaceAuthUrlClientIdPlaceholder(url).replace(INSTANCE_ID_PLACEHOLDER, instanceId);
36+
return super.replaceAuthUrlClientIdPlaceholder(url).replace(BASE_URL_PLACEHOLDER, baseUrl);
3737
}
3838
}

server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/constants/Oauth2Constants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Oauth2Constants {
88
public static final String STATE_PLACEHOLDER = "$STATE";
99
public static final String REALM_PLACEHOLDER = "$REALM";
1010

11-
public static final String INSTANCE_ID_PLACEHOLDER = "$INSTANCE_ID";
11+
public static final String BASE_URL_PLACEHOLDER = "$BASE_URL";
1212

1313
// authorize url
1414
public static final String GITHUB_AUTHORIZE_URL = "https://github.com/login/oauth/authorize"
@@ -27,14 +27,14 @@ public class Oauth2Constants {
2727
+ "&scope=openid email profile"
2828
+ "&prompt=select_account";
2929

30-
public static final String ORY_AUTHORIZE_URL = "https://" + INSTANCE_ID_PLACEHOLDER + "/oauth2/auth"
30+
public static final String ORY_AUTHORIZE_URL = BASE_URL_PLACEHOLDER + "/oauth2/auth"
3131
+ "?response_type=code"
3232
+ "&client_id=" + CLIENT_ID_PLACEHOLDER
3333
+ "&redirect_uri=" + REDIRECT_URL_PLACEHOLDER
3434
+ "&state=" + STATE_PLACEHOLDER
3535
+ "&scope=openid email profile offline_access";
3636

37-
public static final String KEYCLOAK_AUTHORIZE_URL = "https://" + INSTANCE_ID_PLACEHOLDER + "/realms/" + REALM_PLACEHOLDER + "/protocol/openid-connect/auth"
37+
public static final String KEYCLOAK_AUTHORIZE_URL = BASE_URL_PLACEHOLDER + "/realms/" + REALM_PLACEHOLDER + "/protocol/openid-connect/auth"
3838
+ "?response_type=code"
3939
+ "&client_id=" + CLIENT_ID_PLACEHOLDER
4040
+ "&redirect_uri=" + REDIRECT_URL_PLACEHOLDER

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2DefaultSource.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.lowcoder.api.authentication.request.oauth2;
22

33
import org.lowcoder.sdk.auth.constants.Oauth2Constants;
4-
import org.springframework.security.config.oauth2.client.CommonOAuth2Provider;
54

65
public enum Oauth2DefaultSource implements Oauth2Source {
76

@@ -43,17 +42,17 @@ public String refresh() {
4342
ORY {
4443
@Override
4544
public String accessToken() {
46-
return "https://" + Oauth2Constants.INSTANCE_ID_PLACEHOLDER + "/oauth2/token";
45+
return Oauth2Constants.BASE_URL_PLACEHOLDER + "/oauth2/token";
4746
}
4847

4948
@Override
5049
public String userInfo() {
51-
return "https://" + Oauth2Constants.INSTANCE_ID_PLACEHOLDER + "/userinfo";
50+
return Oauth2Constants.BASE_URL_PLACEHOLDER + "/userinfo";
5251
}
5352

5453
@Override
5554
public String refresh() {
56-
return "https://" + Oauth2Constants.INSTANCE_ID_PLACEHOLDER + "/oauth2/token";
55+
return Oauth2Constants.BASE_URL_PLACEHOLDER + "/oauth2/token";
5756
}
5857

5958
},
@@ -62,17 +61,17 @@ public String refresh() {
6261

6362
@Override
6463
public String accessToken() {
65-
return "http://" + Oauth2Constants.INSTANCE_ID_PLACEHOLDER + "/realms/" + Oauth2Constants.REALM_PLACEHOLDER + "/protocol/openid-connect/token";
64+
return Oauth2Constants.BASE_URL_PLACEHOLDER + "/realms/" + Oauth2Constants.REALM_PLACEHOLDER + "/protocol/openid-connect/token";
6665
}
6766

6867
@Override
6968
public String userInfo() {
70-
return "http://" + Oauth2Constants.INSTANCE_ID_PLACEHOLDER + "/realms/" + Oauth2Constants.REALM_PLACEHOLDER + "/protocol/openid-connect/userinfo";
69+
return Oauth2Constants.BASE_URL_PLACEHOLDER + "/realms/" + Oauth2Constants.REALM_PLACEHOLDER + "/protocol/openid-connect/userinfo";
7170
}
7271

7372
@Override
7473
public String refresh() {
75-
return "http://" + Oauth2Constants.INSTANCE_ID_PLACEHOLDER + "/realms/" + Oauth2Constants.REALM_PLACEHOLDER + "/protocol/openid-connect/token";
74+
return Oauth2Constants.BASE_URL_PLACEHOLDER + "/realms/" + Oauth2Constants.REALM_PLACEHOLDER + "/protocol/openid-connect/token";
7675
}
7776

7877
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy