Skip to content

OIDC with Cloudflare proxied domains #76

@reddwarf666

Description

@reddwarf666

Hi There!

We had some conversation 1 month ago and I chose to stay with NPM. #66
I had Pocket-ID working finally but I was not completely happy with it as I find having only passkey a bit limiting and I had to create a setup where every container I wanted to protect with Pocket-ID needed a separate instance of OAuth2-Proxy. Not a solid setup I think.
Started to look at Keycloak to replace Pocket-ID and my issues in this regard with NPM were bad. So bad that I thought to abandon NPM.
Thought about Godoxy again and wanted to give it a second chance!

Did all you said I had to do and I have Godoxy running. Easy, simple and I like it! Thanks for the push at the time, it made the transition easier.

Before I continue with the issue I have with using Keycloak as OIDC provider, I collected some thoughts and things I encounter.
I don't want to overload this thread with several things and wondered if you want me to create separate issues or dump them in this thread?

Now the Keycloak issue I face. I have it running and I "think" I have it setup OK.

But once I try to make Keycloak the OIDC provider for Godoxy, I face some problem. The log of Godoxy does not tell me enough to hunt and fix this alone so I need your help with this.

Error in Godoxy log

03-19 19:07 FTL failed to initialize authentication error="failed to initialize OIDC provider: 404 Not Found: {\"error\":\"Unable to find matching target resource method\"}"
Container stopped

Note: I could not find any errors in the entrypoint.log. I cleared it and started Godoxy to make sure I did not miss anything but it remains empty after starting Godoxy. I guess this issue is so soon that logs are not written to.

Here is some information you might need. I redacted where needed for privacy reasons.

Config for route to Keycloak (file called keycloak.yml stored in /config):

auth:
  scheme: http
  port: 8080
  middlewares:
    set_x_forwarded:
  homepage:
    show: true
    name: Keycloak
    category: oidc
    description: User federation, strong authentication, user management,
      fine-grained authorization .
  host: 192.168.2.192
  load_balance:
    link: ""
    mode: ""
  no_tls_verify: true
  healthcheck:
    disable: true

(Note: host IP address here is the internal docker host IP address)

Config in .env for OIDC:

GODOXY_OIDC_ISSUER_URL=https://auth.example.com
GODOXY_OIDC_CLIENT_ID=godoxy
GODOXY_OIDC_CLIENT_SECRET=NotTheRealSecretOfCourse
GODOXY_OIDC_REDIRECT_URL=https://example.com/api/auth/callback
GODOXY_OIDC_SCOPES=openid, profile, email
GODOXY_OIDC_ALLOWED_USERS=steven
GODOXY_OIDC_ALLOWED_GROUPS=godoxy_allusers

Config relevant I think from Keycloak compose file:
KC_HOSTNAME: auth.example.com
KC_PROXY_HEADERS: xforwarded

Perhaps related, not quite sure:
keycloak/keycloak#31168 (comment)

And I wanted to mention this as it might be relevant.
When I started Keycloak for my Godoxy setup I could hardly logon to Keycloak
https://auth.example.com/admin/master/console/
9 out of 10 times that failed with some weird non-descript error in the browser:

somethingWentWrong
somethingWentWrongDescription

(I'm not making this up 😀!)

I read the Keycloak docs and found this:
Using a reverse proxy
https://www.keycloak.org/server/hostname

When a proxy is forwarding http or reencrypted TLS requests, the proxy-headers option should be set. Depending on the hostname settings, some or all of the URL, may be dynamically determined.
	If either forwarded or xforwarded is selected, make sure your reverse proxy properly sets and overwrites the Forwarded or X-Forwarded-* headers respectively. To set these headers, consult the documentation for your reverse proxy. Misconfiguration will leave Keycloak exposed to security vulnerabilities. 

Hence I set this on my route for “auth”:

middlewares:
    set_x_forwarded:

This worked really well...until I faced that OIDC issue and then this came back, I can hardly logon to Keycloak again, same weird message.

Any ideas what could be wrong or what to do here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions