Skip to content

Commit

Permalink
Update authenticator url
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-lsvk committed Oct 2, 2023
1 parent 6fdb97c commit 8a8c6da
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ public protocol ClientIdAuthenticating {
func createAuthToken(url: String?) throws -> String
}

public struct ClientIdAuthenticator: ClientIdAuthenticating {
public final class ClientIdAuthenticator: ClientIdAuthenticating {
private let clientIdStorage: ClientIdStoring
private let url: String
private var url: String

public init(clientIdStorage: ClientIdStoring, url: String) {
self.clientIdStorage = clientIdStorage
self.url = url
}

public func createAuthToken(url: String? = nil) throws -> String {
url.flatMap { self.url = $0 }

let keyPair = try clientIdStorage.getOrCreateKeyPair()
let payload = RelayAuthPayload(subject: getSubject(), audience: url ?? self.url)
let payload = RelayAuthPayload(subject: getSubject(), audience: self.url)
return try payload.signAndCreateWrapper(keyPair: keyPair).jwtString
}

Expand Down

0 comments on commit 8a8c6da

Please sign in to comment.