tied nonce to AuthorizationService by dedicated methods
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -8,7 +8,11 @@ import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AuthorizationService {
|
||||
AuthorizationService authorize(String userId, String clientId, Collection<String> scopes, String nonce, Instant expiration);
|
||||
AuthorizationService authorize(String userId, String clientId, Collection<String> scopes, Instant expiration);
|
||||
Optional<Authorization> consumeAuthorization(String authCode);
|
||||
AuthResult getAuthorization(String userId, String clientId, Collection<String> scopes);
|
||||
|
||||
Optional<String> consumeNonce(String uuid, String id);
|
||||
|
||||
void nonce(String uuid, String id, String string);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* © SRSoftware 2024 */
|
||||
package de.srsoftware.oidc.api.data;
|
||||
|
||||
public record Authorization(String clientId, String userId, AuthorizedScopes scopes, String nonce) {
|
||||
public record Authorization(String clientId, String userId, AuthorizedScopes scopes) {
|
||||
}
|
||||
@@ -26,10 +26,9 @@ public abstract class AuthServiceTest {
|
||||
var authorizationService = authorizationService();
|
||||
var userId1 = uuid();
|
||||
var expiration = Instant.now();
|
||||
var nonce = uuid();
|
||||
authorizationService.authorize(userId1, CLIENT1, SCOPES1, nonce, expiration);
|
||||
expiration = Instant.now().plusSeconds(3600).truncatedTo(SECONDS); // test overwrite
|
||||
authorizationService.authorize(userId1, CLIENT1, SCOPES1, nonce, expiration); // test overwrite
|
||||
authorizationService.authorize(userId1, CLIENT1, SCOPES1, expiration);
|
||||
expiration = Instant.now().plusSeconds(3600).truncatedTo(SECONDS); // test overwrite
|
||||
authorizationService.authorize(userId1, CLIENT1, SCOPES1, expiration); // test overwrite
|
||||
var authorization = authorizationService.getAuthorization(userId1, CLIENT1, Set.of(OPENID));
|
||||
assertEquals(1, authorization.authorizedScopes().scopes().size());
|
||||
assertTrue(authorization.authorizedScopes().scopes().contains(OPENID));
|
||||
@@ -53,10 +52,9 @@ public abstract class AuthServiceTest {
|
||||
public void testConsume() {
|
||||
var authorizationService = authorizationService();
|
||||
|
||||
var nonce = uuid();
|
||||
var userId1 = uuid();
|
||||
var expiration = Instant.now().plusSeconds(3600).truncatedTo(SECONDS);
|
||||
authorizationService.authorize(userId1, CLIENT1, SCOPES1, nonce, expiration);
|
||||
authorizationService.authorize(userId1, CLIENT1, SCOPES1, expiration);
|
||||
var authResult = authorizationService.getAuthorization(userId1, CLIENT1, Set.of(OPENID));
|
||||
var authCode = authResult.authCode();
|
||||
assertNotNull(authCode);
|
||||
@@ -75,5 +73,5 @@ public abstract class AuthServiceTest {
|
||||
assertTrue(optAuth.isEmpty());
|
||||
}
|
||||
|
||||
// TODO: test nonce passing
|
||||
// TODO: test nonce methods
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user