zipline icon indicating copy to clipboard operation
zipline copied to clipboard

adding authentik oauth implementation

Open danejur opened this issue 1 year ago • 25 comments

Adding an OAuth authentication mechanism using Authentik as the provider. There are 5 required environment variables for this to work:

OAUTH_AUTHENTIK_CLIENT_ID OAUTH_AUTHENTIK_CLIENT_SECRET OAUTH_AUTHENTIK_AUTHORIZE_URL OAUTH_AUTHENTIK_USERINFO_URL OAUTH_AUTHENTIK_TOKEN_URL

Additionally, some setup is required in Authentik, which probably merits an entry to the documentation. I modeled all of this after the other OAuth implementations, so if something's amiss, let me know. Also, I went ahead and used a generic key icon as Tabler didn't have anything that looked even close to Authentik's iconography (from what I could tell).

I've tested it locally and can safely say that it Works on My Machine™, but I've yet to dockerize it and try it out remotely.

This PR satisfies one of the suggested additions of #321.

danejur avatar Apr 13 '23 17:04 danejur

Built with docker(ghcr.io/0xemma/zipline:trunk), and setup with KeyCloak OAuth, only minor "bug" i notice, is that the redirect url is http, rather then the HTTPS im accessing the site via, but this might be due to my HTTPs being handled by my ingress.

0xEmma avatar Apr 19 '23 16:04 0xEmma

@0xEmma I encountered something similar (I'm also terminating TLS at my reverse proxy), but I believe this is solved with an environment variable (see #304). Good to know that this works with other providers! Should we make this one a little more generic to handle other cases, or would it be better to add provider-specific implementations? If we make this one more generic, we could add an additional variable for provider_name.

danejur avatar Apr 20 '23 13:04 danejur

I think making it generic would be a good addition with the provider_name, as well as perhaps configuring the endpoints from the .openid-configuration, which returns the JSON data for the token/userinfo/authorize URL's (https://swagger.io/docs/specification/authentication/openid-connect-discovery/)

I'll see if i can add any of that to the implementation

0xEmma avatar Apr 20 '23 13:04 0xEmma

Any updates on this? Would love to see an Authentik implementation! 😄

JustJoostNL avatar May 10 '23 08:05 JustJoostNL

Any updates on this? Would love to see an Authentik implementation! 😄

Have not had enough time lately to get everything setup and working. I think I'll see if i can do it by next week.

diced avatar May 10 '23 14:05 diced

I think this looks good, though I have not tested it with authentik yet.

@danejur Before this gets merged would you be able to make documentation on https://github.com/diced/zipline-docs?

diced avatar May 11 '23 04:05 diced

The buttons on the oauth selection should probably be changed in to a grid of 2x2 if all 4 are used (even if this use case is rare) image

Other than that, looks good to merge.

diced avatar May 13 '23 06:05 diced

Not OP but made a PR for documentation https://github.com/diced/zipline-docs/pull/55

0xEmma avatar May 21 '23 00:05 0xEmma

@diced Will this be merged?

xbdmHQ avatar Jun 18 '23 18:06 xbdmHQ

We are still waiting for some changes from the author, until then it won't be merged.

diced avatar Jun 18 '23 18:06 diced

Hey all, just to give an update: I've been pretty slammed with a new job and real-world stuff, but fully intend to make the updates necessary here. That being said, if someone wants to take over making the required changes (I know there aren't many), I'd be happy to accept a PR into my repo to add to this PR.

danejur avatar Jun 20 '23 18:06 danejur

No problem, I am thinking of adding authentic support into V4. Since V3 will no longer receive feature updates, I'm wondering how to credit you.. Idk we'll cross that bridge when we come to it 😅, I'd likely ask you to make a small PR or something, if you don't want to do that I can just add some comments within parts you added.

diced avatar Jul 02 '23 02:07 diced

