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

Support multiple credentials in subject extraction #1066

Open
Yshayy opened this issue Jan 20, 2019 · 0 comments
Open

Support multiple credentials in subject extraction #1066

Yshayy opened this issue Jan 20, 2019 · 0 comments

Comments

@Yshayy
Copy link
Contributor

Yshayy commented Jan 20, 2019

Allow to extract multiple identities (or just groups(?)) per token.
The problem rises when trying to map between a single token that contain several groups such as an AD token.

We can solve this problem by using rego to build virtual document of "subjects", instead of:

package rules

default subject = { "user": null, "group": null }
subject = { "user": input.sub, "group": "default" }

we can have:

package rules

subjects[{"group":"default", "user":input.sub}] = {true}

or more complex example:

subjects[{group:group, user:input.sub}] {input.iis="some-ad-issuer"; group = input.groups[_]}

for input:

{sub: "my-user", iis: "some-ad-issuer", groups: ["group-a, group-b"]}

evaluating "subjects" will return

[
      {"group:"group-a", "user":"my-user"},
      {"group:"group-b", "user":"my-user"}
]

After that, we can evaluate the authorizer multiple time for each subject (while still maintaining backward compatibility support) and "allow" if we have one "allow" match.

It'll require changing subject extractor to support multiple subjects: https://github.com/Soluto/tweek/blob/master/services/gateway/security/subjectExtractor.go#L62
same for userInfoFromRequest: https://github.com/Soluto/tweek/blob/master/services/gateway/security/authentication.go#L81
and running authorize for each userinfo until we have true:
https://github.com/Soluto/tweek/blob/master/services/gateway/security/authorization.go#L33
And there are other changes as these objects are pass along request utils and such

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant