tests: OAuth2 - Caddyfile `imap/xoauth2` route dynamic via query string
This way is more flexible and doesn't require modifying the `Caddyfile` directly, while still easy to use. Additionally simplifies understanding the Caddyfile to maintainers by removing the `route` directive that was required to ensure a deterministic order of vars.
This commit is contained in:
parent
c050c7290c
commit
2b102097fd
|
@ -52,15 +52,19 @@
|
|||
}
|
||||
|
||||
# /imap/xoauth2
|
||||
# Responds with the auth string (base64 encoded) for use with the IMAP `AUTHENTICATE` command:
|
||||
# curl http://auth.example.test/imap/xoauth2
|
||||
# Provide `user` and `access_token` values via query string parameters:
|
||||
# curl 'http://auth.example.test/imap/xoauth2?user=user1@localhost.localdomain&access_token=DMS_YWNjZXNzX3Rva2Vu'
|
||||
#
|
||||
# When Dovecot queries /userinfo endpoint, it will be after base64 decoding the IMAP `AUTHENTICATE` value,
|
||||
# and sending the `auth` value from the `credentials` variable as an HTTP Authorization header.
|
||||
:3000 {
|
||||
route {
|
||||
vars token "DMS_YWNjZXNzX3Rva2Vu"
|
||||
vars user "user1@localhost.localdomain"
|
||||
vars credentials "user={vars.user}\001auth=Bearer {vars.token}\001\001"
|
||||
# The login username + OAuth2 access token prior to Base64 encoding, as per the XOAUTH2 spec:
|
||||
# https://developers.google.com/gmail/imap/xoauth2-protocol#the_sasl_xoauth2_mechanism
|
||||
vars credentials "user={query.user}\001auth=Bearer {query.access_token}\001\001"
|
||||
|
||||
# Responds with the auth string (base64 encoded) for use with the IMAP `AUTHENTICATE` command:
|
||||
templates
|
||||
respond "{{b64enc \"{vars.credentials}\"}}"
|
||||
}
|
||||
|
||||
templates
|
||||
|
|
Loading…
Reference in New Issue