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

Explore self-hosted OAuth provider #36

Closed
billimek opened this issue May 26, 2019 · 22 comments
Closed

Explore self-hosted OAuth provider #36

billimek opened this issue May 26, 2019 · 22 comments
Labels
exploration Something to explore

Comments

@billimek
Copy link
Owner

billimek commented May 26, 2019

The Auth0 implementation is cloud-based and I want to see something self-hosted that will work better in 'offline' scenarios.

@billimek billimek added the exploration Something to explore label May 26, 2019
@echel0n
Copy link

echel0n commented May 26, 2019

KeyCloak has offline tokens and can be self-hosted.

@billimek
Copy link
Owner Author

Thanks @echel0n! Will take a look at the helm chart.

@billimek
Copy link
Owner Author

@billimek
Copy link
Owner Author

@echel0n
Copy link

echel0n commented Aug 19, 2019

Keycloak is scalable as well but takes a bit to get that setup, never tried Authelia but looks interesting, I just know when it comes to open source IDPs Keycloak seems to always come up and its easier to find info with integration.

@echel0n
Copy link

echel0n commented Aug 19, 2019

Another option would be auth0.com, they offer 100% free wide-open service for open source projects as well, it would be hosted by them but in the case of auth that might not be a bad thing if you want to avoid downtime due to an outage depending on how you hook into the IDP.

@blackjid
Copy link

Would ouath2_proxy be an alternative to cover this need?? https://github.com/pusher/oauth2_proxy

@echel0n
Copy link

echel0n commented Aug 20, 2019

Keycloak also allows using 3rd party IDPs to auth against such as google and AWS, its really a matter of do you want to be you're own IDP or do you want to just proxy the requests.

@billimek
Copy link
Owner Author

billimek commented Oct 2, 2019

If sticking with cloud-based (Auth0), now that nginx is being used, will likely deploy something like:

nginx.ingress.kubernetes.io/auth-url: "https://example.com/oauth2/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://example.com/oauth2/start?rd=/redirect/$http_host$request_uri"

@billimek
Copy link
Owner Author

Deployed oauth2-proxy configured to use auth0: https://github.com/billimek/k8s-gitops/tree/master/kube-system/oauth2-proxy

@carpenike
Copy link

I’m in the process of moving to KeyCloak with a sidecar injector for KeyCloak-Gateway (Stakater). So far it’s looking promising. Allows for 100% on prem federated logins.

Only negative I’ve found thus far is that the sidecar injector requires Deployment annotations. Most of the available helm charts don’t allow for specifying deployment annotations OOB.

@billimek
Copy link
Owner Author

billimek commented Feb 2, 2020

Interesting, you need to run keycloak sidecards on all of the target workloads doing auth? I was hoping it could be used as a 'central' replacement for something like auth0.

@carpenike
Copy link

Keycloak would be run as the central Auth0 replacement. Sidecars are functionally replacing them NGINX annotations that forward the client to oauth proxy for Auth. Also allows for a bit more granularity in rules. For instance, on Sonarr/Radar I can have the /api path allowed without Auth because it’s protected by API keys but require everything else be authd first.

Sidecars are also workload configurable. For services like Grafana which can directly federate with oauth providers I don’t deploy a sidecar.

@billimek
Copy link
Owner Author

@blackjid
Copy link

blackjid commented Jan 16, 2021 via email

@echel0n
Copy link

echel0n commented Jan 16, 2021

I would suggest using bitnami's gatekeeper helm chart instead, more up to date I found, even their helm chart is decent for keycloak as well.

I've also got keycloak + kube apiserver dialed in so I can use it to protect the kubernetes dashboard ;)

As far as how I use gatekeeper, I just have it handle the ingress and then pass to the protected app's service, so just an extra yaml, but works.

@carpenike
Copy link

I would suggest using bitnami's gatekeeper helm chart instead, more up to date I found, even their helm chart is decent for keycloak as well.

I've also got keycloak + kube apiserver dialed in so I can use it to protect the kubernetes dashboard ;)

As far as how I use gatekeeper, I just have it handle the ingress and then pass to the protected app's service, so just an extra yaml, but works.

@echel0n -- any chance your config is public?

@echel0n
Copy link

echel0n commented Jan 16, 2021

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gatekeeper
  namespace: transmission
  labels:
    app: gatekeeper
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gatekeeper
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: gatekeeper
    spec:
      containers:
        - name: gatekeeper
          image: bitnami/keycloak-gatekeeper:10.0.0
          envFrom:
          - secretRef:
              name: transmission-gatekeeper-env           
          ports:
            - containerPort: 3000
          args:
            - /keycloak-gatekeeper
            - --discovery-url=https://auth.something.ca/auth/realms/something
            - --upstream-url=http://transmission.transmission:9091
            - --listen=0.0.0.0:3000
            - --client-id=$(CLIENT_ID)
            - --client-secret=$(CLIENT_SECRET)
            - --enable-refresh-tokens=true
            - --enable-session-cookies=true
            - --secure-cookie=true
            - --encryption-key=$(ENCRYPTION_KEY)
            - --enable-default-deny=true
            - --verbose
            - --enable-logging
            - --resources=uri=/*
            - --oauth-uri=/transmission/oauth            
---
kind: Service
apiVersion: v1
metadata:
  name: gatekeeper
  namespace: transmission
  labels:
    app: gatekeeper
spec:
  ports:
  - port: 3000
    targetPort: 3000
  selector:
    app: gatekeeper
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: gatekeeper
  namespace: transmission
  labels:
    app: gatekeeper
  annotations:
    kubernetes.io/ingress.class: nginx   
spec:
  tls:
  - hosts:
    - something.ca
    secretName: something-ca-tls
  - hosts:
    - something.lan
    secretName: something-lan-tls    
  rules:
  - host: something.ca
    http:
      paths:
      - path: /transmission
        pathType: Prefix
        backend:
          service:
            name: gatekeeper
            port:
              number: 3000 

@runningman84
Copy link

This also looks good
https://www.authelia.com/

@billimek
Copy link
Owner Author

billimek commented Apr 9, 2021

See also https://github.com/ory/kratos

@hsluoyz
Copy link

hsluoyz commented Aug 14, 2021

Hi @billimek I am from Casbin team and we have a central authentication project called Casdoor: https://casdoor.org/ . Casdoor is itself an OAuth provider, also as well as an integrator of other OAuth providers like GitHub, Google, etc. It also supports SMS, Email logins. It contains a full-fledged web UI but it can also run in "headless" mode. It's developed in Go. And it integrates well with Casbin. You can build it from source (just type in go run main.go) or use our Docker image: https://hub.docker.com/r/casbin/casdoor . You can see the live demo here: https://door.casbin.com/ . Let me know if you have any questions :)

image

@billimek
Copy link
Owner Author

billimek commented May 2, 2024

This is no longer needed - I moved nearly all ingress objects behind tailscale and rely on membership in the tailnet instead of an IDP via an oauth2 proxy service. The remaining truly external ingresses wouldn't work with an authentication proxy anyway.

@billimek billimek closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exploration Something to explore
Projects
None yet
Development

No branches or pull requests

6 participants