https://github.com/diced/zipline/commit/8b74b0b19592eaf9dd30dab3aa96d498c9310fb4 in v4 now supports authentik, im gonna keep this PR open until v4 is released though.

diced avatar Jul 21 '23 18:07 diced

I'm no expert on the matter of OIDC but this does just look like a reguler OIDC authentication method. Maybe it would be great to rebrand this as a general oidc authentication method and add a "label" to be displayed instead of Authentik. I would like to check this against an identity provider that is not Authentik though

CronixZero avatar Aug 13 '23 00:08 CronixZero

As expected, this does work with other OIDC Identity Providers. @diced I think it would be great if v4 included this as a general OIDC implementation with the option of renaming what is beeing shown (Currently Authentik). Also, at the moment this implementation will only use the preferred_username as the key for the username. What if we made the scopes and the json key for the username customizable? That way it would be possible to have support for more Identity Providers that have different scopes. For example, the Identity Provider, I tested this with, supplies a really long name under preferred_username. By making the key customizable, it would be possible to change it to the much simpler key "name" that is just my (or the user's) name

CronixZero avatar Aug 13 '23 02:08 CronixZero

@CronixZero I unfortunately have no idea how authentik or oidc works, so i'm going off a guess here lol- i'm guessing that you changed the variables to a different service other than authentik that seems to implement the same stuff authentik does, therefore working with zipline's integration? i'd also be pretty open to changing how it is implemented to better work with other stuff after clearing this up.

diced avatar Aug 13 '23 04:08 diced

@diced Exactly, I changed Authorize, Info and TokenURL. Those are standardized by OIDC. The only thing that could change between Identity Providers are the scopes (essentialy just the information that is requested in groups)

The Authentik Authorization Flow here is essentialy just an OIDC Authorization Flow

CronixZero avatar Aug 13 '23 04:08 CronixZero

OIDC is just the OpenID Connect standardization. Most IdentityProviders support it

CronixZero avatar Aug 13 '23 04:08 CronixZero

TODO:

  • [ ] Rebase/merge from upstream
  • [x] Rename to OIDC
    • [x] Update docs accordingly: https://github.com/diced/zipline-docs/pull/55

TheDevMinerTV avatar Aug 31 '23 00:08 TheDevMinerTV

Hey @danejur & @0xEmma!

Please have a look at the PRs in your respective repositories. I've taken some time to rename this into the proper authentication flow (OIDC).

When those PRs are merged, please update your PRs (#372 & https://github.com/diced/zipline-docs/pull/55) from upstream.

TheDevMinerTV avatar Aug 31 '23 21:08 TheDevMinerTV

Hey @danejur & @0xEmma!

Please have a look at the PRs in your respective repositories. I've taken some time to rename this into the proper authentication flow (OIDC).

When those PRs are merged, please update your PRs (#372 & https://github.com/diced/zipline-docs/pull/55) from upstream.

Hey! Thanks for taking the time in doing this, but I'm pretty sure you are not aware of the current circumstances. This PR won't be merged, as I have implemented this within v4 (see branch) so any changes can be done through a PR to the v4 branch. This pr is only open to serve as a discussion for Authentic/oidc support in v4 as of a month ago when it was implemented.

diced avatar Aug 31 '23 22:08 diced

This pr is only open to serve as a discussion for Authentic/oidc support in v4 as of a month ago when it was implemented.

Would you mind cherry picking my commits from their forks, or should I make new PRs?

TheDevMinerTV avatar Sep 01 '23 08:09 TheDevMinerTV

kind soul's pr https://github.com/diced/zipline/pull/466

diced avatar Sep 30 '23 02:09 diced

Do I have to be running trunk for Authentik support for the moment?

samip5 avatar Jan 08 '24 16:01 samip5

Do you have a plan, when this v4 version including these changes (or your own implementation) will be merged? @diced

TheCataliasTNT2k avatar Jun 28 '24 21:06 TheCataliasTNT2k