Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for jwks urls #110

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ auth:
#ecdsa: []
# RSA public keys
#rsa: []
# jwks URLs to fetch public keys from
#publicKeyUrls: []
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ data class AuthConfig(
val keyStore: KeyStoreConfig = KeyStoreConfig(),
/** Public keys for checking the digital signature of OAuth 2.0 JWTs. */
val publicKeys: KeyConfig = KeyConfig(),
/** Public key URLs for checking the digital signature of OAuth 2.0 JWTs. */
val publicKeyUrls: List<String>? = null,
) {
fun validate() {
keyStore.validate()
check(managementPortalUrl != null || keyStore.isConfigured || publicKeys.isConfigured) {
"At least one of auth.keyStore, auth.publicKeys or auth.managementPortalUrl must be configured"
check(managementPortalUrl != null || keyStore.isConfigured || publicKeys.isConfigured || !publicKeyUrls.isNullOrEmpty()) {
"At least one of auth.keyStore, auth.publicKeys, auth.publicKeyUrls or auth.managementPortalUrl must be configured"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class EcdsaJwtEnhancerFactory(private val config: GatewayConfig) : EnhancerFacto
jwtKeystoreAlias = config.auth.keyStore.alias,
jwtKeystorePassword = config.auth.keyStore.password,
jwtKeystorePath = config.auth.keyStore.path.toString(),
jwksUrls = config.auth.publicKeyUrls ?: emptyList(),
)
return listOf(
GatewayResourceEnhancer(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ManagementPortalEnhancerFactory(private val config: GatewayConfig) : Enhan
),
jwtResourceName = config.auth.resourceName,
jwtIssuer = config.auth.issuer,
jwksUrls = config.auth.publicKeyUrls ?: emptyList(),
)
return listOf(
GatewayResourceEnhancer(config),
Expand Down
Loading