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

Safari keeps prompting for basic authentication (apache / nginx) #2

Closed
jpmens opened this issue Feb 3, 2024 · 11 comments
Closed

Safari keeps prompting for basic authentication (apache / nginx) #2

jpmens opened this issue Feb 3, 2024 · 11 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@jpmens
Copy link
Member

jpmens commented Feb 3, 2024

Cannot reproduce on either Firefox or Chrome (on Mac). Safari periodically asks for basic auth credentials in spite of saving them.

@jpmens jpmens added the bug Something isn't working label Feb 3, 2024
@jpmens
Copy link
Member Author

jpmens commented Feb 3, 2024

Occurs on iPadOS as well.

@jpmens
Copy link
Member Author

jpmens commented Feb 3, 2024

<ip-address> - jip [03/Feb/2024:18:32:25 +0000] "GET /owntracks/ws/last HTTP/1.1" 101 130363 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15"

<ip-address> - - [03/Feb/2024:18:33:35 +0000] "GET /owntracks/ws/last HTTP/1.1" 401 4970 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15"

From one second to the next.

@jpmens
Copy link
Member Author

jpmens commented Feb 3, 2024

Possibly solved with a Satisfy in spite of it not making much sense to me.

                AuthType Basic
                AuthName "My OwnTracks"
                AuthBasicProvider file
                AuthUserFile "/usr/local/owntracks/userdata/htpasswd"
                Require valid-user
                Satisfy any

jpmens added a commit that referenced this issue Feb 3, 2024
@jpmens
Copy link
Member Author

jpmens commented Feb 4, 2024

Solved.

@jpmens jpmens closed this as completed Feb 4, 2024
@jpmens
Copy link
Member Author

jpmens commented Feb 4, 2024

That wasn't the solution; I didn't notice that authentication didn't work at all. Back to square 1.

@jpmens jpmens reopened this Feb 4, 2024
@jpmens
Copy link
Member Author

jpmens commented Feb 6, 2024

I could really use some help here. This is the config. Firefox and Chrome (on Macos) behave the way I think they should. Safari (on Macos, iPadOS, and iOS) prompt for re-authentication after a minute or two, in spite of checking the "Save Password" box.

I think it has something to do with the websocket connection from frontend/ and from last/.

It shouldn't be a TLS issue; disabling, i.e. configuring for port 80, doesn't solve the issue. It's proxy related.

@jpmens jpmens added the help wanted Extra attention is needed label Feb 6, 2024
@jpmens
Copy link
Member Author

jpmens commented Feb 7, 2024

mastodon-social-jpmens-111889944750942696

(screenshot as my toots are autodeleted.)

@jpmens
Copy link
Member Author

jpmens commented Feb 7, 2024

@jpmens
Copy link
Member Author

jpmens commented Feb 7, 2024

Dirk says:

this configuration works for the websockets in confluence: Edit: yes, also with Safari, but it doesn’t use BasicAuth. So it may help or not.

        <Location /synchrony>
              Require all granted
              RewriteEngine on
              RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
              RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
              RewriteRule .* ws://localhost:1111%{REQUEST_URI} [P]
        </Location>

It doesn't work.

@jpmens
Copy link
Member Author

jpmens commented Feb 7, 2024

zimpenfish says:

Had the same problem with Hugo’s livereload websocket. Solved it by creating a cookie after the first successful login and using that as an alternate authentication method. Not ideal at all but the only way I could find to avoid this with Safari.

This is my nginx configuration.\

map $cookie_thingauth $mysite_hascookie {
  "COOKIE_VALUE" "off";
  default "auth/realm";
}
...
location /xyz/ {
  auth_basic $mysite_hascookie;
  auth_basic_user_file "/pw/file";
  add_header Set-Cookie "thingauth=COOKIE_VALUE;max-age=86400;path=/;secure";
  ...
}

thingauth and COOKIE_VALUE have to match between the two blocks. Hopefully that helps and if there’s a better solution, I’d love to know myself.

This is looking promising...

@jpmens jpmens changed the title Safari keeps prompting for basic authentication Safari keeps prompting for basic authentication (apache / nginx) Feb 8, 2024
@jpmens
Copy link
Member Author

jpmens commented Feb 8, 2024

zimpenfish's solution appears to be working, and thank so much for that!

Cookies are being replaced when they expire, and I've not had Safari prompt for credentials since yesterday's launch.

@jpmens jpmens closed this as completed Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant