Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use testcontainers for cognito tests
wip: Cognito Local v3.7.1 unsupported feature: "AdminInitiateAuth"
- Loading branch information
1 parent
fcfe4b7
commit 74166d4
Showing
7 changed files
with
70 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 6 additions & 21 deletions
27
src/main/java/school/hei/haapi/security/cognito/JwtConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,21 @@ | ||
package school.hei.haapi.security.cognito; | ||
|
||
import java.io.Serializable; | ||
|
||
import lombok.Getter; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class JwtConfiguration implements Serializable { | ||
private final String userPoolId; | ||
private final String region; | ||
public static final String EMAIL_FIELD = "email"; | ||
@Getter private final String cognitoUserPoolUrl; | ||
|
||
public JwtConfiguration( | ||
@Value("${cognito.jwt.userPoolId}") final String userPoolId, | ||
@Value("${cognito.jwt.region}") final String region) { | ||
this.userPoolId = userPoolId; | ||
this.region = region; | ||
} | ||
|
||
public String getCognitoIdentityPoolUrlFormat() { | ||
return String.format( | ||
"https://cognito-idp.%s.amazonaws.com/%s", this.getRegion(), this.getUserPoolId()); | ||
public JwtConfiguration(@Value("${cognito.userPool.url}") final String cognitoUserPoolUrl) { | ||
this.cognitoUserPoolUrl = cognitoUserPoolUrl; | ||
} | ||
|
||
public String getCognitoJwksUrlFormat() { | ||
return getCognitoIdentityPoolUrlFormat() + "/.well-known/jwks.json"; | ||
} | ||
|
||
public String getUserPoolId() { | ||
return this.userPoolId; | ||
} | ||
|
||
public String getRegion() { | ||
return this.region; | ||
return cognitoUserPoolUrl + "/.well-known/jwks.json"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters