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

OIDC login provider support #9

Closed
firestrife23 opened this issue Oct 25, 2021 · 41 comments · Fixed by #60
Closed

OIDC login provider support #9

firestrife23 opened this issue Oct 25, 2021 · 41 comments · Fixed by #60
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@firestrife23
Copy link

I understand your reasons for Auth0. have you heard of self-hosted Authentik? it does pretty much the same as Auth0 in the most area such as Oauth2, SAML, LDAP, and third party integration with Google, Facebook, Twitter, Duo, etc.

@lonnietc
Copy link

Hello,

I am also wondering if there could be support for SuperTokens (https://supertokens.io/) which I just found yesterday and which also has a free tier as well as the option to run your own instance onsite. This might be a good options to have in as well.

@braginini
Copy link
Contributor

braginini commented Oct 26, 2021

hey @firestrife23, @lonnietc

These are good options. We were looking into SuperTokens or keycloak and we are considering supporting it.
I can't give any clear delivery date yet.

Btw, would you be willing to participate in implementing this integration?

@firestrife23
Copy link
Author

More than happy to provide feedback on the implementation.

@pomazanbohdan
Copy link

I would like to turn off the authorization page in the management console altogether

I can add basic authorization to reverse proxy
https://doc.traefik.io/traefik/v2.0/middlewares/basicauth/

@jhult
Copy link

jhult commented Dec 21, 2021

I'm familiar with Keycloak and could help test that.

@braginini
Copy link
Contributor

That would be of a great help @jhult . Thank you!
There are a few things to consider.

Let's have a chat? You can ping me in Slack https://join.slack.com/t/wiretrustee/shared_invite/zt-vrahf41g-ik1v7fV8du6t0RwxSrJ96A

@FlurryNight
Copy link

+1 for SuperTokens

@mlsmaycon
Copy link
Contributor

Hey @pomazanbohdan @jhult @firestrife23 @lonnietc @ZR3SYSTEMS, thanks for your feedback.

We are looking at the alternatives you provided here, and one requirement we have to move forward is that the solution supports the Dashboard which is a Single Page Application, without the need to work on having a session cache somewhere in our Management layer.

This is important as it would allow us to build a project that is scalable and stateless, needing the least amount of services to be deployed.

With that in mind, we are looking at Ory Hydra and Ory Kratos as possible options for archiving the requirements above. Any thoughts on that?

Also, as this is more of a Management layer problem, we will have tickets there as a main way of tracking, please follow the ticket netbirdio/netbird#126

@adyanth
Copy link

adyanth commented May 29, 2022

Instead of limiting options of auth providers, why not implement OAuth2/OIDC and let the user pick whatever provider they need? This would cover Keycloak, Authentik, SuperTokens, Ory Hydra, Auth0 itself and more.

Edit: Personally interested in Keycloak, which is my IdP.

@firestrife23
Copy link
Author

@adyanth I like your suggestion, and keeping it simple.

@KlavsKlavsen
Copy link

and its what Kubernetes do as well (OIDC) - so I assume there's some good GO libs that support it :)

@the-maldridge
Copy link

I have used ORY stuff in the past and found it to be a generally frustrating experience due to low quality documentation. I second the general OIDC recs and specifically Authentik has done a really good job of reducing operational complexity. While Keycloak did a lot of things that worked well in a single pane of glass way, the operational complexity with running Keycloak has eroded its position in the field IMHO.

@KlavsKlavsen
Copy link

I'd probably do it like shown here: https://stackoverflow.com/questions/48855122/keycloak-adaptor-for-golang-application - which uses generic go oidc module

@KlavsKlavsen
Copy link

and could we rename this issue to be "OIDC login provider support" ? (instead of 'Authentik' )

@braginini
Copy link
Contributor

braginini commented Jun 20, 2022

Looks good @KlavsKlavsen !
We will also need to check how we could replace the Auth0 in the frontend part.

Anyone up for a challenge? :)

@braginini braginini changed the title Support for Authentik? OIDC login provider support Jun 20, 2022
@mlsmaycon mlsmaycon added enhancement New feature or request help wanted Extra attention is needed labels Jun 20, 2022
@KlavsKlavsen
Copy link

@braginini What is the auth0 frontend part? oauth2/oidc does not have a UI part.. it redirects to the third party auth (keycloak f.ex.) for serving login UI (thats kinda the point :)

@braginini
Copy link
Contributor

braginini commented Jun 21, 2022

@braginini What is the auth0 frontend part? oauth2/oidc does not have a UI part.. it redirects to the third party auth (keycloak f.ex.) for serving login UI (thats kinda the point :)

You have to generate tokens when calling API, save them, handle refresh tokens, etc. This is all done in the frontend.

And still you need handling to show the login.

For example this is where the auth0 lib is used. No the only place, every view uses it.
https://github.com/netbirdio/dashboard/blob/main/src/App.tsx

@KlavsKlavsen
Copy link

It seems soneone wrote a keycloak specific module - making it even easier: https://github.com/Nerzal/gocloak - and a short search on github shows many using it (so its easy to see how to do it) - https://github.com/Clarilab/gocloaksession f.ex.

@adyanth
Copy link

adyanth commented Jun 21, 2022

It's always better to do OIDC than limit to any one provider. Many, many different IdPs (including cloud hosted ones) implement OIDC compared to just adding Keycloak.

@braginini
Copy link
Contributor

A quick search on GitHub also showed some react libs for the frontend part.
https://github.com/bjerkio/oidc-react

@MrRagga-
Copy link

I am also quite familiar with OIDC both on OP and RP side.

Any well written OP shall have the .well-known/openid-configuration endpoint implemented, see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig.

Using a proper module for your specific language shall enable you to read the configuration and get from there all the necessary information to proceed the OIDC flow in a generic way.

Thus your generic implementation would only need a pointer to the the the well-known configuration endpoint, a client_id and things like audience or other claims to be validated.

For public clients (which you can use for SPA only) the preferred way is to use authorization code flow + PKCE enabled on the server side.

I am not very familiar with TypeScript but I am willing to help testing, giving feedback or whatever is needed ...

@braginini
Copy link
Contributor

braginini commented Jun 28, 2022

I am also quite familiar with OIDC both on OP and RP side.

Any well written OP shall have the .well-known/openid-configuration endpoint implemented, see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig.

Using a proper module for your specific language shall enable you to read the configuration and get from there all the necessary information to proceed the OIDC flow in a generic way.

Thus your generic implementation would only need a pointer to the the the well-known configuration endpoint, a client_id and things like audience or other claims to be validated.

For public clients (which you can use for SPA only) the preferred way is to use authorization code flow + PKCE enabled on the server side.

I am not very familiar with TypeScript but I am willing to help testing, giving feedback or whatever is needed ...

@MrRagga- thank you for offering help on that. Very much appreciated!

We had a look into our backend code and it seems that there is nothing todo since the jwt token validation part is generic. Only if we would want to support multiuser setup, then we could implement the IDP manager interface -> https://github.com/netbirdio/netbird/blob/295f0c755adffc14d04252f8f169bfba070d0f57/management/server/idp/idp.go#L11. Similar to our auth0 implementation. But this could be the 2nd step.

As for the frontend part - we will engage with @dataontabs to replace auth0 lib with a generic solution.

@MrRagga-
Copy link

Oh, you have a bff, then you should offer authorization code flow with a confidential client + PKCE.

I am not so much "concerned" about the validation part of the JWT token, but more that you provide a generic implementation with a well-known configuration endpoint support, which is going to work with all existing IdP's out of the box following OIDC standards.

@braginini
Copy link
Contributor

braginini commented Jun 28, 2022

Oh, you have a bff, then you should offer authorization code flow with a confidential client + PKCE.

I am not so much "concerned" about the validation part of the JWT token, but more that you provide a generic implementation with a well-known configuration endpoint support, which is going to work with all existing IdP's out of the box following OIDC standards.

Not really bff. We just use IDP manager user endpoint to store application-specific user data and query it when needed via API. We just don't want to store email and things like that in the Management service database, we leave it for the specialized software or providers (e.g. auth0 in the case of our hosted version).
This is actually unrelated to the OIDC, I guess I confused you a bit with my previous message.
But I got your point. I'd be willing to ping you to discuss things once we started working on this.

