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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
