Open Pixtriks opened 4 years ago
Encountered the same issue today.
It seems as if GitLab is not following the official OpenID connect implementation by exposing all other claims under the /oauth/userinfo
endpoint (including e-mail address). Maybe a change on the side of traefik-forward-auth could account for this?
I think it would be a better idea to allow GitLab trough oAuth2.
Hmm, that's a pain! I agree it would probably be easier to just add a customer gitlab provider as opposed to an extra workaround in the OIDC code.
Unfortunately, the same applies to GitHub.
There's an example of how OpenID Connect can still be used with GitHub, by providing the required endpoints manually: https://fusionauth.io/docs/v1/tech/identity-providers/openid-connect/github
Is this issue accepting PRs?
This is a relatively simple bug. GitLab provides a UserInfo endpoint (example from gitlab.com). According to the OIDC specs, when requesting claims using scopes,
The Claims requested by the
profile
,address
, andphone
scope values are returned from the UserInfo Endpoint [...]
Traefik Forward Auth does not currently query the UserInfo endpoint but expects the claims as part of the id_token
:
GitLab will soon add the email
claim to the ID token, which will make this obsolete for GitLab.
This should now be doable using the generic oauth provider, I'll test with gitlab this week, add some docs and update this issue
I have the same issue with GitHub also my X-Forwarded-User is empty.
Ahh sorry just read:
Note: as per Github's documentation, their /user endpoint only returns the user's email if it's publicly visible. As such, you will not be able to use the User Restriction features with the Github provider, unless all your users have their email addresses public.
@thomseddon Is it not possible to introduce another whitelist for github to check the login (username) or name instead of the email?
GitLab works fine for me with OIDC including email whitelist.
As mentioned before, email claim was added some while ago.
This is the working base config:
env:
DEFAULT_PROVIDER="oidc"
PROVIDERS_OIDC_ISSUER_URL="https://gitlab.com"
SECRET="${cookie_secret}"
WHITELIST=<redacted>@users.noreply.gitlab.com
service stanza for the traefik-forward-auth task (I'm on Nomad)
{
[...]
namespace: traefik
[...]
service {
name = "traefik-forward-auth"
provider = "nomad"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.middlewares.traefik-auth.forwardauth.address=https://auth.example.com",
"traefik.http.middlewares.traefik-auth.forwardauth.authResponseHeaders=X-Forwarded-User",
"traefik.http.routers.traefik-auth.entrypoints=websecure",
"traefik.http.routers.traefik-auth.rule=Host(`auth.example.com`)",
"traefik.http.routers.traefik-auth.tls=true",
"traefik.http.routers.traefik-auth.tls.certresolver=letsencrypt"
]}
}
demo task service stanza:
service {
name = "demo-webapp"
provider = "nomad"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.routers.demoapp-secure.rule=Host(`demoapp.example.com`)",
"traefik.http.routers.demoapp-secure.entrypoints=websecure",
"traefik.http.routers.demoapp-secure.tls=true",
"traefik.http.routers.demoapp-secure.tls.certresolver=letsencrypt",
"traefik.http.routers.demoapp-secure.middlewares=traefik-auth@nomad-traefik"
]}
the demoapp.example and auth.example.com (example.com is of course replaced my own domain) dns records are both public.
In GitLab I have created an app with the following scopes, it's more than needed here I think because I use it also for other apps: api,read_user,openid,profile,email
The redirect uri is this: https://demoapp.example.com/_oauth
Maybe it's a help for someone in the future
I am experiencing this issue (#60) as well. I am running in overlay mode and have one whitelisted e-mail address. Identity provider is GitLab. The e-mail field is empty causing a "Not Authorized" error.
Log file:
This is my docker-compose:
These are my GitLab settings:
I should also note that my profile and e-mail address are all set to public on GitLab. GitLab documentation states the following with regards to OpenID Connect:
Source: https://docs.gitlab.com/ee/integration/openid_connect_provider.html