Skip to content

Support Client and RoleMapping in custom Realms#50534

Merged
tvernum merged 9 commits intoelastic:masterfrom
tvernum:feature/48369-security-extension-components
Jan 14, 2020
Merged

Support Client and RoleMapping in custom Realms#50534
tvernum merged 9 commits intoelastic:masterfrom
tvernum:feature/48369-security-extension-components

Conversation

@tvernum
Copy link
Copy Markdown
Contributor

@tvernum tvernum commented Dec 31, 2019

Previously custom realms were limited in what services and components
they had easy access to. It was possible to work around this because a
security extension is packaged within a Plugin, so there were ways to
store this components in static/SetOnce variables and access them from
the realm, but those techniques were fragile, undocumented and
difficult to discover.

This change includes key services as an argument to most of the methods
on SecurityExtension so that custom realm / role provider authors can
have easy access to them.

Resolves: #48369

Previously custom realms were limited in what services and components
they had easy access to. It was possible to work around this because a
security extension is packaged within a Plugin, so there were ways to
store this components in static/SetOnce variables and access them from
the realm, but those techniques were fragile, undocumented and
difficult to discover.

This change includes key services as an argument to most of the methods
on SecurityExtension so that custom realm / role provider authors can
have easy access to them.

Resolves: elastic#48369
@tvernum
Copy link
Copy Markdown
Contributor Author

tvernum commented Dec 31, 2019

This required the UserRoleMapper interface from security to core, which trigger a lot of very small changes (imports) across multiple realms & tess.

Copy link
Copy Markdown
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

I've raised a few questions, but I don't feel strongly about any of them.

* @param components Access to components that may be used to build realms
*/
default Map<String, Realm.Factory> getRealms(ResourceWatcherService resourceWatcherService) {
default Map<String, Realm.Factory> getRealms(SecurityComponents components) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think a Settings object might be useful as well? (same for other methods)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Settings is on RealmConfig, so I didn't add it here, but I think that was a mistake.
It makes sense to have everything available in 1 place. I'll add environment and settings to the components interface.

@albertzaharovits albertzaharovits self-requested a review January 12, 2020 21:55
Copy link
Copy Markdown
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

The SecurityExtension#SecurityComponents interface LGTM. I trust that the other methods will use a single components parameter.

@tvernum tvernum merged commit 75b68fa into elastic:master Jan 14, 2020
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Jan 14, 2020
Previously custom realms were limited in what services and components
they had easy access to. It was possible to work around this because a
security extension is packaged within a Plugin, so there were ways to
store this components in static/SetOnce variables and access them from
the realm, but those techniques were fragile, undocumented and
difficult to discover.

This change includes key services as an argument to most of the methods
on SecurityExtension so that custom realm / role provider authors can
have easy access to them.

Backport of: elastic#50534
tvernum added a commit that referenced this pull request Jan 14, 2020
Previously custom realms were limited in what services and components
they had easy access to. It was possible to work around this because a
security extension is packaged within a Plugin, so there were ways to
store this components in static/SetOnce variables and access them from
the realm, but those techniques were fragile, undocumented and
difficult to discover.

This change includes key services as an argument to most of the methods
on SecurityExtension so that custom realm / role provider authors can
have easy access to them.

Backport of: #50534
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
Previously custom realms were limited in what services and components
they had easy access to. It was possible to work around this because a
security extension is packaged within a Plugin, so there were ways to
store this components in static/SetOnce variables and access them from
the realm, but those techniques were fragile, undocumented and
difficult to discover.

This change includes key services as an argument to most of the methods
on SecurityExtension so that custom realm / role provider authors can
have easy access to them.

Resolves: elastic#48369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom realms to use additional supporting objects

3 participants