Skip to content

Conversation

@rhim
Copy link
Contributor

@rhim rhim commented Dec 16, 2016

  1. Add default admin authorization for built in admin user.
  2. Add principals claim to login token to represent local user/ldap
    groups associated with a AD user
  3. Use authorizations to add role claim to token that is used by UI for
    role differentiation
  4. Use authorizations to generate role claim at runtime to perform RBAC
    on API calls

1. Add default admin authorization for built in admin user.
2. Add principals claim to login token to represent local user/ldap
groups associated with a AD user
3. Use authorizations to add role claim to token that is used by UI for
role differentiation
4. Use authorizations to generate role claim at runtime to perform RBAC
on API calls
@rhim rhim requested review from dseevr, selvik and yuva29 December 16, 2016 08:34
switch {
// If no authorizations are found, this user has not been authorized to
// access any resources yet. Return success without adding the claim.
case l == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this only means that there is no role=whatever is added for the principal, but the principal may have tenant authZs defined. Am I right?

Copy link
Contributor

Choose a reason for hiding this comment

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

How are we expecting the UI to treat a token with no role?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Return an error message saying "you are not authorized. Go talk to Admin and get access to something first"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

role=whatever authorization will be added automatically (will come in next PR) whenever the tenant authz is added.

case l == 0:
return nil

default:
Copy link
Contributor

@yuva29 yuva29 Dec 16, 2016

Choose a reason for hiding this comment

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

l>1 if more than one role authZ is defined for the user. e.g. role=admin, role=ops? Shouldn't we handle that or Are we restricting it to be only 1 at any point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there is only 1. The goal is to "cache" the highest role available. It is only really useful when you are working with global access roles such as admin. For most RBAC impl., we will be looking for tenant authz with specific roles.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

}

// If not a valid role, ignore error and move on to next principal
r, err := types.Role(authz[0].ClaimValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

How are we assuming len(auth)<=1 always?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above. There will be only 1 claim of type role, if any.

Copy link
Contributor

@dseevr dseevr left a comment

Choose a reason for hiding this comment

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

👍

return types.Authorization{}, err
}

log.Info("Adding role authorization successful")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we log a few more deets here, like the principalName and role? Not sure how much value this line adds currently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Let me clean it up in my next PR.

tmp, ok := auth.(*types.Authorization)
if ok {
if (tmp.ClaimKey == claim) && (tmp.PrincipalID == ID) {
if (tmp.ClaimKey == claim) && (tmp.PrincipalName == principal) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The parentheses here are unnecessary and can be removed

@yuva29
Copy link
Contributor

yuva29 commented Dec 16, 2016

@rhim
Copy link
Contributor Author

rhim commented Dec 16, 2016 via email

@rhim rhim merged commit 36a58f2 into contiv:master Dec 17, 2016
@rhim rhim deleted the auth_model branch December 17, 2016 02:09
dseevr pushed a commit to dseevr-dev/auth_proxy that referenced this pull request Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants