Skip to content

Commit abe6b59

Browse files
th37roseludomikula
th37rose
authored andcommitted
Implemented the generic Auth feature without additional .well_known endpoint.
1 parent 4b23df7 commit abe6b59

File tree

5 files changed

+2
-87
lines changed

5 files changed

+2
-87
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public String getAuthorizeUrl() {
3838
case AuthTypeConstants.GITHUB -> replaceAuthUrlClientIdPlaceholder(Oauth2Constants.GITHUB_AUTHORIZE_URL);
3939
case AuthTypeConstants.ORY -> replaceAuthUrlClientIdPlaceholder(Oauth2Constants.ORY_AUTHORIZE_URL);
4040
case AuthTypeConstants.KEYCLOAK -> replaceAuthUrlClientIdPlaceholder(Oauth2Constants.KEYCLOAK_AUTHORIZE_URL);
41-
case AuthTypeConstants.GENERIC -> replaceAuthUrlClientIdPlaceholder(((Oauth2GenericAuthConfig)this).getAuthorizationEndpoint());
41+
case AuthTypeConstants.GENERIC -> ((Oauth2GenericAuthConfig)this).getAuthorizationEndpoint();
4242
default -> null;
4343
};
4444
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/AuthenticationController.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,4 @@ public Mono<ResponseView<List<APIKey>>> getAllAPIKeys() {
130130
.collectList()
131131
.map(ResponseView::success);
132132
}
133-
134-
/**
135-
* This endpoint is to get IDP configuration
136-
* @param issuerUri String
137-
* @param source String
138-
* @param sourceName String
139-
* @param clientId String
140-
* @param clientSecret String
141-
* @return Oauth2GenericAuthConfig
142-
*/
143-
@Override
144-
public Mono<ResponseView<Oauth2GenericAuthConfig>> addOAuthProvider(String issuerUri,
145-
String source,
146-
String sourceName,
147-
String clientId,
148-
String clientSecret) {
149-
return authenticationApiService.fetchAndParseConfiguration(issuerUri, source, sourceName, clientId, clientSecret)
150-
.map(ResponseView::success);
151-
}
152-
153133
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/service/AuthenticationApiService.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.lowcoder.domain.authentication.FindAuthConfig;
77
import org.lowcoder.domain.user.model.APIKey;
88
import org.lowcoder.domain.user.model.AuthUser;
9-
import org.lowcoder.sdk.auth.Oauth2GenericAuthConfig;
109
import org.springframework.web.server.ServerWebExchange;
1110
import reactor.core.publisher.Flux;
1211
import reactor.core.publisher.Mono;
@@ -30,19 +29,4 @@ public interface AuthenticationApiService {
3029
Mono<Void> deleteAPIKey(String authId);
3130

3231
Flux<APIKey> findAPIKeys();
33-
34-
/**
35-
* This method is to fetch and parse the OpenID configuration from the issuer URI.
36-
* @param issuerUri String
37-
* @param source String
38-
* @param sourceName String
39-
* @param clientId String
40-
* @param clientSecret String
41-
* @return Oauth2GenericAuthConfig
42-
*/
43-
Mono<Oauth2GenericAuthConfig> fetchAndParseConfiguration(String issuerUri,
44-
String source,
45-
String sourceName,
46-
String clientId,
47-
String clientSecret);
4832
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/service/AuthenticationApiServiceImpl.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -333,56 +333,6 @@ public Flux<APIKey> findAPIKeys() {
333333
);
334334
}
335335

336-
/**
337-
* This method is to fetch and parse the OpenID configuration from the issuer URI.
338-
* @param issuerUri String
339-
* @param source String
340-
* @param sourceName String
341-
* @param clientId String
342-
* @param clientSecret String
343-
* @return Oauth2GenericAuthConfig
344-
*/
345-
@Override
346-
public Mono<Oauth2GenericAuthConfig> fetchAndParseConfiguration(String issuerUri,
347-
String source,
348-
String sourceName,
349-
String clientId,
350-
String clientSecret) {
351-
String wellKnownUri = issuerUri + "/.well-known/openid-configuration";
352-
return WebClientBuildHelper.builder()
353-
.systemProxy()
354-
.build()
355-
.get()
356-
.uri(wellKnownUri)
357-
.retrieve()
358-
.bodyToMono(Map.class)
359-
.map(map -> mapToConfig(map, source, sourceName, clientId, clientSecret));
360-
}
361-
362-
/**
363-
* This method is to map to config for Generic Auth Provider
364-
* @param map Object that comes from /.well-known endpoint for IDP Configuration
365-
* @return Oauth2GenericAuthConfig
366-
*/
367-
private Oauth2GenericAuthConfig mapToConfig(Map<String, Object> map,
368-
String source,
369-
String sourceName,
370-
String clientId,
371-
String clientSecret) {
372-
return Oauth2GenericAuthConfig.builder()
373-
.authType(AuthTypeConstants.GENERIC)
374-
.source(source)
375-
.sourceName(sourceName)
376-
.clientId(clientId)
377-
.clientSecret(clientSecret)
378-
.issuerUri((String) map.get("issuer"))
379-
.authorizationEndpoint((String) map.get("authorization_endpoint"))
380-
.tokenEndpoint((String) map.get("token_endpoint"))
381-
.userInfoEndpoint((String) map.get("userinfo_endpoint"))
382-
.build();
383-
}
384-
385-
386336
private Mono<Void> removeTokensByAuthId(String authId) {
387337
return sessionUserService.getVisitorOrgMemberCache()
388338
.flatMapMany(orgMember -> orgMemberService.getOrganizationMembers(orgMember.getOrgId()))

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/service/factory/AuthConfigFactoryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class AuthConfigFactoryImpl implements AuthConfigFactory {
1919

2020
@Override
2121
public AbstractAuthConfig build(AuthConfigRequest authConfigRequest, boolean enable) {
22+
buildOauth2GenericAuthConfig(authConfigRequest, enable);
2223
return switch (authConfigRequest.getAuthType()) {
2324
case AuthTypeConstants.FORM -> buildEmailAuthConfig(authConfigRequest, enable);
2425
case AuthTypeConstants.GITHUB -> buildOauth2SimpleAuthConfig(GITHUB, GITHUB_NAME, authConfigRequest, enable);

0 commit comments

Comments
 (0)