-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Not Authorized error #31
Comments
I Received that too and i seems to be some cookie/cache related issue. Either wait a couple of hours or try a different browser/ Incognito |
OMG,so in all my testing I had forgot to try Incognito mode... I had tried both Chrome and Edge... But that was prob whilst the config was not right... so retested with Incognito mode and hey presto its working... Thanks this can be closed 👍 |
I don't think this should be closed. I run into this problem frequently. It may be because we need a traefik header |
Related #20 |
Hmm, I have a similar issue where I've clicked the wrong google account, my only option is to clear cookies and try again - sounds like this could be the same root cause - I wonder if there is a better UX for this? |
It does happen if you do choose the wrong account or it happens once the authorization expires with the right account. I believe it may be due to a missing header on traefik and/or its like it can't refresh the token on it's own. |
@robertbaker what do you mean it's missing a header? |
In the #20 I believe it's mentioned. The Forwarded URI or auth trust
heaters.
Although I think it's more likely a bug where its not refreshing the
expired token
…On Tue, Mar 19, 2019, 9:07 AM Thom Seddon ***@***.***> wrote:
@robertbaker <https://github.com/robertbaker> what do you mean it's
missing a header?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3YJQccmkPKzNmrrTAL6W3Ncj8AumK7ks5vYQtcgaJpZM4bWnaR>
.
|
I experience the same issue intermittently in auth host mode, via both desktop and mobile browsers.
As @robertbaker stated, this seems to happen most frequently when re-selecting an account which has been authorized (in my case, via WHITELIST) after the session lifetime has expired. Perhaps a token refresh issue? |
I can confirm I have the same error even after deleting my cookies... |
I don’t suppose a “logout” endpoint is in the works? |
FWIW I've been struggling with this issue for months with no good workaround except to logout of all google accounts, delete all google related cookies and cache, and close and re-open the browser. It happens every month or so and it's incredibly annoying. The incognito mode fix does work for me though so I think it's safe to say it's something to do with caching and tokens. When I get the "not authorized" message I also get the CSRF error log mentioned by @726a67. I hope we come up with a fix for this soon. |
@zetas simply completely closing chrome (including tray icon) should be the only thing you need to do to fix it. |
Getting the same error intermittently, completely closing chrome didnt fix it |
The weird thing is that it lets me access some of my endpoints but not others when this happens. E.g. some work fine some give the "not authorized" text |
So I think I might have found the cause of this, after a cookie expires the existing behavior was just to throw an error. I have just pushed a change which means that the users will be redirected to Google login instead. If someone would be willing to test the |
Just tried it, still getting the error. My log level is set to debug, let me know what to look for |
Can you double check you're running the image with the tag: 3e6ccc8 Do you get any logs with the 401? For extra info, 401 can returned from 4 places:
There's a log message in each location, so if tfa is returning an error then it should be showing more info in the logs |
I wasn't able to come up with a good way to check this. The only docker tag on that is latest and there apparently isn't a shell in the container I could use to check the source. I restarted a couple of times, so it should have pulled the image.
I have
I was grepping on "401" before, I didn't realize the logs dont actually include the http status code. |
One thing that seems to work consistently is getting to the "not authorized" page, then visiting a different endpoint that for whatever reason works, then going back to my original endpoint lets me continue to the page I wanted. |
I've done a thing in branch I have written tests, which pass, but I want to do some functional testing before I actually submit a PR. However, I flubbed an unrelated IP on my home setup, and so can't actually access my own environment to deploy the updated version, so I'll do it tomorrow. Thanks, sslh. I have built the image manually on https://hub.docker.com/r/tnwhitwell/traefik-forward-auth/tags, tag: testing, but obviously I'd recommend building and deploying your own version if you do want to test. |
I actually added a logout endpoint to my landing page which does the same thing, I've also been manually deleting the cookie and disabling caching before running these tests so I don't know if that will solve the problem |
Could you do a docker inspect on the container, mine is showing: I actually think my changes in 3e6ccc8 are a red herring (which I will partially revert), the browser will expire the cookie after that time so it is actually an error if such a cookie is received.
|
I'll double check the image hash
Indeed it's directly after I log into google that I get this screen, which is part of why it makes no sense since I've just logged in. Do you rely on the X-Forwarded-User header to check the username at the callback endpoint? I don't think I configured traefik to send it for that endpoint |
Interesting, could you check what cookies are sent before you're redirected to Google (you can inspect the headers on the 307 redirect in your browser)? Are you using the auth host? |
Sorry for the late reply, I'm in the process of rebuilding that cluster right now, when it's settled down I'll look into the cookies for you |
In the request to my endpoint, I see
The 307 response has
|
Hmm, so that's why it doesn't work - but why doesn't the cookie match? My first thought would be a domain missmatch? |
I am experiencing exactly same issue as Queuecumber. "Not authorized" after google authentication. Docker Image: Command is: services I am authenticating are path based |
Same issue here, After google login I get "Not authorized".. No clue yet why |
@frankforpresident (or anyone else in the thread) could you post:
I'm sure we can get to the bottom of this :) |
I can confirm I'm seeing the same behavior here. Initiating an incognito browser allows me to access the service properly though. |
@thomseddon, I did my best to gather some information for you. My setup was based on: https://www.smarthomebeginner.com/google-oauth-with-traefik-docker/ Description: Expected: Proper redirection after the authentication. Content is visible. Actual: After login the webpage redirects and returns with 401 Not authorized. Note: I did changed some personal data and revoked the 0auth cert just after this run. Logs:
docker-compose.yaml
oauth.env
Note: I also tried INSECURE_COOKIE=false, changing _forward_auth_csrf to a different key and a different email address How do you want me to collect the request logs? or is this enough to get started? I did saw this message in the console after landing on the 401 page.
and I can't seem to find the_forward_auth_csrf cookie after the redirect under Application>Storage>Cookies. Not sure if this is the cause of my problem. |
@thomseddon, (or anyone else) Any update on this issue? Is there something I could help you with? If more logs are required don't hesitate to contact me. I would love to implement this in my setup. |
Sorry I missed your previous comment, thanks for the detailed info. Could you post your entire compose config (including traefik) - the absolute jackpot would be if you can give me a docker-compose.yaml + associated config so I can exactly replicate it? With regards to capturing the requests, if you export them from the chrome network tab, that would be great (although if I can replicate that won't be needed) |
I am having the same issue here. I guess my config are more naive. Error: Traefik (installed with helm - stable/traefik):
traefik-forward-auth (reference to Example for k8s):
|
I found out the clear the browser data can solve this problem. |
Hey Frank, I also used the SmartHomeBeginner sample. I was also getting 'unauthorized' because the Google email address I was logging in with, was not in the WHITELIST environment variable passed to the forward-auth! Adding this fixed it.. Clear cookies to ensure it's re-authenticating. This error clue is also apparent from the service log for the container which will say invalid email. Hope that helps someone! |
I will try it again tonight but if i remember correctly it was already set to the correct email address. |
My email address is ok and I don't see this message in the logs. I have a question, could it be related to my ip range? I've noticed in the logs a 192.168.0.1 ip address but that would be the range of my modem while my internal ip range of my router is 10.0.0.X Anyway. on every attempt I see the same result. missing cookie, setting cookie, done time="2020-04-09T10:53:09Z" level=warning msg="Missing csrf cookie" source_ip=192.168.0.1 |
Ahh, OK.. that should be an easy fix.. Did you generate and pass a cookie? |
Yes, generated with: openssl rand -hex 16 You can check my config here, it didn't changed that much. |
OK, comparing yours to mine, I have 2 differences:
And I do not have the "CSRF_COOKIE_NAME=_forward_auth_csrf" So that could be why you are getting your error. Note also that SmartHomeBeginner has drastically changed his sample code in the past week.. |
I got the same errors and was able to reproduce it as follows:
Closing Tab A, so that it would not make requests and issue new |
@bekoeppel I have created an issue to track that specific pattern as I think there could be a better way of handling it. I believe a lot of people here will have run into #103 whereby Google will not offer up the account selection by default on subsequent requests, so if you select the wrong account you have to wait for that selection to expire on Google's side before having another go (which is why some people have said you just need to wait and clearing cookies is not enough). Beyond the two instances above, I think the most common cause will be a misconfiguration. I have opened #114 to improve debug logging to help track these down @frankforpresident I will confirm when #114 is merged, if you could send your debug logs again following that, it would be greatly appreciated. |
@thomseddon, Will do |
Just want to share my Experience on debugging my issue. My architecture is like this: Route53 -> CloudFront -> EKS -> traefik -> traefik-forward-auth -> The application The biggest challenge to me is the Cloudfront since i am not familiar with it. Here are the errors I experienced First Error - Missing csrf cookieThe reason is that I didn't allow the Cloudfront to Second Error - Error validating csrf cookie: Invalid CSRF state valueThe reason of getting this is because the Third Error - Invalid emailIt seems like the config in the kubeconfig.yaml is incorrect. I am still investigating it. |
Hello everyone - the good news is that v2.2 was released yesterday, this includes a significant improvement in logging as well as a warning about some invalid configuration states. This also includes a tweak to the Google provider to ensure the user is always prompted to select which account they would like to use, this fixes the issue where a user selects the wrong account and is then unable to reselect the right account as their previous selection is "cached" (which may result in a Not Authorized error). I've also released a large amount of new examples for both k8s and swarm, using both traefik v1.7 and 2+ - this shows the advised way to deploy the service and should help many people ending up in a bad/conflicting configuration state. As mentioned before, I think this issue may represent a number of different issues that people have had, most of which I believe will have been caused by me not providing enough configuration examples - which I hope is now fixed. Due to this, and the other fixes outlined above, I'm going to close this issue. If anyone is still having a problem when using v2.2, following the new examples, please please please open a new issue with your configuration and logs and I will dig into it right away. Thank you everyone for your contributions to this, it's very much appreciated. |
Hello all, for reference to other users: I too was experiencing the error:
with the in the documentation recommended docker The error happened after the initial cookie expired (which was 30 days after initial authentication). I could work around the issue by using a private browser session. After updating to the Best regards, |
I can confirm that although a similar issue (intermittently) persisted on tags |
I find myself revisiting this thread again but this time, my issue was I didn't have the user in the WHITELIST - added that and voila! If that helps anyone.. |
What would we, the ones running on |
@GuyKh you can use the 2.2.1 multi-arch image here https://github.com/Beanow/traefik-forward-auth/pkgs/container/traefik-forward-auth. Works like a charm. |
Nope... still getting
|
Hi,
I've just setup traefik-forward-auth docker container for the first time, and after some playing in both overlay and auth-host modes I get the same "Not Authroized" error displayed.
I ran the container up with debug mode and am getting the following error:
Error validating csrf cookie: CSRF cookie does not match state
This is my config (with secrets removed of course):
traefik-forward-auth container:
Traefik-Forward-Auth:
container_name: Traefik-Forward-Auth
hostname: Traefik-Forward-Auth
image: thomseddon/traefik-forward-auth
networks:
IoT:
ipv4_address: 10.1.11.253
environment:
- CLIENT_ID=
- CLIENT_SECRET=
- SECRET=
- COOKIE_DOMAINS=
- COOKIE_SECURE=true
- AUTH_HOST=auth.
- WHITELIST=@
- LOG_LEVEL=debug
- LOG_FORMAT=json
# When using an auth host, adding it here prompts traefik to generate certs
labels:
# Traefik - General
- "traefik.enable=true"
- "traefik.default.port=4181"
- "traefik.frontend.rule=Host:auth."
# Traefik - SSL
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.STSSeconds=315360000"
- "traefik.frontend.headers.browserXSSFilter=true"
- "traefik.frontend.headers.contentTypeNosniff=true"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.frontend.headers.SSLHost="
- "traefik.frontend.headers.STSIncludeSubdomains=true"
- "traefik.frontend.headers.STSPreload=true"
- "traefik.frontend.headers.frameDeny=true"
# Traefik - Whitelisting
- "traefik.frontend.auth.forward.address=http://10.1.11.253:4181"
- traefik.frontend.auth.forward.authResponseHeaders = ["X-Forwarded-User"]
whoami container which I'm trying to forward auth as a test:
Whoami:
container_name: Whoami
hostname: whoami
image: containous/whoami
networks:
IoT:
ipv4_address: 10.1.11.251
labels:
# Traefik - General
- "traefik.enable=true"
- "traefik.frontend.entryPoints=http,https"
- "traefik.default.protocol=http"
- "traefik.default.port=80"
- "traefik.frontend.rule=Host:whoami."
# Traefik - SSL
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.STSSeconds=315360000"
- "traefik.frontend.headers.browserXSSFilter=true"
- "traefik.frontend.headers.contentTypeNosniff=true"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.frontend.headers.SSLHost="
- "traefik.frontend.headers.STSIncludeSubdomains=true"
- "traefik.frontend.headers.STSPreload=true"
- "traefik.frontend.headers.frameDeny=true"
# Traefik - Whitelisting
- "traefik.frontend.auth.forward.address=http://10.1.11.253:4181"
- traefik.frontend.auth.forward.authResponseHeaders = ["X-Forwarded-User"]
As I am using labels for everything instead of making changes to the treafik.toml file I added the auth.forward.address and auth.forward.authResponseHeaders to the treafik-forward-auth container as I saw something around this in another post when using auth-host mode. Which solved my endless login loop when it wasnt in there.
I have gone through as setup the Google side as per the instructions, and added https://auth./_oauth and https://whoami./_oauth (for when I was testing in overlay mode.
Any ideas, I have tried multiple options around the DOMAIN and WHITELIST options, and multiple google accounts. And all give me the same problem. The error probably suggests its not something with the accounts Im using somwhere else Im guessing?
Thanks in advance.
O
Originally posted by @owendemooy in #20 (comment)
The text was updated successfully, but these errors were encountered: