From 84d42ef96eeecbec1e239a7401adbc88d027ce57 Mon Sep 17 00:00:00 2001 From: Sami Rosendahl Date: Tue, 9 Jul 2024 12:32:07 +0300 Subject: [PATCH] [fix] Bearer authorization token spelling; * It should be spelled excactly as "Bearer", see https://datatracker.ietf.org/doc/html/rfc6750#section-2.1 * Use TokenType.rawValue to produce string value of the token. --- Sources/Entities/IssuanceAccessToken.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Entities/IssuanceAccessToken.swift b/Sources/Entities/IssuanceAccessToken.swift index 50eba11..89150de 100644 --- a/Sources/Entities/IssuanceAccessToken.swift +++ b/Sources/Entities/IssuanceAccessToken.swift @@ -53,7 +53,7 @@ public struct IssuanceAccessToken: Codable { public extension IssuanceAccessToken { var authorizationHeader: [String: String] { - ["Authorization": "BEARER \(accessToken)"] + ["Authorization": "\(TokenType.bearer.rawValue) \(accessToken)"] } func dPoPOrBearerAuthorizationHeader( @@ -61,13 +61,13 @@ public extension IssuanceAccessToken { endpoint: URL? ) throws -> [String: String] { if tokenType == TokenType.bearer { - return ["Authorization": "BEARER \(accessToken)"] + return ["Authorization": "\(TokenType.bearer.rawValue) \(accessToken)"] } else if let dpopConstructor, tokenType == TokenType.dpop, let endpoint { return [ - "Authorization": "DPoP \(accessToken)", - "DPoP": try dpopConstructor.jwt(endpoint: endpoint, accessToken: accessToken) + "Authorization": "\(TokenType.dpop.rawValue) \(accessToken)", + TokenType.dpop.rawValue: try dpopConstructor.jwt(endpoint: endpoint, accessToken: accessToken) ] } - return ["Authorization": "BEARER \(accessToken)"] + return ["Authorization": "\(TokenType.bearer.rawValue) \(accessToken)"] } }