@braginini
Copy link
Contributor

braginini commented Jul 3, 2022

Hey guys,
We came across Zitadel -> https://github.com/zitadel/zitadel
It looks like an excellent option for us, except that they don't yet support a device flow that we need for our interactive login feature when registering a device with SSO -> zitadel/oidc#141
It is OIDC compliant, so it will work once we support OIDC. Just curious about your opinions.

P.S. As I understood, we could embed Zitadel into the management service. Not sure if it is a good idea thought.

@braginini
Copy link
Contributor

Hey guys, just letting you know that we have started working on the generic OIDC support.
Most of the work has been done by @mlsmaycon and there are some bugs to fix. It is coming soon!

#60

@braginini braginini linked a pull request Jul 26, 2022 that will close this issue
@braginini
Copy link
Contributor

braginini commented Jul 26, 2022

Hey everyone!
I brought some good news :) We have just merged #60, thanks to @mlsmaycon!
We introduced a generic OIDC library within this PR and achieved compatibility with Auth0. We haven't tested any other IDP yet, but the library is OIDC compliant, so we don't expect any big issues. Go ahead if you'd like to try it with keycloak or any other solution!
Feedback is very welcome, and feel free to document the steps, we will then publish them on our docs website :)

We will be also working on documentation in the following days.

Cheers,
Misha

@braginini
Copy link
Contributor

braginini commented Aug 14, 2022

FYI:
I'm working on some generic OIDC adjustments here #66

Just tested Keycloak :)

@braginini
Copy link
Contributor

Hey everyone. The Keycloak integration guide is there, check it out!
https://netbird.io/docs/integrations/identity-providers/self-hosted/using-netbird-with-keycloak

@bohemtucsok
Copy link

Hello

I would like to ask for a little help. I followed the description of the keycloak step by step, but I encounter an error at point 9

Your authority OIDC configuration will be available under:

https:///realms/netbird/.well-known/openid-configuration

unfortunately I have 404 not found. What can I do wrong?

@braginini
Copy link
Contributor

Hi @bohemtucsok

Hello

I would like to ask for a little help. I followed the description of the keycloak step by step, but I encounter an error at point 9

Your authority OIDC configuration will be available under:

https:///realms/netbird/.well-known/openid-configuration

unfortunately I have 404 not found. What can I do wrong?

What is the name of the realm you created? netbird?
What version of Keycloak are you running?

@bohemtucsok
Copy link

yes the name netbird, and the keycloak version is 16.1.1

@braginini
Copy link
Contributor

yes the name netbird, and the keycloak version is 16.1.1

Quite an old version. You might try this URL instead:

http://keycloakhost:keycloakport/auth/realms/{realm}/.well-known/openid-configuration

Or get the info from the Admin UI (use your realm)
https://i.stack.imgur.com/VzkjW.png

@bohemtucsok
Copy link

Ooooooo I understand thx for help now working :)

@bohemtucsok
Copy link

Hi one more question :)

How can I add another user on the netbird management interface ??? is there a way to do this?

@braginini
Copy link
Contributor

braginini commented Sep 21, 2022

Hi one more question :)

How can I add another user on the netbird management interface ??? is there a way to do this?

For the self-hosted setup
https://netbird.io/docs/integrations/identity-providers/self-hosted/using-netbird-with-keycloak#step-8-ensure-that-all-users-will-join-the-same-netbird-network-optional

After finishing these steps you can create a new user in Keycloak and they will be added to your network once they log in.

@bohemtucsok
Copy link

ohhh thx you are the best :)

@mlsmaycon
Copy link
Contributor

Closing this as complete. Thanks all for the suggestions, indeed it was an improvement to the platform

@senorsmile
Copy link

The readme still mentions auth0 is required. Does that need to be updated now?

@braginini
Copy link
Contributor

The readme still mentions auth0 is required. Does that need to be updated now?

Good catch. Need to be updated. We support generic OIDC since a while already.

@djmaze
Copy link

djmaze commented Mar 8, 2023

Readme still needs an update. Took me a bit of time to find out I don't need Auth0 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.