Kitura / Swift-JWT

JSON Web Tokens in Swift
Apache License 2.0
549 stars 106 forks source link

"Alg" header not settable? #71

Closed markm77 closed 4 years ago

markm77 commented 4 years ago

Hi there,

Just curious why alg seems hard-coded to nil in Header class (https://github.com/IBM-Swift/Swift-JWT/blob/master/Sources/SwiftJWT/Header.swift)? I am experimenting with this library for UK Open Banking client registration where I need to set this value (see example Python code for this use case in 4.1.1 here: https://openbanking.atlassian.net/wiki/spaces/DZ/pages/313918598/Integrating+a+TPP+with+Ozone+Model+Banks+Using+Postman+on+Directory+Sandbox

Many thanks for any help!

BR, Mark

markm77 commented 4 years ago

Okay, I now see it seems to be set automatically in function below? Anyway I'll update this issue following testing - most likely to close it.

    public mutating func sign(using jwtSigner: JWTSigner) throws -> String {
        var tempHeader = header
        tempHeader.alg = jwtSigner.name
        let headerString = try tempHeader.encode()
        let claimsString = try claims.encode()
        header.alg = tempHeader.alg
        return try jwtSigner.sign(header: headerString, claims: claimsString)
    }
markm77 commented 4 years ago

All fine in testing so far. 😀