-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Return API key name in _authentication response #78946
Return API key name in _authentication response #78946
Conversation
Responses to POST /_security/api_key includes id, name, metadata, api_key (shared secret), and encoded (base64 of id:api_key). Requests to GET /_security/_authenticate returns data about the user, but not the API KEY. When authenticating using an API KEY, return API KEY info map in the response. The initial feature request asked for 'name'. However, the request's Authentication header contains 'encoded', so the decoded 'id' will be returned for convenience too. When authenticating using any other method, API KEY info map is omitted. Closes elastic#70306
Responses to POST /_security/api_key includes id, name, metadata, api_key (shared secret), and encoded (base64 of id:api_key). Requests to GET /_security/_authenticate returns data about the user, but not the API KEY. When authenticating using an API KEY, return API KEY info map in the response. The initial feature request asked for 'name'. However, the request's Authentication header contains 'encoded', so the decoded 'id' will be returned for convenience too. When authenticating using any other method, API KEY info map is omitted. Closes elastic#70306
...gin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/AuthenticationResult.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java
Outdated
Show resolved
Hide resolved
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 didn't really look into the client side code. But here are a few things on the server side.
...lugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ApiKeyServiceField.java
Outdated
Show resolved
Hide resolved
...curity-trial/src/javaRestTest/java/org/elasticsearch/xpack/security/apikey/ApiKeyRestIT.java
Outdated
Show resolved
Hide resolved
...src/javaRestTest/java/org/elasticsearch/xpack/security/authc/SecurityRealmSmokeTestCase.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/api_key/10_basic.yml
Show resolved
Hide resolved
...l-realms/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/NativeRealmAuthIT.java
Outdated
Show resolved
Hide resolved
...nt/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateResponse.java
Outdated
Show resolved
Hide resolved
...ck/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java
Outdated
Show resolved
Hide resolved
# Conflicts: # x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java
Fix merge issue.
@elasticmachine update branch |
...plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java
Show resolved
Hide resolved
@elasticmachine update branch |
merge conflict between base and head |
@elasticmachine update branch |
merge conflict between base and head |
4ba6dee
to
15e140a
Compare
@elasticmachine update branch |
991db2e
to
8da4cb1
Compare
ff24e60
to
96884c1
Compare
@elasticmachine update branch |
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.
LGTM. (Not sure why my previous disappeared. But I approved already a couple days back.)
Responses to POST /_security/api_key includes id, name, metadata,
api_key (shared secret), and encoded (base64 of id:api_key).
Requests to GET /_security/_authenticate returns data about the user,
but not the API KEY.
When authenticating using an API KEY, return API KEY info map in the
response. The initial feature request asked for 'name'. However, the
request's Authentication header contains 'encoded', so the decoded
'id' will be returned for convenience too.
When authenticating using any other method, API KEY info map is
omitted.
Closes #70306
Example request:
Example response: