allow multiple redirect uris per client

This commit is contained in:
Dusan Jakub
2023-09-25 15:24:32 +02:00
parent c02f950c33
commit 1e615b2566
5 changed files with 16 additions and 10 deletions

View File

@@ -1,10 +1,11 @@
package com.ysoft.geecon.dto;
import java.util.List;
import java.util.Objects;
public record OAuthClient(String clientId, String description, String clientSecret, String redirectUri) {
public record OAuthClient(String clientId, String description, String clientSecret, List<String> redirectUris) {
public boolean validateRedirectUri(String redirectUri) {
return this.redirectUri != null && this.redirectUri.equals(redirectUri);
return this.redirectUris != null && this.redirectUris.contains(redirectUri);
}
public boolean validateSecret(String clientSecret) {

View File

@@ -5,6 +5,7 @@ import com.ysoft.geecon.dto.OAuthClient;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -13,11 +14,15 @@ public class ClientsRepo {
private final Map<String, OAuthClient> clients = new HashMap<>();
public ClientsRepo() {
register(new OAuthClient("my-public-client", "Example public client", null, "https://localhost:8888/oauth_success"));
register(new OAuthClient("oauthdebugger", "Example public client", null, "https://oauthdebugger.com/debug"));
register(new OAuthClient("my-public-client", "Example public client", null,
List.of("https://localhost:8888/oauth_success")));
register(new OAuthClient("oauthdebugger", "Example public client", null,
List.of("https://oauthdebugger.com/debug")));
register(new OAuthClient("oauth-playground", "OAuth playground", null, "https://oauth-playground.online/flow/code-2"));
register(new OAuthClient("oauth-playground-localhost", "OAuth playground", null, "http://localhost:5555/flow/code-2"));
register(new OAuthClient("oauth-playground", "OAuth playground", null,
List.of("https://oauth-playground.online/flow/code-2", "https://oauth-playground.online/flow/pkce-3")));
register(new OAuthClient("oauth-playground-localhost", "OAuth playground", null,
List.of("http://localhost:5555/flow/code-2", "http://localhost:5555/flow/pkce-2")));
}
public Optional<OAuthClient> getClient(String clientId) {