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

feat: adding an OAuth provider for WorkOS #3831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

panbanda
Copy link

@panbanda panbanda commented Mar 19, 2024

We needed a way to extend our auth capabilities to allow for SSO and discovered WorkOS. It's enterprise SSO and you interact with it in an OIDC/OAuth kind of way. Their integration is OAuth ready so making an OAuth provider for WorkOS gives us the ability to use enterprise SSO with Kratos.

I didn't add any new features in this PR it's mainly just a new provider.

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    security@ory.sh) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

To use this provider it would look like this and you would basically set this up for each of your enterprise SSO clients

selfservice:
  methods:
    oidc:
      config:
        providers:
          - id: demo-organization
            provider: workos
            client_id: client_00000000000000000
            client_secret: sk_live_...
            workos_organization_id: org_000000000000000000
            mapper_url: "base64://..."
            scope: []

@CLAassistant
Copy link

CLAassistant commented Mar 19, 2024

CLA assistant check
All committers have signed the CLA.

@panbanda panbanda changed the title feat: added workos provider Adding an OAuth provider for WorkOS Mar 19, 2024
@panbanda panbanda changed the title Adding an OAuth provider for WorkOS feat: Adding an OAuth provider for WorkOS Mar 19, 2024
@panbanda panbanda changed the title feat: Adding an OAuth provider for WorkOS feat: adding an OAuth provider for WorkOS Mar 19, 2024
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 48.71795% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 77.96%. Comparing base (da90502) to head (05e6e9e).

Files Patch % Lines
selfservice/strategy/oidc/provider_workos.go 48.71% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3831      +/-   ##
==========================================
- Coverage   77.98%   77.96%   -0.02%     
==========================================
  Files         359      360       +1     
  Lines       25203    25242      +39     
==========================================
+ Hits        19654    19681      +27     
- Misses       4041     4054      +13     
+ Partials     1508     1507       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aeneasr
Copy link
Member

aeneasr commented Mar 27, 2024

Thank you very much! Could you please add this provider also to the docs? :)

https://www.ory.sh/docs/kratos/social-signin/generic

@panbanda
Copy link
Author

@aeneasr Yep! Done and done.

@panbanda
Copy link
Author

panbanda commented Apr 4, 2024

@aeneasr Please let me know if you need anything else for this review. I was looking at tests and looks like this may be a flaky failure or something. But yeah happy to work to get this merged in.

@BrandonNoad
Copy link
Contributor

Is there a way to configure/implement this so you can have a single OIDC provider that works for multiple WorkOS organizations?

@panbanda
Copy link
Author

panbanda commented Apr 5, 2024

@BrandonNoad I think there may be a way to do that but I would need to update the UpstreamParameters sanitized attributes and schema to include organization. That kind of felt more "hacky" since this feel more like a standard list from oauth2.AuthCodeOption. Are you saying that this would be preferred?

@BrandonNoad
Copy link
Contributor

Are you saying that this would be preferred?

We use Ory and WorkOS. But we have ~200 WorkOS Organizations/Connections. Having 200 different OIDC login buttons isn't practical (for us).

What we ended up doing was wrapping WorkOS in Hydra, and then we have one generic "WorkOS" OIDC provider that is associated with that Hydra.

We have a discovery step during the Login flow where we get the user's email and send that along in the OIDC request. Then in our custom Hydra Login endpoint, we use the email value to look up the WorkOS connection that we should be using.

@panbanda
Copy link
Author

panbanda commented Apr 5, 2024

@BrandonNoad yeah thats nice. I think we were going the route of not showing the hundreds of buttons and instead having landing pages specific to the organizations which would correspond to those oauth providers ID. We were trying to keep it in kratos land but hydra sounds like an interesting route.

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.

None yet

4 participants