diff --git a/test/config/oauth2/Caddyfile b/test/config/oauth2/Caddyfile index 56a009d4..4f683e4f 100644 --- a/test/config/oauth2/Caddyfile +++ b/test/config/oauth2/Caddyfile @@ -52,9 +52,15 @@ } # /imap/xoauth2 +# Generate IMAP commands for authentication testing # 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' # +# Example Response: +# a0 AUTHENTICATE XOAUTH2 dXNlcj11c2VyMUBsb2NhbGhvc3QubG9jYWxkb21haW4BYXV0aD1CZWFyZXIgRE1TX1lXTmpaWE56WDNSdmEyVnUBAQ== +# a1 EXAMINE INBOX +# a2 LOGOUT +# # 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 { @@ -62,11 +68,12 @@ # 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: + # Responds with the raw IMAP commands for testing XOAUTH2 authentication. + # Uses the `b64enc` template function to encode credentials as required for `IMAP AUTHENTICATE`: templates - respond "{{b64enc \"{vars.credentials}\"}}" -} - - templates - respond "{{b64enc \"{vars.credentials}\"}}" + respond <