File tree Expand file tree Collapse file tree 4 files changed +16
-16
lines changed
Sources/Main/AttestationBasedClient Expand file tree Collapse file tree 4 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,6 @@ public struct ClientAttestationJWT {
3737 }
3838 self . payload = JSON ( jsonObject)
3939
40- /*
41- guard payload[JWTClaimNames.subject].string != nil else {
42- throw ClientAttestationError.missingSubject
43- }
44- */
45-
4640 guard let cnf = payload [ JWTClaimNames . cnf] . dictionary else {
4741 throw ClientAttestationError . missingCnfClaim
4842 }
Original file line number Diff line number Diff line change @@ -48,22 +48,22 @@ public struct DefaultClientAttestationPoPBuilder: ClientAttestationPoPBuilder {
4848 clock: ClockType ,
4949 authServerId: URL
5050 ) throws -> ClientAttestationPoPJWT {
51-
5251 switch client {
5352 case . attested( let attestationJWT, let popJwtSpec) :
54- let now = Date ( )
55- let exp = now . addingTimeInterval ( popJwtSpec. duration)
56- let jws = try JWS . init (
53+ let now = Date ( ) . timeIntervalSince1970
54+ let exp = Date ( ) . addingTimeInterval ( popJwtSpec. duration) . timeIntervalSince1970
55+ let jws : JWS = try . init(
5756 header: try . init( parameters: [
5857 JWTClaimNames . algorithm: popJwtSpec. signingAlgorithm. rawValue,
5958 JWTClaimNames . type: popJwtSpec. typ
6059 ] ) ,
6160 payload: . init( JSON ( [
6261 JWTClaimNames . issuer: attestationJWT. clientId,
63- JWTClaimNames . jwtId: UUID ( ) . uuidString ,
62+ JWTClaimNames . jwtId: String . randomBase64URLString ( length : 20 ) ,
6463 JWTClaimNames . expirationTime: exp,
6564 JWTClaimNames . issuedAt: now,
66- JWTClaimNames . audience: authServerId. absoluteString
65+ JWTClaimNames . audience: authServerId. absoluteString,
66+ JWTClaimNames . cnf: attestationJWT. cnf
6767 ] ) . rawData ( ) ) ,
6868 signer: popJwtSpec. jwsSigner
6969 )
Original file line number Diff line number Diff line change @@ -35,15 +35,15 @@ public struct ClientAttestationPoPJWTSpec {
3535
3636 public let signingAlgorithm : SignatureAlgorithm
3737 public let duration : TimeInterval
38- public let typ : String ?
38+ public let typ : String
3939 public let jwsSigner : Signer
4040
4141 // MARK: - Initializer
4242
4343 public init (
4444 signingAlgorithm: SignatureAlgorithm ,
4545 duration: TimeInterval = 300 , // Default to 5 minutes
46- typ: String ? = nil ,
46+ typ: String ,
4747 jwsSigner: Signer
4848 ) throws {
4949 // Validate the signing algorithm (must not be MAC)
Original file line number Diff line number Diff line change @@ -36,11 +36,15 @@ internal func selfSignedClient(
3636 algorithm: algorithm
3737 )
3838
39+ let duration : TimeInterval = 300
40+ let now = Date ( ) . timeIntervalSince1970
41+ let exp = Date ( ) . addingTimeInterval ( duration) . timeIntervalSince1970
3942 let payload : Payload = try ! . init( [
4043 " iss " : clientId,
41- " clientId " : clientId,
44+ " aud " : clientId,
4245 " sub " : clientId,
43- " exp " : 1800000000 ,
46+ " iat " : now,
47+ " exp " : exp,
4448 " cnf " : [
4549 " jwk " : ECPublicKey (
4650 publicKey: try ! KeyController . generateECDHPublicKey (
@@ -65,6 +69,8 @@ internal func selfSignedClient(
6569 ) ,
6670 popJwtSpec: . init(
6771 signingAlgorithm: algorithm,
72+ duration: duration,
73+ typ: " oauth-client-attestation-pop+jwt " ,
6874 jwsSigner: signer
6975 )
7076 )
You can’t perform that action at this time.
0 commit comments