Hi everybody,
Is there an easy way to redirect a user based on his authentication login and password ?
Thanks!
Hi everybody,
Is there an easy way to redirect a user based on his authentication login and password ?
Thanks!
Hi @zelda-rageux,
This is extremely dependent on what technology you use for authentication. Personally I’d recommend doing this kind of operation on your backend, rather than your webserver.
Assuming you’re talking about basic auth, it is possible that the redir
directive could make conditional comparisons against the Authorization
request header sent by the client.
You would need to work out beforehand what the header would contain and then test for it directly. The Authorization
header usually consists of the text Basic [STRING]
where [STRING]
is the base-64 encoded version of [USER]:[PASSWORD]
.
The test would look like this:
example.com
basicauth / user password
redir {
# Valid only for literal user:password
if {>Authorization} is "Basic dXNlcjpwYXNzd29yZA=="
to https://example.com/some-url
}
basicauth / foo bar
redir {
# Valid only for literal foo:bar
if {>Authorization} is "Basic Zm9vOmJhcg=="
to https://example.com/other-url
}
https://caddyserver.com/docs/redir
https://caddyserver.com/docs/placeholders
Hi Matthew,
This solution is fine for me, i’ll produce a new Docker image with new Caddyfile automatically when the users db change.
Thanks you very much for your help.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.