Skip to content
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

Refactor Security code to use TransportVersion #93089

Merged
merged 49 commits into from
Jan 26, 2023

Conversation

pgomulka
Copy link
Contributor

@pgomulka pgomulka commented Jan 19, 2023

With the introduction of TransportVersion we want to use this object in transport protocol related code (usages of StreamInput, StreamOutput).
Also with serverless release being more frequent then on-prem the code changes that relied on Node's Version to perform a conditional logic are also refactored to use TransportVersion which has higher granularity

@pgomulka pgomulka changed the title Security trasnport version Security transport version Jan 19, 2023
@@ -87,7 +87,7 @@ public Map<String, Object> getMetadata() {
return metadata;
}

public Version getVersion() {
public TransportVersion getTransportVersion() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places, when replacing existing version methods, I've just left it as getVersion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tended to replace the method name too. I feel it might read better

}

public Subject(User user, Authentication.RealmRef realm, Version version, Map<String, Object> metadata) {
public Subject(User user, Authentication.RealmRef realm, TransportVersion version, Map<String, Object> metadata) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this version number actually mean in the security code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

judging by when this is called I would suspect that this has the same meaning as a transport version in StreamInput
https://github.com/pgomulka/elasticsearch/blob/1db5baa41b5c933ead5cba9a848b9aa95e749546/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java#L155

once this PR is ready for review I will follow up with security team

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed ofline: Version in Subject and UserToken is used for serialisation into a Base64 strings. It does not use transport protocol (serialisation is into ThreadContext or XContent) but is using StreamInput/StreamOutput api

@@ -110,7 +110,7 @@ public String getId() {
/**
* The version of the node this token was created on
*/
Version getVersion() {
TransportVersion getTransportVersion() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the comment, this is the actual node version. Do we want to change this to TransportVersion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment. I think this should be a transportVersion as per https://github.com/elastic/elasticsearch/pull/93089/files#r1087901056

@pgomulka pgomulka changed the title Security transport version Refactor Security code to use TransportVersion Jan 24, 2023
@pgomulka pgomulka added :Core/Infra/Core Core issues without another label :Security/Security Security issues without another label >refactoring labels Jan 24, 2023
@pgomulka
Copy link
Contributor Author

pgomulka commented Jan 24, 2023

@elastic/es-security would you be able to take a look at the PR?
we were wondering if you could put some light on the meaning of Version in security code. For instance https://github.com/elastic/elasticsearch/pull/93089/files#r1084169354
in Subject there is a Version field, what is the purpose of this field? Should we expect any other use of Version than transport protocol ?

Similar question to UserToken #93089 (comment)

@pgomulka pgomulka marked this pull request as ready for review January 24, 2023 14:13
@elasticsearchmachine elasticsearchmachine added Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team labels Jan 24, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Member

@thecoop thecoop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in the codebase for now, and see how it evolves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >refactoring :Security/Security Security issues without another label Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants