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

Added group member check #21

Closed
wants to merge 1 commit into from
Closed

Added group member check #21

wants to merge 1 commit into from

Conversation

renanqts
Copy link
Contributor

#18

@k3a
Copy link

k3a commented May 7, 2020

So if I understand it correctly, your use-case is not using Kubernetes with ClusterRole/ClusterRoleBinding but a pre-configured group-based check as an alternative implementation of Authorizer.

It would be mostly ok, but I don't like that it changes the API of Authorizer interface so much. Even the extra map allocation doesn't look very good to me. It would be ah-well-ok if it were an optional map with some extra metadata but not the main argument. Directly accessing map keys like requestVerb := m["requestVerb"].(string) can also easily produce panic if the map keys change without modifying other parts of codebase expecting those keys.

I think the better approach would be to keep the Authorizer api as is (user User, requestVerb, requestResource string) and use the first user argument to extract user groups for the purpose of that different authorizer.

Then, you would supply your configured authorizer in NewServer like so:

func NewServer(sessionStore sessions.Store, clientset kubernetes.Interface) *Server {
	s := &Server{
		log: internallog.NewDefaultLogger(config.LogLevel, config.LogFormat),
	}
	s.buildRoutes()
	s.sessionStore = sessionStore
	if config.EnableRBAC {
		s.authorizer = rbac.NewRBACAuthorizer(clientset)
	} else if config.GroupsMemberOf != "" {
		s.authorizer = groupmemberof.NewAuthorizer(config.GroupsMemberOf)
	}
	return s
}

That your authorizer would be just another implementation of the common Authorizer interface which is probably what we all would like. What do you think?

Copy link
Contributor

@jr0d jr0d 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 not change the Authorizer interface

@@ -54,6 +54,7 @@ type Config struct {
GroupClaimPrefix string `long:"group-claim-prefix" env:"GROUP_CLAIM_PREFIX" default:"oidc:" description:"prefix oidc group claims with this value"`
SessionKey string `long:"session-key" env:"SESSION_KEY" description:"A session key used to encrypt browser sessions"`
GroupsAttributeName string `long:"groups-attribute-name" env:"GROUPS_ATTRIBUTE_NAME" default:"groups" description:"Map the correct attribute that contain the user groups"`
GroupsMemberOf string `long:"groups-member-of" env:"GROUPS_MEMBER_OF" description:"List of groups that the user must be member, at least one"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
GroupsMemberOf string `long:"groups-member-of" env:"GROUPS_MEMBER_OF" description:"List of groups that the user must be member, at least one"`
GroupsMemberOf CommaSeparatedList `long:"groups-member-of" env:"GROUPS_MEMBER_OF" description:"List of groups that the user must be member, at least one"`

@renanqts renanqts closed this May 16, 2020
@renanqts
Copy link
Contributor Author

That is okay for me.

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