-
Notifications
You must be signed in to change notification settings - Fork 161
fix(agentstack-server): fix #2138 #2373
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,8 +178,9 @@ async def discover_issuer(provider: OidcProvider) -> AuthorizationServerMetadata | |
| response.raise_for_status() | ||
| metadata = AuthorizationServerMetadata(response.json()) | ||
| metadata.validate_issuer() | ||
| metadata.validate_jwks_uri() | ||
| metadata.validate_introspection_endpoint() | ||
| if provider.issuer.scheme == "https": | ||
| metadata.validate_jwks_uri() | ||
| metadata.validate_introspection_endpoint() | ||
| except Exception as e: | ||
| # Fallback to OIDC 1.0 | ||
| try: | ||
|
|
@@ -188,8 +189,9 @@ async def discover_issuer(provider: OidcProvider) -> AuthorizationServerMetadata | |
| response.raise_for_status() | ||
| metadata = OpenIDProviderMetadata(response.json()) | ||
| metadata.validate_issuer() | ||
| metadata.validate_jwks_uri() | ||
| metadata.validate_introspection_endpoint() | ||
| if provider.issuer.scheme == "https": | ||
| metadata.validate_jwks_uri() | ||
| metadata.validate_introspection_endpoint() | ||
|
Comment on lines
+192
to
+194
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| except Exception as fallback_e: | ||
| logger.warning(f"Issuer discovery fallback failed for provider {provider.issuer}: {fallback_e}") | ||
| raise fallback_e from e | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,8 +131,8 @@ def provider(self) -> OidcProvider: | |
| @model_validator(mode="after") | ||
| def validate_auth(self): | ||
| if self.insecure_transport: | ||
| if self.issuer.scheme != "http" or self.issuer.host != "keycloak": | ||
| raise ValueError("Insecure transport is only allowed for internal keycloak!") | ||
| if self.issuer.scheme != "http": | ||
| raise ValueError("Insecure transport is only allowed when the issuer URL uses http:// scheme!") | ||
|
Comment on lines
+134
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The application allows enabling insecure transport for OIDC authentication for any host. When |
||
|
|
||
| os.environ["AUTHLIB_INSECURE_TRANSPORT"] = "1" | ||
| logger.warning( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code skips validation of the JWKS URI and introspection endpoint when the OIDC issuer uses the 'http' scheme. This is done to support the
insecure_transportconfiguration. However, by skipping these validations, the application may accept insecure or malformed metadata from an unencrypted source, which could be manipulated by an attacker to point to malicious endpoints.