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

Fix UserContext SSO detection in UI for Okta Users #47944

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

marcoandredinis
Copy link
Contributor

Okta imported users are not being properly identified as SSO users. Okta does not set any of the Users' identities and instead only sets the User.Connector.CreatedBy field.

When building the UserContext, which is used by the WebUI, it was returning local user type for Okta users.

As an example of what this fixes in the UI: when setting traits during the Discover flows, User is now correctly asked to change the Teleport Role instead of being allowed to enter principals but then getting an error.

Before
image

After
image

Fixes #47901

changelog: During the Set Up Access of the Enroll New Resource flows, Okta users will be asked to change the role instead of entering the principals and getting an error afterwards.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-47944.d3pp5qlev8mo18.amplifyapp.com

Comment on lines 107 to 108
isSSO := user.GetUserType() == types.UserTypeSSO ||
len(user.GetOIDCIdentities()) > 0 ||
Copy link
Contributor

@greedy52 greedy52 Oct 25, 2024

Choose a reason for hiding this comment

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

looks good to me. just curious if user.GetUserType() is enough without checking other identities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It only checks for the CreatedBy.Connector != nil.
I did that, but some tests started failing so I'm not sure we should be changing that.

On the other hard, maybe user.GetUserType() should check not only for the CreatedBy.Connector but also for the OIDC and SAML identities.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ended up moving the check to user.GetUserType
I'm pretty confident we could remove the SAML/OIDC checks but playing on the safe side here.

Okta imported users are not being properly identified as SSO users.
Okta does not set any of the Users' identities and instead only sets the
User.Connector.CreatedBy field.

When building the UserContext, which is used by the WebUI, it was
returning `local` user type for Okta users.
@marcoandredinis marcoandredinis force-pushed the marco/fix_ui_sso_detection branch from 5caea60 to cc605f4 Compare October 25, 2024 16:08
@marcoandredinis marcoandredinis added this pull request to the merge queue Oct 25, 2024
Merged via the queue into master with commit 9b754bf Oct 25, 2024
41 checks passed
@marcoandredinis marcoandredinis deleted the marco/fix_ui_sso_detection branch October 25, 2024 16:45
@public-teleport-github-review-bot

@marcoandredinis See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Create PR
branch/v16 Create PR

marcoandredinis added a commit that referenced this pull request Oct 25, 2024
* Fix UserContext SSO detection in UI for Okta Users

Okta imported users are not being properly identified as SSO users.
Okta does not set any of the Users' identities and instead only sets the
User.Connector.CreatedBy field.

When building the UserContext, which is used by the WebUI, it was
returning `local` user type for Okta users.

* move usertype check to types.User
marcoandredinis added a commit that referenced this pull request Oct 28, 2024
* Fix UserContext SSO detection in UI for Okta Users

Okta imported users are not being properly identified as SSO users.
Okta does not set any of the Users' identities and instead only sets the
User.Connector.CreatedBy field.

When building the UserContext, which is used by the WebUI, it was
returning `local` user type for Okta users.

* move usertype check to types.User
github-merge-queue bot pushed a commit that referenced this pull request Oct 28, 2024
…7959)

* Fix UserContext SSO detection in UI for Okta Users (#47944)

* Fix UserContext SSO detection in UI for Okta Users

Okta imported users are not being properly identified as SSO users.
Okta does not set any of the Users' identities and instead only sets the
User.Connector.CreatedBy field.

When building the UserContext, which is used by the WebUI, it was
returning `local` user type for Okta users.

* move usertype check to types.User

* remove User.Status field which only exists on 15+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discover: set up principals (traits) fails when user is imported from Okta
3 participants