tests: OAuth2 - `/imap/xoauth2` respond with IMAP commands for netcat
Since this is the only intended usage, might as well have it respond with the full file content.
This commit is contained in:
parent
2b102097fd
commit
74ead6a83a
|
@ -52,9 +52,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
# /imap/xoauth2
|
# /imap/xoauth2
|
||||||
|
# Generate IMAP commands for authentication testing
|
||||||
# Provide `user` and `access_token` values via query string parameters:
|
# 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'
|
# 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,
|
# 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.
|
# and sending the `auth` value from the `credentials` variable as an HTTP Authorization header.
|
||||||
:3000 {
|
:3000 {
|
||||||
|
@ -62,11 +68,12 @@
|
||||||
# https://developers.google.com/gmail/imap/xoauth2-protocol#the_sasl_xoauth2_mechanism
|
# https://developers.google.com/gmail/imap/xoauth2-protocol#the_sasl_xoauth2_mechanism
|
||||||
vars credentials "user={query.user}\001auth=Bearer {query.access_token}\001\001"
|
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
|
templates
|
||||||
respond "{{b64enc \"{vars.credentials}\"}}"
|
respond <<EOF
|
||||||
}
|
a0 AUTHENTICATE XOAUTH2 {{b64enc "{vars.credentials}"}}
|
||||||
|
a1 EXAMINE INBOX
|
||||||
templates
|
a2 LOGOUT
|
||||||
respond "{{b64enc \"{vars.credentials}\"}}"
|
EOF
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue