Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 1 | #REGTEST_TYPE=devel |
| 2 | |
| 3 | # This reg-test uses the JSON Web Token (JWT) converters to verify a token's signature. |
| 4 | # It uses the http_auth_bearer sample fetch to fetch a token contained in an |
| 5 | # HTTP Authorization header (with the Bearer scheme) which is the common way of |
| 6 | # transmitting a token (see RFC6750). It then uses the jwt_header_query |
| 7 | # converter to get the "alg" field declared in the token's JOSE header and |
| 8 | # gives it to the jwt_verify converter with the appropriate certificate. |
| 9 | # |
| 10 | # All the supported algorithms are tested at least once (HMAC, RSA and ECDSA) |
| 11 | # and the errors codes returned by jwt_verify are tested as well. |
| 12 | |
| 13 | varnishtest "Test the 'set ssl ca-file' feature of the CLI" |
| 14 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
| 15 | feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'" |
| 16 | feature cmd "command -v socat" |
| 17 | feature ignore_unknown_macro |
| 18 | |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 19 | server s1 -repeat 24 { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 20 | rxreq |
| 21 | txresp |
| 22 | } -start |
| 23 | |
| 24 | haproxy h1 -conf { |
| 25 | global |
| 26 | tune.ssl.default-dh-param 2048 |
| 27 | tune.ssl.capture-buffer-size 1 |
| 28 | stats socket "${tmpdir}/h1/stats" level admin |
| 29 | |
| 30 | defaults |
| 31 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 32 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 33 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 34 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 35 | |
| 36 | listen main-fe |
| 37 | bind "fd@${mainfe}" |
| 38 | |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 39 | use_backend hsXXX_be if { path_beg /hs } |
| 40 | use_backend rsXXX_be if { path_beg /rs } |
| 41 | use_backend esXXX_be if { path_beg /es } |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 42 | use_backend psXXX_be if { path_beg /ps } |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 43 | use_backend auth_bearer_be if { path /auth_bearer } |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 44 | default_backend dflt_be |
| 45 | |
| 46 | |
| 47 | backend hsXXX_be |
| 48 | http-request set-var(txn.bearer) http_auth_bearer |
| 49 | http-request set-var(txn.jwt_alg) var(txn.bearer),jwt_header_query('$.alg') |
| 50 | |
| 51 | http-request deny unless { var(txn.jwt_alg) -m beg "HS" } |
| 52 | |
| 53 | http-response set-header x-jwt-token %[var(txn.bearer)] |
| 54 | http-response set-header x-jwt-alg %[var(txn.jwt_alg)] |
| 55 | |
Willy Tarreau | 44c5ff6 | 2021-11-02 17:08:15 +0100 | [diff] [blame] | 56 | http-response set-header x-jwt-verify-HS256 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"hmac key hs256")] if { var(txn.jwt_alg) -m str "HS256" } |
| 57 | http-response set-header x-jwt-verify-HS384 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"hmac key hs384")] if { var(txn.jwt_alg) -m str "HS384" } |
| 58 | http-response set-header x-jwt-verify-HS512 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"hmac key hs512")] if { var(txn.jwt_alg) -m str "HS512" } |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 59 | server s1 ${s1_addr}:${s1_port} |
| 60 | |
| 61 | backend rsXXX_be |
| 62 | http-request set-var(txn.bearer) http_auth_bearer |
| 63 | http-request set-var(txn.jwt_alg) var(txn.bearer),jwt_header_query('$.alg') |
| 64 | |
| 65 | http-request deny unless { var(txn.jwt_alg) -m beg "RS" } |
| 66 | |
| 67 | http-response set-header x-jwt-token %[var(txn.bearer)] |
| 68 | http-response set-header x-jwt-alg %[var(txn.jwt_alg)] |
| 69 | |
Willy Tarreau | 44c5ff6 | 2021-11-02 17:08:15 +0100 | [diff] [blame] | 70 | http-response set-header x-jwt-verify-RS256 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/rsa-public.pem")] if { var(txn.jwt_alg) -m str "RS256" } |
| 71 | http-response set-header x-jwt-verify-RS384 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/rsa-public.pem")] if { var(txn.jwt_alg) -m str "RS384" } |
| 72 | http-response set-header x-jwt-verify-RS512 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/rsa-public.pem")] if { var(txn.jwt_alg) -m str "RS512" } |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 73 | server s1 ${s1_addr}:${s1_port} |
| 74 | |
| 75 | backend esXXX_be |
| 76 | http-request set-var(txn.bearer) http_auth_bearer |
| 77 | http-request set-var(txn.jwt_alg) var(txn.bearer),jwt_header_query('$.alg') |
| 78 | |
| 79 | http-request deny unless { var(txn.jwt_alg) -m beg "ES" } |
| 80 | |
| 81 | http-response set-header x-jwt-token %[var(txn.bearer)] |
| 82 | http-response set-header x-jwt-alg %[var(txn.jwt_alg)] |
| 83 | |
Willy Tarreau | 44c5ff6 | 2021-11-02 17:08:15 +0100 | [diff] [blame] | 84 | http-response set-header x-jwt-verify-ES256 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/es256-public.pem")] if { var(txn.jwt_alg) -m str "ES256" } |
| 85 | http-response set-header x-jwt-verify-ES384 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/es384-public.pem")] if { var(txn.jwt_alg) -m str "ES384" } |
| 86 | http-response set-header x-jwt-verify-ES512 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/es512-public.pem")] if { var(txn.jwt_alg) -m str "ES512" } |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 87 | server s1 ${s1_addr}:${s1_port} |
| 88 | |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 89 | backend psXXX_be |
| 90 | http-request set-var(txn.bearer) http_auth_bearer |
| 91 | http-request set-var(txn.jwt_alg) var(txn.bearer),jwt_header_query('$.alg') |
| 92 | |
| 93 | http-request deny unless { var(txn.jwt_alg) -m beg "PS" } |
| 94 | |
| 95 | http-response set-header x-jwt-token %[var(txn.bearer)] |
| 96 | http-response set-header x-jwt-alg %[var(txn.jwt_alg)] |
| 97 | |
| 98 | http-response set-header x-jwt-verify-PS256 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/rsa-public.pem")] if { var(txn.jwt_alg) -m str "PS256" } |
| 99 | http-response set-header x-jwt-verify-PS384 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/rsa-public.pem")] if { var(txn.jwt_alg) -m str "PS384" } |
| 100 | http-response set-header x-jwt-verify-PS512 %[var(txn.bearer),jwt_verify(txn.jwt_alg,"${testdir}/rsa-public.pem")] if { var(txn.jwt_alg) -m str "PS512" } |
| 101 | server s1 ${s1_addr}:${s1_port} |
| 102 | |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 103 | |
| 104 | # This backend will only be used to test the http_auth_bearer sample fetch. |
| 105 | # No jwt_verify will then be performed. |
| 106 | backend auth_bearer_be |
| 107 | http-request set-var(txn.bearer) http_auth_bearer("Custom-Authorization") |
| 108 | |
| 109 | http-response set-header x-jwt-token %[var(txn.bearer)] |
| 110 | |
| 111 | server s1 ${s1_addr}:${s1_port} |
| 112 | |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 113 | # This backend will mostly be used to test error cases (invalid tokens, algorithm and so on) |
| 114 | backend dflt_be |
| 115 | http-request set-var(txn.bearer) http_auth_bearer |
| 116 | http-request set-var(txn.jwt_alg) var(txn.bearer),jwt_header_query('$.alg') |
| 117 | |
| 118 | http-request set-var(txn.jwt_verify) var(txn.bearer),jwt_verify(txn.jwt_alg,"unknown_cert.pem") |
| 119 | |
| 120 | http-response set-header x-jwt-token %[var(txn.bearer)] |
| 121 | http-response set-header x-jwt-alg %[var(txn.jwt_alg)] |
| 122 | http-response set-header x-jwt-verify %[var(txn.jwt_verify)] |
| 123 | |
| 124 | server s1 ${s1_addr}:${s1_port} |
| 125 | |
| 126 | } -start |
| 127 | |
| 128 | |
| 129 | client c1 -connect ${h1_mainfe_sock} { |
| 130 | # Token content : {"alg":"HS256","typ":"JWT"} |
| 131 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 132 | # HMAC key : 'hmac key hs256' |
| 133 | # OpenSSL cmd : openssl dgst -sha256 -mac HMAC -macopt key:'hmac key hs256' data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 134 | |
| 135 | txreq -url "/hs256" -hdr "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.hhj1mbYgezxFoYwinThsZQbckYHt4jJlRoQ7W8ksrFM" |
| 136 | rxresp |
| 137 | expect resp.status == 200 |
| 138 | expect resp.http.x-jwt-alg == "HS256" |
| 139 | expect resp.http.x-jwt-verify-HS256 == "1" |
| 140 | } -run |
| 141 | |
| 142 | client c2 -connect ${h1_mainfe_sock} { |
| 143 | # Token content : {"alg":"HS384","typ":"JWT"} |
| 144 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 145 | # HMAC key : 'hmac key hs384' |
| 146 | # OpenSSL cmd : openssl dgst -sha384 -mac HMAC -macopt key:'hmac key hs384' data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 147 | |
| 148 | txreq -url "/hs384" -hdr "Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.3EsbLfl6DDh5nZMkLWg3ssCurFHyOhXP28a4PDS48aPAIoYLzHchtXmNaYI8He-R" |
| 149 | rxresp |
| 150 | expect resp.status == 200 |
| 151 | expect resp.http.x-jwt-alg == "HS384" |
| 152 | expect resp.http.x-jwt-verify-HS384 == "1" |
| 153 | } -run |
| 154 | |
| 155 | client c3 -connect ${h1_mainfe_sock} { |
| 156 | # Token content : {"alg":"HS512","typ":"JWT"} |
| 157 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 158 | # HMAC key : 'hmac key hs512' |
| 159 | # OpenSSL cmd : openssl dgst -sha512 -mac HMAC -macopt key:'hmac key hs512' data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 160 | |
| 161 | txreq -url "/hs512" -hdr "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.K4Yze5N7jeJrDbJymphaH1YsFlYph5F-U75HzBRKDybrN7WBO494EgNG77mAQj4CVci_xbTD_IsqY2umO0f47A" |
| 162 | rxresp |
| 163 | expect resp.status == 200 |
| 164 | expect resp.http.x-jwt-alg == "HS512" |
| 165 | expect resp.http.x-jwt-verify-HS512 == "1" |
| 166 | } -run |
| 167 | |
| 168 | # The following token is invalid (it has three extra characters at the end of the signature) |
| 169 | client c4 -connect ${h1_mainfe_sock} { |
| 170 | # Token content : {"alg":"HS512","typ":"JWT"} |
| 171 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 172 | # HMAC key : 'hmac key hs512' |
| 173 | # OpenSSL cmd : openssl dgst -sha512 -mac HMAC -macopt key:'hmac key hs512' data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 174 | |
| 175 | txreq -url "/hs512" -hdr "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.K4Yze5N7jeJrDbJymphaH1YsFlYph5F-U75HzBRKDybrN7WBO494EgNG77mAQj4CVci_xbTD_IsqY2umO0f47AAAA" |
| 176 | rxresp |
| 177 | expect resp.status == 200 |
| 178 | expect resp.http.x-jwt-alg == "HS512" |
Remi Tricot-Le Breton | 1c891bc | 2021-10-18 15:14:49 +0200 | [diff] [blame] | 179 | expect resp.http.x-jwt-verify-HS512 == "-3" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 180 | } -run |
| 181 | |
| 182 | |
| 183 | client c5 -connect ${h1_mainfe_sock} { |
| 184 | # Token content : {"alg":"RS256","typ":"JWT"} |
| 185 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 186 | # OpenSSL cmd : openssl dgst -sha256 -sign rsa-private.pem data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 187 | |
| 188 | txreq -url "/rs256" -hdr "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.hRqFM87JzV_YinYhdERp2E9BLhl6s7I5J37GTXAeT5fixJx-OCjTFvwKssyVo7fWAFcQMdQU7vGEXDOiWbNaMUFGIsMxx0Uflk0BeNwk6pWvNGk8KZGMtiqOv-IuPdAiaSW_xhxLHIk7eOwVefvBfk8j2hgU9yoHN87AYnl8oEnzrkzwWvEt-x-P2zB4s_VwhF0gbL1G4FsP5hxWL1HWmSFLBpvWaL5Lx3OJE7mLRLRf8TpMwEe4ROakzMpiv9Xk1H3mZth6d2a91F5Bm65MIJpJ7P2kEL3tdS62VRx8DM_SlsFuWcsqryO3CDQquMbwzAvfRgLPy8PBLRLT64wM3mZtue5GI2KUlqSYsSwKwK580b4drosLvAS75l_4jJwdwuQEvVd8Gry3DWS2mKJSMefmGfD-cdty1vvszs5sUa96Gf7Ro5DvkgXtVCKYk8KJLI62YgZd5S3M0ucP5NLBc_flUi4A2B_aSkd7NDM0ELddk0y48pcF95tejcvliGIy1GRRwevdqensXXQrFweFSZVvuKo8c9pcCBVfKTSllgL0lFGyI_vz6dUYt69I1gqWBDeGcA2XQUBJqfX3o9nkhZspA7b7QxMESatoATsM_XmfhbwsyY-sTq25XIGC4awaZHViZr1YFVD6BwNZWBCEBvW5zObiD5h5A5AgWoBv14E" |
| 189 | rxresp |
| 190 | expect resp.status == 200 |
| 191 | expect resp.http.x-jwt-alg == "RS256" |
| 192 | expect resp.http.x-jwt-verify-RS256 == "1" |
| 193 | } -run |
| 194 | |
| 195 | client c6 -connect ${h1_mainfe_sock} { |
| 196 | # Token content : {"alg":"RS384","typ":"JWT"} |
| 197 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 198 | # OpenSSL cmd : openssl dgst -sha384 -sign rsa-private.pem data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 199 | |
| 200 | txreq -url "/rs384" -hdr "Authorization: Bearer eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.GuR-v91EMCVvvTTLiE56O0oDAKeQ5JdLqvHtrgOp2MbUtF7zCDutV0LTmMo4qDNVpvTnD3GZfTTGaVUTvW7kIQ3_1iEVAg61qVWkT9rtHHxifDX70RDBKkvNcMWyQH-dFP_FUvCmhCu7q-AzgBT6PHvs5ZqYyQvlQ1gSWZEPFi184dhvcUQrQC6CySEAdOzIryIHH2oQjN_a9lA9V9M_CH3P-AAwFE7NwUE1H1SGIYM4NHcngEZ3B4lBCHOhhgQMpfagcxQjjXv7VfeSqza6OZDpupwlOl34bb0gnFDGMh4hHSS6iHvvwCeCkclbyvKV0Vq0MaRtJuoKRF-_Oww-nKT_bfNtbF6MeOQLNRlYjGCHerWoBtjv3w2KjoLvQ5iGIFI3cEguyrrKNimpovF4Y5uINH0pWdRF99zOwVUlcJBk3RivIb--Y6s47aNFIVWimUpSn-8MSHTla20TYbcdVaZaMur09Cw500jPrOy6jFqVydSnmU6r13NkmCD5-Bl0mgwGtpZcOQExrnIcPQky12kQJAIrffVblvtkd-8FIBPBy1uBKCgkE-q9_suEvBTdvaoTocBmPcIxfPjZUVXeU3UmnRrXEz17pue0YfrwK9CUR9UoP0F5C7O5eSbAtZNm4Hpkiah0w7qugWG3esMgku3-xx0B2xwg6Ul7bAgEJFg" |
| 201 | rxresp |
| 202 | expect resp.status == 200 |
| 203 | expect resp.http.x-jwt-alg == "RS384" |
| 204 | expect resp.http.x-jwt-verify-RS384 == "1" |
| 205 | } -run |
| 206 | |
| 207 | client c7 -connect ${h1_mainfe_sock} { |
| 208 | # Token content : {"alg":"RS512","typ":"JWT"} |
| 209 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 210 | # OpenSSL cmd : openssl dgst -sha512 -sign rsa-private.pem data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 211 | |
| 212 | txreq -url "/rs512" -hdr "Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.dgUDvxbWXV-q9lVFDVDt6zffrAjCMkKL7UURz-vvc6utCNMEgt8jSkDWi-mt-jmttkD5mwHqUf3HxWPhfjYNmkTok_XL79F5RXhiF_cu_2oDLDc-RuXdrHaRt9xjUIyZhVJMhaMLdmpcAokQlZxc2W6aj92HKzk3EjyHwfdwfKQNgMooXNzxjE9vCHUbahyLZvtPwiqDtYUSnvN_XOpAMUilxByJStwNqdB7MaOxeAzn76nITh6DqD1bNtxBiLzA7MxYdfsUSmXHMLpkWNAhlrcEIJui9PKm9E0OLFD3M7cCqi6rVvzDxvHqXz3-fcXiSJSRrSmSTu1_ok35TT4WwA9SkHpGe2MJ3uc-8CRlYmjDTcLyXWs_d8i3iNozo6xgiwqIkty4HqScTjhXndRQdmiK-RcUfNLM0Iqm6wYgOifWj728_9GCtdjup-C2uVPdwVwuOjwLbzctZLlFqH3i5IGrCfuOOCAcc_vN3REFqSrDEi4-9qpXuh7yk5pOaiCZYr3-uVhmY5neo55_eV8N3NooDyztwkzRtB_DdbaNrqxk3WEHU79Hseg7c1mkXGm6Djqt3dkkrdpbltzRLrnGKxA4-FzccKOT_P27UYmxQSkyfpAQhfH3jpOE0n9-UYyULbMOY7ZIypXUTquJnrZM3rD_NypU7Jg8uBBGqcziZFc" |
| 213 | rxresp |
| 214 | expect resp.status == 200 |
| 215 | expect resp.http.x-jwt-alg == "RS512" |
| 216 | expect resp.http.x-jwt-verify-RS512 == "1" |
| 217 | } -run |
| 218 | |
| 219 | # The following token is invalid (the signature used SHA384 instead of SHA512) |
| 220 | client c8 -connect ${h1_mainfe_sock} { |
| 221 | # Token content : {"alg":"RS512","typ":"JWT"} |
| 222 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 223 | # OpenSSL cmd : openssl dgst -sha512 -sign rsa-private.pem data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 224 | |
| 225 | txreq -url "/rs512" -hdr "Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.GuR-v91EMCVvvTTLiE56O0oDAKeQ5JdLqvHtrgOp2MbUtF7zCDutV0LTmMo4qDNVpvTnD3GZfTTGaVUTvW7kIQ3_1iEVAg61qVWkT9rtHHxifDX70RDBKkvNcMWyQH-dFP_FUvCmhCu7q-AzgBT6PHvs5ZqYyQvlQ1gSWZEPFi184dhvcUQrQC6CySEAdOzIryIHH2oQjN_a9lA9V9M_CH3P-AAwFE7NwUE1H1SGIYM4NHcngEZ3B4lBCHOhhgQMpfagcxQjjXv7VfeSqza6OZDpupwlOl34bb0gnFDGMh4hHSS6iHvvwCeCkclbyvKV0Vq0MaRtJuoKRF-_Oww-nKT_bfNtbF6MeOQLNRlYjGCHerWoBtjv3w2KjoLvQ5iGIFI3cEguyrrKNimpovF4Y5uINH0pWdRF99zOwVUlcJBk3RivIb--Y6s47aNFIVWimUpSn-8MSHTla20TYbcdVaZaMur09Cw500jPrOy6jFqVydSnmU6r13NkmCD5-Bl0mgwGtpZcOQExrnIcPQky12kQJAIrffVblvtkd-8FIBPBy1uBKCgkE-q9_suEvBTdvaoTocBmPcIxfPjZUVXeU3UmnRrXEz17pue0YfrwK9CUR9UoP0F5C7O5eSbAtZNm4Hpkiah0w7qugWG3esMgku3-xx0B2xwg6Ul7bAgEJFg" |
| 226 | rxresp |
| 227 | expect resp.status == 200 |
| 228 | expect resp.http.x-jwt-alg == "RS512" |
| 229 | expect resp.http.x-jwt-verify-RS512 == "0" |
| 230 | } -run |
| 231 | |
| 232 | |
| 233 | |
| 234 | client c9 -connect ${h1_mainfe_sock} { |
| 235 | # Token content : {"alg":"ES256","typ":"JWT"} |
| 236 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 237 | # Key gen process : openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out es256-private.pem; openssl ec -in es256-private.pem -pubout -out es256-public.pem |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 238 | # Token creation : ./build_token.py ES256 '{"sub":"1234567890","name":"John Doe","iat":1516239022}' es256-private.pem |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 239 | |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 240 | txreq -url "/es256" -hdr "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.pNI_c5mHE3mLV0YDpstlP4l3t5XARLl6OmcKLuvF5r60m-C63mbgfKWdPjmJPMTCmX_y50YW_v2SKw0ju0tJHw" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 241 | rxresp |
| 242 | expect resp.status == 200 |
| 243 | expect resp.http.x-jwt-alg == "ES256" |
| 244 | expect resp.http.x-jwt-verify-ES256 == "1" |
| 245 | } -run |
| 246 | |
| 247 | client c10 -connect ${h1_mainfe_sock} { |
| 248 | # Token content : {"alg":"ES384","typ":"JWT"} |
| 249 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 250 | # Key gen process : openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-384 -out es384-private.pem; openssl ec -in es384-private.pem -pubout -out es384-public.pem |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 251 | # Token creation : ./build_token.py ES384 '{"sub":"1234567890","name":"John Doe","iat":1516239022}' es384-private.pem |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 252 | |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 253 | txreq -url "/es384" -hdr "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzM4NCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.cs59CQiCI_Pl8J-PKQ2y73L5IJascZXkf7MfRXycO1HkT9pqDW2bFr1bh7pFyPA85GaML4BPYVH_zDhcmjSMn_EIvUV8cPDuuUu69Au7n9LYGVkVJ-k7qN4DAR5eLCiU" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 254 | rxresp |
| 255 | expect resp.status == 200 |
| 256 | expect resp.http.x-jwt-alg == "ES384" |
| 257 | expect resp.http.x-jwt-verify-ES384 == "1" |
| 258 | } -run |
| 259 | |
| 260 | client c11 -connect ${h1_mainfe_sock} { |
| 261 | # Token content : {"alg":"ES512","typ":"JWT"} |
| 262 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 263 | # Key gen process : openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-521 -out es512-private.pem; openssl ec -in es512-private.pem -pubout -out es512-public.pem |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 264 | # Token creation : ./build_token.py ES512 '{"sub":"1234567890","name":"John Doe","iat":1516239022}' es512-private.pem |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 265 | |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 266 | txreq -url "/es512" -hdr "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzUxMiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.AJcyt0OYf2wg7SggJJVKYysLUkBQA0f0Zc0EbKgud2fQLeT65n42A9l9hhGje79VLWhEyisQmDpFXTpfFXeD_NiaAXyNnX5b8TbZALqxbjx8iIpbcObgUh_g5Gi81bKmRmfXUHW7L5iAwoNjYbUpXGipCpCD0N6-8zCrjcFD2UX01f0Y" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 267 | rxresp |
| 268 | expect resp.status == 200 |
| 269 | expect resp.http.x-jwt-alg == "ES512" |
| 270 | expect resp.http.x-jwt-verify-ES512 == "1" |
| 271 | } -run |
| 272 | |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 273 | |
| 274 | |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 275 | client c12 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 276 | # Token content : {"alg":"PS256","typ":"JWT"} |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 277 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 278 | # Token creation : ./build_token.py PS256 '{"sub":"1234567890","name":"John Doe","iat":1516239022}' rsa-private.pem |
| 279 | txreq -url "/ps256" -hdr "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJQUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.eXzN8m41ejgmbtJPhgifU_jMuYwVXL3HsLMOJ_ERipNcuqVQUmfHib1MWydSOYkgNBIm2lK9LjUmRCs1LvMUsbcqnokebFUNmO6IFdbMj3kD4cvqXHyK0yogQ7fdtJZf3_ukcJQ_-IdCG6mwowq6-OLjv-v2EflwPsT33EGmEDuE-7Z8AVTOVPiKUrqq1KqBi7NnnzdghqKfXn4b0yT7CnxQ_GK4F-ghBxBiMXK2J8M6pvS1vof7PyzVQmpeNzn2Rpbk-Ez88WeoTQXqZL1_BeW0z8FeyWXoIiqAzluRHSfZf2iUwrHuiH-tZ5BkAsJXHMDhMoL8_TKdD2hAnCWdVA9W9bQpzfaCbF5xv8lkGcy01ekrh-rN6ZOjItYeDj3BuaQgrKa5YAs_Grei_iSLqAu_YmDiVJxBfv5ahe1I8rwBQ7lIsZqv6p8BKqBFNylLzIFioAtmHJBF0HtItLoj0Mp_bUuU6RLIwf7C8ZWPQVTVsTgHMAlnZLNnQ3vhcxCjLm-r45M3AUFQfMEy1ajiqpFb3z2ElEwiOS9uLYJs3AOAoJDc-e62VJ7tRlw7KB-Vw0mvztvXgYdit48KOxdbn15HQ0lbBM_jJHvbYjDFC0iGUaizBPqmOJcTvObvKv5itEhPT6ffsv9XBnRSv9f3kW_rI7chrCyRZc0nFUvEJ9o" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 280 | rxresp |
| 281 | expect resp.status == 200 |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 282 | expect resp.http.x-jwt-alg == "PS256" |
| 283 | expect resp.http.x-jwt-verify-PS256 == "1" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 284 | } -run |
| 285 | |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 286 | client c13 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 287 | # Token content : {"alg":"PS384","typ":"JWT"} |
| 288 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 289 | # Token creation : ./build_token.py PS384 '{"sub":"1234567890","name":"John Doe","iat":1516239022}' rsa-private.pem |
| 290 | txreq -url "/ps384" -hdr "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJQUzM4NCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.f-il5pRvC_vYuJ5jI-q9zxgqStCzvICKJyJEmVSjK47uLtt24SNLsQ1V24gqGuDOkXAhxlVu9rUwvtbzOQbF6N1YFFKbCuJ7zbGG81j5r3IuFl_5y6v077PW3hSNn62WX1GDv8w_kGedAZqGwKhJR7D1CbPBE5v-b4PskVF1V7IrFx8PufS_LUeJq1Etei0iU7H9OWD0yVApE_nmeELy4Kz1cc1fQZTBzd-b6kB562JbUbENM14HoiuKpnZvDtQks93A7y_B14SZPrxDaiVI-fR1n8Ja10wyBqbw8mWzt4s7vkxQI8U0eTBcj6bpWcm6S947G_jjoum_Lu3ZSKXE4UxcZ2IIuM74PEUgWJUjr4f9klB8kplJS5AIXMUNG6QbgZhOdSfZmlfzZUmSt1CLI22rTadXjvn-5CG_VxWJUjcPF9hViFFKQ7qQw3Tcn73ZKf5toK3imQBay4vR11DYWP5flLscFtqPvFcV4qhNarG-kVTI2xO8wXDXEoKeIXvsr3GTmCmBbs-kxvtyI80GUTzKN2I9vp0W9Qo5GNa3DDU1-io3olVwtMFh_0qfhmdO1Rt-j11gGnYTz3S5zMMMG2Ihy8ho3ayNZlZf7MJvVBSPqbCpHdiRa8VgTyYdYvK81lgkSc3wE8CygFEBMEi9b181OKPODlpux6k-3AL_2Hs" |
| 291 | rxresp |
| 292 | expect resp.status == 200 |
| 293 | expect resp.http.x-jwt-alg == "PS384" |
| 294 | expect resp.http.x-jwt-verify-PS384 == "1" |
| 295 | } -run |
| 296 | |
| 297 | client c14 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 298 | # Token content : {"alg":"PS512","typ":"JWT"} |
| 299 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 300 | # Token creation : ./build_token.py PS512 '{"sub":"1234567890","name":"John Doe","iat":1516239022}' rsa-private.pem |
| 301 | txreq -url "/ps512" -hdr "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJQUzUxMiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.tJZQn0ksGx7vFpBzhNkP8vupyRiAAy5Rf6UdR2MEnO6-iwisbXOUrwwh8XQWngEe2O5FJabCxJRI_shSVEUuWY2Vz6kvRAQ6sWv_4uoPTUk9zjSXkS6C_nb_UY_6tUz39qA-OI80JKcLadvjB66CGWHI00C5Xz2gyWQuFgSItBIV6l0wI6Spf4NJa2Lefo7XbobQ7-u-yzgbIJ1BgXFOTWHYsgJ67n39gj7MDDsUjSaNbFlKfbvGJrdli5_PNNSdoNiF0pdsd6vldnucs5Rfysp4V-nbBzrORuJhl0_BlPG7_Wbap0sm6NCnzp1ks3D5_OWLZxJZNw_TJ2OuVHOX2PNj2MuHjMPDMKKxgxIXQJ8ry39-sk56ZrCJ8UqZofk8NX7Z4ypeWrK62BNSTLY8Le4WzF6dYcuawxiyt7xsC0MkaplXpRFLdmHrMhvyZz6S8BFhtlGD-PnRnEr8qZkThiZSs5kcEW8ryneKlN5TQ7E0H1HekUUii3_T9MtC5rNsT1vzyGr0XAn5TLxeal4Gvp3WyOHs4l7Q1EyQXPkAX8bWwODtLZ3DrREwdLb7Ex2k9wRDF52aww9EMpeLM3at6MQKggWQhNEClahN9AWBj7Vz-RqliWEIdUdNTL3d1JgLX41GZqXjOGZIwiVJwYpVRh1jKVhUn8pN8jCtoeiUxh8" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 302 | rxresp |
| 303 | expect resp.status == 200 |
| 304 | expect resp.http.x-jwt-alg == "PS512" |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 305 | expect resp.http.x-jwt-verify-PS512 == "1" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 306 | } -run |
| 307 | |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 308 | |
| 309 | |
| 310 | # The following token is invalid (too short) |
| 311 | client c15 -connect ${h1_mainfe_sock} { |
| 312 | # Token content : {"alg":"ES512","typ":"JWT"} |
| 313 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 314 | # OpenSSL cmd : openssl dgst -sha512 -sign es512-private.pem data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 315 | |
| 316 | txreq -url "/es512" -hdr "Authorization: Bearer eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.MIGHAkEEPEgIrFKIDofBpFKX_mtya55QboGr09P6--v8uO85DwQWR0iKgMNSzYkL3K1lwyExG0Vtwfnife0lNe7Fn5TigAJCAY95NShiTn3tvleXVGCkkD0-HcribnMhd34QPGRc4rlwTkUg9umIUhxnEhPR--OohlmhJyIYGHuH8Ksm5f" |
| 317 | rxresp |
| 318 | expect resp.status == 200 |
| 319 | expect resp.http.x-jwt-alg == "ES512" |
| 320 | # Invalid token |
| 321 | expect resp.http.x-jwt-verify-ES512 == "-3" |
| 322 | } -run |
| 323 | |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 324 | # Unknown algorithm |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 325 | client c16 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 326 | # Token content : {"alg":"UNKNOWN_ALG","typ":"JWT"} |
| 327 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 328 | txreq -url "/errors" -hdr "Authorization: Bearer eyJhbGciOiJVTktOT1dOX0FMRyIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.MIGHAkEEPEgIrFKIDofBpFKX_mtya55QboGr09P6--v8uO85DwQWR0iKgMNSzYkL3K1lwyExG0Vtwfnife0lNe7Fn5TigAJCAY95NShiTn3tvleXVGCkkD0-HcribnMhd34QPGRc4rlwTkUg9umIUhxnEhPR--OohlmhJyIYGHuH8Ksm5f" |
| 329 | rxresp |
| 330 | expect resp.status == 200 |
| 331 | expect resp.http.x-jwt-alg == "UNKNOWN_ALG" |
| 332 | # Unmanaged algorithm |
Remi Tricot-Le Breton | 1c891bc | 2021-10-18 15:14:49 +0200 | [diff] [blame] | 333 | expect resp.http.x-jwt-verify == "-1" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 334 | } -run |
| 335 | |
| 336 | # Invalid token (not enough fields) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 337 | client c17 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 338 | # Token content : {"alg":"ES512","typ":"JWT"} |
| 339 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 340 | txreq -url "/errors" -hdr "Authorization: Bearer eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ" |
| 341 | rxresp |
| 342 | expect resp.status == 200 |
| 343 | expect resp.http.x-jwt-alg == "ES512" |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 344 | # Invalid token |
Remi Tricot-Le Breton | 1c891bc | 2021-10-18 15:14:49 +0200 | [diff] [blame] | 345 | expect resp.http.x-jwt-verify == "-3" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 346 | } -run |
| 347 | |
| 348 | # Invalid token (too many fields) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 349 | client c18 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 350 | # Token content : {"alg":"ES512","typ":"JWT"} |
| 351 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 352 | txreq -url "/errors" -hdr "Authorization: Bearer eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.MIGHAkEEPEgIrFKIDofBpFKX_mtya55QboGr09P6--v8uO85DwQWR0iKgMNSzYkL3K1lwyExG0Vtwfnife0lNe7Fn5TigAJCAY95NShiTn3tvleXVGCkkD0-HcribnMhd34QPGRc4rlwTkUg9umIUhxnEhPR--OohlmhJyIYGHuH8Ksm5f.unexpectedextrafield" |
| 353 | rxresp |
| 354 | expect resp.status == 200 |
| 355 | expect resp.http.x-jwt-alg == "ES512" |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 356 | # Invalid token |
Remi Tricot-Le Breton | 1c891bc | 2021-10-18 15:14:49 +0200 | [diff] [blame] | 357 | expect resp.http.x-jwt-verify == "-3" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 358 | } -run |
| 359 | |
| 360 | # Invalid token (empty signature) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 361 | client c19 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 362 | # Token content : {"alg":"ES512","typ":"JWT"} |
| 363 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 364 | txreq -url "/errors" -hdr "Authorization: Bearer eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ." |
| 365 | rxresp |
| 366 | expect resp.status == 200 |
| 367 | expect resp.http.x-jwt-alg == "ES512" |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 368 | # Invalid token |
Remi Tricot-Le Breton | 1c891bc | 2021-10-18 15:14:49 +0200 | [diff] [blame] | 369 | expect resp.http.x-jwt-verify == "-3" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 370 | } -run |
| 371 | |
| 372 | # Unknown certificate |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 373 | client c20 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 374 | # Token content : {"alg":"ES512","typ":"JWT"} |
| 375 | # {"sub":"1234567890","name":"John Doe","iat":1516239022} |
| 376 | # Key gen process : openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-521 -out es512-private.pem; openssl ec -in es512-private.pem -pubout -out es512-public.pem |
| 377 | # OpenSSL cmd : openssl dgst -sha512 -sign es512-private.pem data.txt | base64 | tr -d '=\n' | tr '/+' '_-' |
| 378 | |
| 379 | txreq -url "/errors" -hdr "Authorization: Bearer eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.MIGHAkEEPEgIrFKIDofBpFKX_mtya55QboGr09P6--v8uO85DwQWR0iKgMNSzYkL3K1lwyExG0Vtwfnife0lNe7Fn5TigAJCAY95NShiTn3tvleXVGCkkD0-HcribnMhd34QPGRc4rlwTkUg9umIUhxnEhPR--OohlmhJyIYGHuH8Ksm5fSIWfRa" |
| 380 | rxresp |
| 381 | expect resp.status == 200 |
| 382 | expect resp.http.x-jwt-alg == "ES512" |
Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 383 | # Unknown certificate |
Remi Tricot-Le Breton | 1c891bc | 2021-10-18 15:14:49 +0200 | [diff] [blame] | 384 | expect resp.http.x-jwt-verify == "-5" |
Remi Tricot-Le Breton | 36da606 | 2021-10-01 15:36:59 +0200 | [diff] [blame] | 385 | } -run |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 386 | |
| 387 | |
| 388 | # Test the http_auth_bearer special cases (other header than the default "Authorization" one) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 389 | client c21 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 390 | txreq -url "/auth_bearer" -hdr "Custom-Authorization: Bearer random_value" |
| 391 | rxresp |
| 392 | expect resp.status == 200 |
| 393 | expect resp.http.x-jwt-token == "random_value" |
| 394 | } -run |
| 395 | |
| 396 | # Test the http_auth_bearer special cases (multiple spaces after the scheme) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 397 | client c22 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 398 | txreq -url "/auth_bearer" -hdr "Custom-Authorization: Bearer random_value" |
| 399 | rxresp |
| 400 | expect resp.status == 200 |
| 401 | expect resp.http.x-jwt-token == "random_value" |
| 402 | } -run |
| 403 | |
| 404 | # Test the http_auth_bearer special cases (no value after the scheme) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 405 | client c23 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 406 | txreq -url "/auth_bearer" -hdr "Custom-Authorization: Bearer " |
| 407 | rxresp |
| 408 | expect resp.status == 200 |
| 409 | expect resp.http.x-jwt-token == "" |
| 410 | } -run |
| 411 | |
| 412 | # Test the http_auth_bearer special cases (no value after the scheme) |
Remi Tricot-Le Breton | 447a38f | 2023-03-07 17:43:57 +0100 | [diff] [blame] | 413 | client c24 -connect ${h1_mainfe_sock} { |
Remi Tricot-Le Breton | 7da35bf | 2021-10-29 15:25:19 +0200 | [diff] [blame] | 414 | txreq -url "/errors" -hdr "Authorization: Bearer " |
| 415 | rxresp |
| 416 | expect resp.status == 200 |
| 417 | expect resp.http.x-jwt-token == "" |
| 418 | } -run |