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

Dynamic Roles #897

Merged
merged 4 commits into from
Apr 5, 2017
Merged

Dynamic Roles #897

merged 4 commits into from
Apr 5, 2017

Conversation

russjones
Copy link
Contributor

@russjones russjones commented Apr 4, 2017

Purpose

As covered in #891, at the moment using OIDC with individual system logins means you have to either create a role for every user or keep updating a shared role with logins whenever someone new joins the team.

To improve the user experience of OIDC and Teleport, this PR allows you to define a role template that can be used to dynamically create roles based off the claims received from an identity provider.

Implementation

  • The claims_to_roles for an OIDC connector can now contain roles or a role_template that contains an embedded role that is filled out by data from claims.

    claims_to_roles:
      - claim: roles
        value: teleport-admin
        role_template:
          kind: role
          version: v2
          metadata:
            name: '{{index . "email"}}'
            namespace: "default"
          spec:
            namespaces: [ "*" ]
            max_session_ttl: 90h0m0s
            logins: [ '{{index . "nickname"}}', root ]
            node_labels:
               "*": "*"
            resources:
              "*": [ "read", "write" ]
            forward_agent: true
  • UpsertRole has been updated with a TTL so that dynamic roles are removed along with the dynamic user.

  • User creation logic has been updated so if you re-login via OIDC you don't have to wait for your existing User to expire.

Related Issues

Fixes #891

@russjones russjones force-pushed the rjones/oidc-templates branch from 30c38b9 to ecbd113 Compare April 4, 2017 22:30
@russjones russjones force-pushed the rjones/oidc-templates branch from ecbd113 to fcfb883 Compare April 5, 2017 00:06
lib/auth/auth.go Outdated
}

// figure out ttl for role. expires = now + ttl => ttl = expires - now
ttl := ident.ExpiresAt.Sub(time.Now())
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use auth server clock instead?

lib/auth/auth.go Outdated
} else {
}

// check if any exisiting user is a non-oidc user, dont override their
Copy link
Contributor

Choose a reason for hiding this comment

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

incomplete comment sentence

// Roles is a list of static teleport roles to match.
Roles []string `json:"roles,omitempty"`
// RoleTemplate a template role that will be filled out with claims.
RoleTemplate *RoleV2 `json:"role_template,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

can you implement this sligthly in a different way that will allow me to add extesions:

  • use json.RawMessageHere
  • use GetRoleMarshaller().Unmarshal()
  • set the value

This will allow me to override this setting in Telekube and Teleport Enterprise

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, nevermind, I can already do this without this change

Copy link
Contributor

@klizhentas klizhentas left a comment

Choose a reason for hiding this comment

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

have a couple of comments around using time, otherwise looks good.

@russjones
Copy link
Contributor Author

@klizhentas Made the changes you suggested, can you take another look?

@russjones russjones merged commit 5e6c0ae into master Apr 5, 2017
@russjones russjones deleted the rjones/oidc-templates branch April 24, 2017 21:21
hatched pushed a commit to hatched/teleport-merge that referenced this pull request Nov 30, 2022
hatched pushed a commit that referenced this pull request Dec 20, 2022
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.

2 participants