-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Extension points for authentication/authorization #4271
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
07f0ac0
Extension points for authentication/authorization
jon-wei 037f5dd
Address some PR comments
jon-wei 6dd0af9
Authorization result caching
jon-wei bcb3074
Add unit tests for SecuritySanityCheckFilter and PreResponseAuthoriza…
jon-wei 2a3aaf3
Use Set for auth caching, close outputstreams in filters
jon-wei 28129e2
Don't close output stream on success in sanity check filter
jon-wei d3d5c59
Add ConfigResourceFilter to coordinator lookups
jon-wei 1f1daba
Fix filtering authorization check for empty resource list
jon-wei a632f4b
HttpClient users must explicitly escalate the client
jon-wei 0ef07c8
Remove response modification from PreResponseAuthorizationCheckFilter
jon-wei 5c34b2d
Remove extraneous pom.xml
jon-wei ec67fd4
Fix unit test
jon-wei d5917f4
Better lifecycle management
jon-wei 427aa26
Rename AuthorizationManager to Authorizer
jon-wei 4c365fe
Fix authorization denials for empty supervisor list
jon-wei f357014
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei 7d33cc9
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei 09455cf
Address some PR comments
jon-wei faa18d0
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei 655ffac
Address more PR comments
jon-wei 56c40dd
Small cleanup
jon-wei 7ea9a12
Add Jetty HttpClient wrapper to Authenticator
jon-wei 042a4bb
Remove Authorizer start/stop
jon-wei 5c37dc7
Restore immutable context map in DruidConnection, UT fix
jon-wei 880df86
Fix/update docs
jon-wei a3343ee
Add authorization checks to EventReceiverFirehose
jon-wei 9734c9d
Fix router authorization check failure, restore PreResponseAuthorizat…
jon-wei c373bbc
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei 1686d8f
Compile fixes
jon-wei b9c564d
Test fixes
jon-wei bf6b669
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei 02e0a72
Update Authenticator/Authorizer doc comments
jon-wei 2b95a30
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei e9188a0
Merge fixes
jon-wei 375aee8
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei 65895b1
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei eff666c
PR comments
jon-wei 8f3ae31
Merge remote-tracking branch 'upstream/master' into new_security
jon-wei baae14c
Fix test
jon-wei 99a4972
Fix IT
jon-wei e833bef
More PR comments
jon-wei 0f44de3
PR comments
jon-wei 9724acc
SSL fix
jon-wei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
37 changes: 37 additions & 0 deletions
37
api/src/main/java/io/druid/guice/annotations/EscalatedGlobal.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets 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 | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * 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 io.druid.guice.annotations; | ||
|
|
||
| import com.google.inject.BindingAnnotation; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| */ | ||
| @BindingAnnotation | ||
| @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @PublicApi | ||
| public @interface EscalatedGlobal | ||
| { | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| --- | ||
| layout: doc_page | ||
| --- | ||
|
|
||
| # Authentication and Authorization | ||
|
|
||
| |Property|Type|Description|Default|Required| | ||
| |--------|-----------|--------|--------|--------| | ||
| |`druid.auth.authenticationChain`|JSON List of Strings|List of Authenticator type names|["allowAll"]|no| | ||
| |`druid.auth.escalatedAuthenticator`|String|Type of the Authenticator that should be used for internal Druid communications. This Authenticator must be present in `druid.auth.authenticationChain`.|"allowAll"|no| | ||
| |`druid.auth.authorizers`|JSON List of Strings|List of Authorizer type names |["allowAll"]|no| | ||
|
|
||
| ## Enabling Authentication/Authorization | ||
|
|
||
| ## Authentication Chain | ||
| Authentication decisions are handled by a chain of Authenticator instances. A request will be checked by Authenticators in the sequence defined by the `druid.auth.authenticationChain`. | ||
|
|
||
| Authenticator implementions are provided by extensions. | ||
|
|
||
| For example, the following authentication chain definition enables the Kerberos and HTTP Basic authenticators, from the `druid-kerberos` and `druid-basic-security` core extensions, respectively: | ||
|
|
||
| ``` | ||
| druid.auth.authenticationChain=["kerberos", "basic"] | ||
| ``` | ||
|
|
||
| A request will pass through all Authenticators in the chain, until one of the Authenticators successfully authenticates the request or sends an HTTP error response. Authenticators later in the chain will be skipped after the first successful authentication or if the request is terminated with an error response. | ||
|
|
||
| If no Authenticator in the chain successfully authenticated a request or sent an HTTP error response, an HTTP error response will be sent at the end of the chain. | ||
|
|
||
| Druid includes a built-in Authenticator, used for the default unsecured configuration. | ||
|
|
||
| ### AllowAll Authenticator | ||
|
|
||
| This built-in Authenticator authenticates all requests, and always directs them to an Authorizer named "allowAll". It is not intended to be used for anything other than the default unsecured configuration. | ||
|
|
||
| ## Internal Authenticator | ||
| The `druid.auth.escalatedAuthenticator` property determines what authentication scheme should be used for internal Druid cluster communications (such as when a broker node communicates with historical nodes for query processing). | ||
|
|
||
| The Authenticator chosen for this property must also be present in `druid.auth.authenticationChain`. | ||
|
|
||
| ## Authorizers | ||
| Authorization decisions are handled by an Authorizer. The `druid.auth.authorizers` property determines what Authorizer implementations will be active. | ||
|
|
||
| There are two built-in Authorizers, "default" and "noop". Other implementations are provided by extensions. | ||
|
|
||
| For example, the following authorizers definition enables the "basic" implementation from `druid-basic-security`: | ||
|
|
||
| ``` | ||
| druid.auth.authorizers=["basic"] | ||
| ``` | ||
|
|
||
|
|
||
| Only a single Authorizer will authorize any given request. | ||
|
|
||
| Druid includes one built in authorizer: | ||
|
|
||
| ### AllowAll Authorizer | ||
| The Authorizer with type name "allowAll" accepts all requests. | ||
|
|
||
| ## Default Unsecured Configuration | ||
|
|
||
| When `druid.auth.authenticationChain` is left empty or unspecified, Druid will create an authentication chain with a single AllowAll Authenticator named "allowAll". | ||
|
|
||
| When `druid.auth.authorizers` is left empty or unspecified, Druid will create a single AllowAll Authorizer named "allowAll". | ||
|
|
||
| The default value of `druid.auth.escalatedAuthenticator` is "allowAll" to match the default unsecured Authenticator/Authorizer configurations. | ||
|
|
||
| ## Authenticator to Authorizer Routing | ||
|
|
||
| When an Authenticator successfully authenticates a request, it must attach a AuthenticationResult to the request, containing an information about the identity of the requester, as well as the name of the Authorizer that should authorize the authenticated request. | ||
|
|
||
| An Authenticator implementation should provide some means through configuration to allow users to select what Authorizer(s) the Authenticator should route requests to. | ||
|
|
||
| ## Internal System User | ||
|
|
||
| Internal requests between Druid nodes (non-user initiated communications) need to have authentication credentials attached. | ||
|
|
||
| These requests should be run as an "internal system user", an identity that represents the Druid cluster itself, with full access permissions. | ||
|
|
||
| The details of how the internal system user is defined is left to Authorizer and Authenticator implementations. | ||
|
|
||
| ### Authorizer Internal System User Handling | ||
|
|
||
| Authorizers implementations must recognize and authorize an identity for the "internal system user", with full access permissions. | ||
|
|
||
| ### Authenticator Internal System User Handling | ||
|
|
||
| Authenticators must implement three methods related to the internal system user: | ||
|
|
||
| ```java | ||
| public HttpClient createEscalatedClient(HttpClient baseClient); | ||
|
|
||
| public org.eclipse.jetty.client.HttpClient createEscalatedJettyClient(org.eclipse.jetty.client.HttpClient baseClient); | ||
|
|
||
| public AuthenticationResult createEscalatedAuthenticationResult(); | ||
| ``` | ||
|
|
||
| `createEscalatedClient` returns an wrapped HttpClient that attaches the credentials of the "internal system user" to requests. | ||
|
|
||
| `createEscalatedJettyClient` is similar to `createEscalatedClient`, except that it operates on a Jetty HttpClient. | ||
|
|
||
| `createEscalatedAuthenticationResult` returns an AuthenticationResult containing the identity of the "internal system user". | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what is the expected behavior in case the authorizer returned is not present in list of druid.auth.authorizers ?