]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-oauth2: jwt - Allow missing 'typ' field
authorAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 2 Nov 2022 13:56:54 +0000 (15:56 +0200)
committerDovecot Automation <automation@dovecot.org>
Wed, 14 Jun 2023 07:03:29 +0000 (07:03 +0000)
src/lib-oauth2/oauth2-jwt.c
src/lib-oauth2/test-oauth2-jwt.c

index ec7ad46d4a96cebd724a22757f5998e97de7f843..56e8d00fffe672c5ad9682fdf015913063027af7 100644 (file)
@@ -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;
        }
 
index 5f9925c27610672c6c4b474afb627c7b8a95c005..dcf5e5e58b9ad98f2cedc44220cafe0c72b48d57 100644 (file)
@@ -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