Performs a signature verification for the JSON Web Token (JWT) given in input
by using the <alg> algorithm and the <key> parameter, which should either
hold a secret or a path to a public certificate. Returns 1 in case of
- verification success. See below for a full list of the possible return
- values.
+ verification success, 0 in case of verification error and a strictly negative
+ value for any other error. Because of all those non-null error return values,
+ the result of this converter should never be converted to a boolean. See
+ below for a full list of the possible return values.
For now, only JWS tokens using the Compact Serialization format can be
processed (three dot-separated base64-url encoded strings). Among the
+----+----------------------------------------------------------------------+
| ID | message |
+----+----------------------------------------------------------------------+
- | 0 | "Verification failure" |
- | 1 | "Verification sucess" |
- | 2 | "Unknown algorithm (not mentioned in RFC7518)" |
- | 3 | "Unmanaged algorithm (PSXXX algorithm family)" |
- | 4 | "Invalid token" |
- | 5 | "Out of memory" |
- | 6 | "Unknown certificate" |
+ | 0 | "Verification failure" |
+ | 1 | "Verification sucess" |
+ | -1 | "Unknown algorithm (not mentioned in RFC7518)" |
+ | -2 | "Unmanaged algorithm (PSXXX algorithm family)" |
+ | -3 | "Invalid token" |
+ | -4 | "Out of memory" |
+ | -5 | "Unknown certificate" |
+----+----------------------------------------------------------------------+
Please note that this converter is only available when HAProxy has been
enum jwt_vrfy_status {
JWT_VRFY_KO = 0,
JWT_VRFY_OK = 1,
- JWT_VRFY_UNKNOWN_ALG,
- JWT_VRFY_UNMANAGED_ALG,
- JWT_VRFY_INVALID_TOKEN,
- JWT_VRFY_OUT_OF_MEMORY,
- JWT_VRFY_UNKNOWN_CERT
+
+ JWT_VRFY_UNKNOWN_ALG = -1,
+ JWT_VRFY_UNMANAGED_ALG = -2,
+ JWT_VRFY_INVALID_TOKEN = -3,
+ JWT_VRFY_OUT_OF_MEMORY = -4,
+ JWT_VRFY_UNKNOWN_CERT = -5
};
#endif /* USE_OPENSSL */
rxresp
expect resp.status == 200
expect resp.http.x-jwt-alg == "HS512"
- expect resp.http.x-jwt-verify-HS512 == "4"
+ expect resp.http.x-jwt-verify-HS512 == "-3"
} -run
expect resp.status == 200
expect resp.http.x-jwt-alg == "PS512"
# Unmanaged algorithm
- expect resp.http.x-jwt-verify == "3"
+ expect resp.http.x-jwt-verify == "-2"
} -run
# Unknown algorithm
expect resp.status == 200
expect resp.http.x-jwt-alg == "UNKNOWN_ALG"
# Unmanaged algorithm
- expect resp.http.x-jwt-verify == "2"
+ expect resp.http.x-jwt-verify == "-1"
} -run
# Invalid token (not enough fields)
expect resp.status == 200
expect resp.http.x-jwt-alg == "ES512"
# Unmanaged algorithm
- expect resp.http.x-jwt-verify == "4"
+ expect resp.http.x-jwt-verify == "-3"
} -run
# Invalid token (too many fields)
expect resp.status == 200
expect resp.http.x-jwt-alg == "ES512"
# Unmanaged algorithm
- expect resp.http.x-jwt-verify == "4"
+ expect resp.http.x-jwt-verify == "-3"
} -run
# Invalid token (empty signature)
expect resp.status == 200
expect resp.http.x-jwt-alg == "ES512"
# Unmanaged algorithm
- expect resp.http.x-jwt-verify == "4"
+ expect resp.http.x-jwt-verify == "-3"
} -run
# Unknown certificate
expect resp.status == 200
expect resp.http.x-jwt-alg == "ES512"
# Unmanaged algorithm
- expect resp.http.x-jwt-verify == "6"
+ expect resp.http.x-jwt-verify == "-5"
} -run