-
Notifications
You must be signed in to change notification settings - Fork 280
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
[Question] How should service account permissions be stored and where? #2566
Comments
@scrawfor99 This is a great write-up! My thoughts are that there should be one policy associated with an extension that will dictate how requests originating from the extension can interact with a cluster. In my mind, the policy will look similar to how roles are defined in the security plugin currently. For example:
This policy would be configured by a cluster admin on installation and an extension could provide a default recommended configuration that the cluster admin could accept/edit before accepting. Over the weekend, I was thinking about introducing the notion of a |
This issue is covering storage in terms of 'physical storage' location and I am also interested in the code structure of extensions objects themselves and the relationship between a service account, its permissions, vs the capabilities/limitations/scopes of an extension. Is everything on a single object, are there multiple objects, how does information get looked up, etc... |
Hi @peternied, thank you for the comment. I will try to address that more clearly in an additional question. I know @cwperks had been wondering about this and left a comment on #2572 about service accounts. I will add a decision framework for that here and link on the other issue. |
Hi @cwperks, thank you for your thoughtful feedback. I like your idea about the policy file. I have actually covered some similar ideas over on #2552 which may interest you. In the meantime, I am going to take some time to add a decision/question for service account vs. extension object vs. something else as the last item on this issue. I will first reference what you wrote over on #2572 though. |
Hi @opensearch-project/security, I am going to make some executive decisions to try to drive these questions to a resolution. For each of the points below, I will be moving forward unless I hear objections by Monday 4/3.
|
@scrawfor99 I really want to be clear with language.
i.e.
i.e.
could be the roles definition for a service account token created for the service account associated with AD. |
Should we rename this to something more along the lines of service account permissions? |
Problem Statement
Where and how should extension permissions be stored?
Action items decided on this issue:
Where and how extension permissions are stored is an important consideration when designing the overall authorization structure. Currently, user permissions are stored as part of the configuration repository. The configuration repository is shard'd onto every node in the cluster and the Security Plugin is stored on every index as part of a cache. Every time there is a change in the Security settings, the cache is invalidated and reloaded from the shard'd repository which will be eventually consistent. The current system has issues as the number of changes touching the configuration repository grow. Every time there is a change, the repository is updated on all the nodes and all caches are invalidated and require reloading. This leads to a number of scaling issues and also causes multiple requests to be sent throughout the cluster every time there is an API call that touches the security plugin.
There are two main locations where it makes sense to store extension permissions.
What do code changes look like?
What do code changes look like?
For choosing a data structure, it seems there are numerous valid options with the two most prominent being maps and lists, and maps and tries.
With maps and tries, the extension would still be used as the key but now the various permissions would be stored in a trie structure. When resolving a permission you would access the key value and then parse the trie until you reached a leaf indicating the permission was not found or you found the appropriate permission.
Example diagram:
NOTE: This question is closely related to the previous question about where extension permissions are stored. If extension permissions are stored alongside user permissions then it makes sense to simply store extension permissions in the same manner as user permissions. This option could use the extension ID as the stand-in for the username and treat everything else the same.
For user permissions, the Security Plugin makes use of roles to resolve authorization. Roles are used to grant numerous users the same set of permissions based on their membership. These roles are then resolved into their constituent permissions when a request is processed.
As an example consider two users Sean and Nushi. These users work at Library.com, whose administrator has made roles
Librarian
,Accountant
, andAdministrator
. TheLibrarian
has permissionsread, archive, write
. TheAccountant
has permissionsread, write, calculate.
TheAdministrator
has permissionsread, write, archive, calculate, delete
. Sean is assigned rolesLibrarian
andAccountant
. Nushi is assigned rolesAccountant
andAdministrator
.When Sean then attempts to
read
a book, the cluster first accesses his assigned roles. It sees he is assignedLibrarian
andAccountant
and views the permissions associated withLibrarian
. BecauseLibrarian
has the permissionread
Sean is able toread
the book. When Sean then tries todelete
the book because he feels it is outdated, the cluster checks the permissions forLibrarian
once more. Permission fordelete
is not part of that role so the cluster then checks theAccountant
permissions. Again,delete
is not part of that role's permissions so Sean is unable to perform the action. Nushi then comes along and tries todelete
the book. Because Nushi is anAdministrator
, when the cluster resolves their roles, it sees they are able to perform the action. The book is deleted.Roles are used for user permissions because of the nature of large organizations where it is important to be able to assign the same set of permissions to many people. For example, everyone at Library.com is an employee, but as shown above, not everyone is an administrator. A cluster administrator would not want to have to iteratively assign the same set of basic permissions i.e.
read
, to the thousands of employees at the company. They also do not want everyone to be able todelete
books.Returning to the topic at hand, there are three options for dealing with roles with extensions.
NOTE: Role support could be added at a later point, but removing role support after adding it would be inadvisable.
What do code changes look like?
f roles are used, then the
Extension
object (if implementation goes that route) should allow for storage of associated roles as part of the metadata. The roles can be stored in an attribute of the class instance and then queried when resolving the permissions. Alternatively, an extension service account could be used as a reference to the given extension and the account could be stored in the same manner user accounts are stored. When the roles were to be resolved, they could be resolved exactly like a user's roles would be.What do code changes look like?
If roles are only used for granting permissions but not resolving them, then it will be necessary to make further changes to the code base. Specifically, this option requires either an
Extension
object class which can have the assigned permissions associated with each extension as an attribute or an extension ID of some kind that can be used to reference a list of permissions somewhere. This option could still allow for extensions to slot in with user accounts but the method of resolving would require changes in thePrivilegesEvaluator
of the Security Plugin so that permissions can be resolved without roles. Changes will also be needed in the permission granting code since role-based permission grants to extensions will need to be immediately resolved into the constituent privileges.What do code changes look like?
This option would require the same code changes as the previous option minus the code needed to make role-based granting resolve immediately into permissions.
In order to handle extensions, it is important to have some method of tracking them. There has to be something that allows OpenSearch to identify which extension is which and have confidence it is operating on the correct extension's behalf. Likewise, the Security Plugin will benefit from having a reference to different extensions and their metadata. Extension metadata could include things like the permissions an extension has, an extension's ID, and references to any predefined roles the extension expects to operate with. There are two main options for handling this tracking.
permissionsList/rolesList
(depending on whether roles are used or not),extensionId
representing a unique extension reference,actionToPermissionsMapping
representing the specific permissions that are required for an action to be able to complete its registered actions, andpredefinedRoles
which lists the roles it registered on installation.What do code changes look like?
If an Extension object class were to be used, the code changes would be significant. It would require adding an entire new Extension object into OpenSearch core which would then be inherited by the Security Plugin. This option would also require the registration of all predefined roles and action to required permissions when an extension was first installed. On top of the object class, code changes would need to be made to the
PrivilegesEvaluator
in the Security Plugin to access the appropriate Extension object and parse its permissions when authorizing its requests. Further code changes would likely be required elsewhere in the Security Plugin for retrieving the Extension ID from a token and comparing it to an Extension object's associated Id.What do code changes look like?
This option requires fewer code changes than creating an Extension object would. Code changes would be required in OpenSearch core for the creation of an internal user whenever an extension was installed as well as for adding permissions to its single role. Code changes would not be required in the
PrivilegesEvaluator
since the role based resolution would be the same as what is currently in place.The text was updated successfully, but these errors were encountered: