-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[UIAM] Cloud API key authentication #128440
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
Open
n1v0lg
wants to merge
27
commits into
elastic:main
Choose a base branch
from
n1v0lg:uiam-cloud-api-key-authentication
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+330
−31
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d5bc9d2
[UIAM] Cloud API key authentication
n1v0lg c673649
Clean up
n1v0lg 3f6b6ff
Nit
n1v0lg 604c630
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 95c9a38
Fix more tests
n1v0lg d45fe0c
Nit
n1v0lg cd8b9f1
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 3be47f0
Fix sig
n1v0lg 12908fa
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 0b6bdff
Fix not
n1v0lg c974761
Nit
n1v0lg 113f6a5
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 5b89907
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 7bfb559
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 6966cea
Authenticator
n1v0lg e3abd81
More
n1v0lg 8b0f1d3
Javadoc
n1v0lg ca6efe8
Javadoc
n1v0lg 444b9a1
Fix tests
n1v0lg f868daf
Exception handling
n1v0lg e4f5b9e
Javadoc
n1v0lg 0686c92
Merge branch 'main' into uiam-cloud-api-key-authentication
n1v0lg 65aebd2
Merge branch 'main' of github.com:elastic/elasticsearch into uiam-clo…
slobodanadamovic f1965d3
add new transport version
slobodanadamovic 30dc57d
add todo to followup in ES-11961
slobodanadamovic bd19d18
test cloud API key authentication serialization
slobodanadamovic 4d07cdc
Merge branch 'main' of github.com:elastic/elasticsearch into uiam-clo…
slobodanadamovic 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
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
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
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
51 changes: 51 additions & 0 deletions
51
...in/java/org/elasticsearch/xpack/core/security/authc/apikey/CustomApiKeyAuthenticator.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,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.security.authc.apikey; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.core.Nullable; | ||
import org.elasticsearch.xpack.core.security.authc.Authentication; | ||
import org.elasticsearch.xpack.core.security.authc.AuthenticationResult; | ||
import org.elasticsearch.xpack.core.security.authc.AuthenticationToken; | ||
|
||
/** | ||
* An extension point to provide a custom API key authenticator implementation. | ||
* The implementation is wrapped by a core `Authenticator` class and included in the authenticator chain _before_ the | ||
* default API key authenticator. | ||
*/ | ||
public interface CustomApiKeyAuthenticator { | ||
String name(); | ||
|
||
AuthenticationToken extractCredentials(@Nullable SecureString apiKeyCredentials); | ||
|
||
void authenticate(@Nullable AuthenticationToken authenticationToken, ActionListener<AuthenticationResult<Authentication>> listener); | ||
|
||
/** | ||
* A no-op implementation of {@link CustomApiKeyAuthenticator} that is effectively skipped in the authenticator chain. | ||
*/ | ||
class Noop implements CustomApiKeyAuthenticator { | ||
@Override | ||
public String name() { | ||
return "noop"; | ||
} | ||
|
||
@Override | ||
public AuthenticationToken extractCredentials(@Nullable SecureString apiKeyCredentials) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void authenticate( | ||
@Nullable AuthenticationToken authenticationToken, | ||
ActionListener<AuthenticationResult<Authentication>> listener | ||
) { | ||
listener.onResponse(AuthenticationResult.notHandled()); | ||
} | ||
} | ||
} |
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
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.
I really don't love this. Is there a reason you specifically want a pluggable
CloudApiKeyService
rather than just additional authenticators?That is, I would have opted to have a more generic extension point and push most of the
CloudApiKey
code into the extension itself rather than in core security.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.
That was my original idea too. It would require moving quite a lot of classes around though since
Authenticator
is not accessible fromSecurityExtension
:SecurityExtension
is inorg.elasticsearch.xpack.core.security
which does not have access toAuthenticator
Authenticator
is inorg.elasticsearch.xpack.security.authc
which depends onorg.elasticsearch.xpack.core.security
Moving it would require quite a few classes getting pulled up -- it feels like something we can follow up on in a bigger refactor subsequently but let me know if it's too big a blocker for you.
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.
One thing we could consider is injecting a cloud API key authenticator like class into
ApiKeyAuthenticator
cc @slobodanadamovic
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.
I pushed a commit that uses a
CustomApiKeyAuthenticator
extension point -- as discussed on Slack.