You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "moresandeep (via GitHub)" <gi...@apache.org> on 2026/09/18 20:21:52 UTC
[PR] KNOX-3470 - Add support for /.well-known/oauth-authorization-server [knox]
moresandeep opened a new pull request, #1417:
URL: https://github.com/apache/knox/pull/1417
[KNOX-3470](https://issues.apache.org/jira/browse/KNOX-3470) - Add support for /.well-known/oauth-authorization-server
## What changes were proposed in this pull request?
Add support for /.well-known/oauth-authorization-server, this support is added at the topology level e.g.
`https://localhost:8443/gateway/knoxidf-test/.well-known/oauth-authorization-server` to be as compliant with the RFC 8414 as we possibally can be. The RFC 8414 dictates `.well-known/oauth-authorization-server` to be exposed at the root domain but the way Knox servlets are setup that is not possible.
`.well-known/oauth-authorization-server` is also exposed at the knox IDF api level e.g. `https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/.well-known/oauth-authorization-server` to be in line with `/knoxidf/api/v1/.well-known/openid-configuration`.
## How was this patch tested?
### Manual Testing
Following `knoxidf-test` topology was used for testing
```
<?xml version="1.0" encoding="utf-8"?>
<topology>
<gateway>
<provider>
<role>authentication</role>
<name>ShiroProvider</name>
<enabled>true</enabled>
<param>
<name>main.ldapRealm</name>
<value>org.apache.knox.gateway.shirorealm.KnoxLdapRealm</value>
</param>
<param>
<name>main.ldapRealm.userDnTemplate</name>
<value>uid={0},ou=people,dc=hadoop,dc=apache,dc=org</value>
</param>
<param>
<name>main.ldapRealm.contextFactory.url</name>
<value>ldap://localhost:33389</value>
</param>
<param>
<name>main.ldapRealm.contextFactory.authenticationMechanism</name>
<value>simple</value>
</param>
<!-- Public discovery documents: reachable without authentication. -->
<param>
<name>urls./knoxidf/api/v1/.well-known/openid-configuration</name>
<value>anon</value>
</param>
<!-- RFC 8414 OAuth 2.0 Authorization Server Metadata, at both placements. -->
<param>
<name>urls./knoxidf/api/v1/.well-known/oauth-authorization-server</name>
<value>anon</value>
</param>
<param>
<name>urls./.well-known/oauth-authorization-server</name>
<value>anon</value>
</param>
<param>
<name>urls./knoxidf/api/v1/jwks</name>
<value>anon</value>
</param>
<param>
<name>urls./knoxidf/api/v1/client/register</name>
<value>anon</value>
</param>
<param>
<name>urls./knoxidf/api/v1/authorize/callback</name>
<value>anon</value>
</param>
<!-- Everything else requires HTTP Basic auth against the demo LDAP. -->
<param>
<name>urls./**</name>
<value>authcBasic</value>
</param>
</provider>
<provider>
<role>identity-assertion</role>
<name>Default</name>
<enabled>true</enabled>
</provider>
</gateway>
<service>
<role>KNOXIDF</role>
<param>
<name>knoxidf.knox.token.ttl</name>
<value>60000</value>
</param>
<param>
<!-- Convenience for local testing: allow unauthenticated client registration. -->
<name>knoxidf.client.registration.anonymous.allowed</name>
<value>true</value>
</param>
<param>
<name>knoxidf.auto.consent.enabled</name>
<value>true</value>
</param>
</service>
</topology>
```
Curl command output:
```
curl -sk https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/.well-known/oauth-authorization-server | jq .
{
"issuer": "https://localhost:8443/gateway/knoxidf-test/knoxidf",
"authorization_endpoint": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/authorize",
"token_endpoint": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/token",
"registration_endpoint": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/client/register",
"jwks_uri": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/jwks",
"response_types_supported": [
"code"
],
"token_endpoint_auth_methods_supported": [
"client_secret_post",
"none"
],
"grant_types_supported": [
"authorization_code",
"refresh_token",
"client_credentials",
"urn:ietf:params:oauth:grant-type:token-exchange"
],
"scopes_supported": [
"openid",
"profile",
"email",
"offline_access"
],
"code_challenge_methods_supported": [
"S256"
]
}
```
AND at root
```
curl -sk https://localhost:8443/gateway/knoxidf-test/.well-known/oauth-authorization-server | jq .
{
"issuer": "https://localhost:8443/gateway/knoxidf-test/knoxidf",
"authorization_endpoint": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/authorize",
"token_endpoint": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/token",
"registration_endpoint": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/client/register",
"jwks_uri": "https://localhost:8443/gateway/knoxidf-test/knoxidf/api/v1/jwks",
"response_types_supported": [
"code"
],
"token_endpoint_auth_methods_supported": [
"client_secret_post",
"none"
],
"grant_types_supported": [
"authorization_code",
"refresh_token",
"client_credentials",
"urn:ietf:params:oauth:grant-type:token-exchange"
],
"scopes_supported": [
"openid",
"profile",
"email",
"offline_access"
],
"code_challenge_methods_supported": [
"S256"
]
}
```
## Integration Tests
Integration tests added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KNOX-3470 - Add support for /.well-known/oauth-authorization-server [knox]
Posted by "moresandeep (via GitHub)" <gi...@apache.org>.
moresandeep merged PR #1417:
URL: https://github.com/apache/knox/pull/1417
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KNOX-3470 - Add support for /.well-known/oauth-authorization-server [knox]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1417:
URL: https://github.com/apache/knox/pull/1417#issuecomment-5735826864
## Test Results
4 files 4 suites 29s ⏱️
100 tests 100 ✅ 0 💤 0 ❌
118 runs 118 ✅ 0 💤 0 ❌
Results for commit 3566b88b.
[test-results]:data:application/gzip;base64,H4sIAKafrWoC/13MQQ7CIBRF0a00jB0ApfDrZgzwaUJsi6EwMu5dJLVFh+e+5D3J5Ge3kWsnLh3Zsk8HMEedfFgL+VhclvTZGKVf3bZs7X+6+0dJZ5i0n3+CizHEvcS81k8GO47LppyP1c1hdftnw7L4VED6QUoDYDTnoFEBZYgjE9b0TgEqJQcpBBpLXm9EP9loBAEAAA==
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KNOX-3470 - Add support for /.well-known/oauth-authorization-server [knox]
Posted by "pzampino (via GitHub)" <gi...@apache.org>.
pzampino commented on code in PR #1417:
URL: https://github.com/apache/knox/pull/1417#discussion_r4050537064
##########
gateway-service-knoxidf/src/main/java/org/apache/knox/gateway/service/knoxidf/OAuthServerMetadataRootResource.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.knox.gateway.service.knoxidf;
+
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+
+/**
+ * The RFC 8414 OAuth 2.0 Authorization Server Metadata document served at the topology root
+ * ({@code /gateway/<topology>/.well-known/oauth-authorization-server}) -- the well-known location
+ * OAuth-only clients probe relative to the base URL, and Knox's closest practical approximation of
+ * the RFC 8414 canonical placement (the gateway servlet is mounted under {@code /gateway/<topology>/},
+ * so true host-root placement is not possible).
+ *
+ * <p>This differs from {@link OAuthServerMetadataResource} only in its {@code @Path}: it is a second
+ * root resource that inherits that class's {@code @Context} injection, {@code @PostConstruct init()},
+ * and {@code @GET getMetadata()} unchanged, so the two placements cannot drift. It requires the
+ * {@code .well-known/oauth-authorization-server} route pattern in {@code KnoxIDFServiceDeploymentContributor}.
+ */
+@Path(".well-known/oauth-authorization-server")
Review Comment:
What is the purpose of this without the base resource path (i.e., knoxidf/api/v1)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org