From: Aki Tuomi Date: Wed, 2 Nov 2022 13:56:54 +0000 (+0200) Subject: lib-oauth2: jwt - Allow missing 'typ' field X-Git-Tag: 2.3.21~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6d5eb297613a97ce8e800c948c1a64a3020fcaf1;p=thirdparty%2Fdovecot%2Fcore.git lib-oauth2: jwt - Allow missing 'typ' field --- diff --git a/src/lib-oauth2/oauth2-jwt.c b/src/lib-oauth2/oauth2-jwt.c index ec7ad46d4a..56e8d00fff 100644 --- a/src/lib-oauth2/oauth2-jwt.c +++ b/src/lib-oauth2/oauth2-jwt.c @@ -326,8 +326,8 @@ oauth2_jwt_header_process(struct json_tree *tree, const char **alg_r, const char *alg = get_field(tree, "alg"); const char *kid = get_field(tree, "kid"); - if (null_strcmp(typ, "JWT") != 0) { - *error_r = "Cannot find 'typ' field"; + if (typ != NULL && strcasecmp(typ, "JWT") != 0) { + *error_r = t_strdup_printf("Unsupported typ value '%s'", typ); return -1; } diff --git a/src/lib-oauth2/test-oauth2-jwt.c b/src/lib-oauth2/test-oauth2-jwt.c index 5f9925c276..dcf5e5e58b 100644 --- a/src/lib-oauth2/test-oauth2-jwt.c +++ b/src/lib-oauth2/test-oauth2-jwt.c @@ -388,15 +388,11 @@ static void test_jwt_broken_token(void) .is_jwt = FALSE }, { /* no alg field */ - .token = "eyJ0eXAiOiAiSldUIn0", - .is_jwt = FALSE - }, - { /* no typ field */ - .token = "eyJhbGciOiAiSFMyNTYifQ", + .token = "eyJ0eXAiOiAiSldUIn0.e30.e30", .is_jwt = FALSE }, { /* typ field is wrong */ - .token = "eyJ0eXAiOiAiand0IiwgImFsZyI6ICJIUzI1NiJ9." + .token = "e3R5cDogamtzLCBhbGc6IEhTMjU2fQ." "eyJhbGdvIjogIldURiIsICJ0eXAiOiAiSldUIn0." "q2wwwWWJVJxqw-J3uQ0DdlIyWfoZ7Z0QrdzvMW_B-jo", .is_jwt = FALSE