Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smal Auth/c Patch #2153

Merged
merged 1 commit into from Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 0 additions & 26 deletions Sources/Vapor/Authentication/Authenticator.swift
Expand Up @@ -39,32 +39,6 @@ extension BearerAuthenticator {
}
}

// MARK: User Token

public protocol UserTokenAuthenticator: RequestAuthenticator {
associatedtype TokenAuthenticator: RequestAuthenticator where
TokenAuthenticator.User: AuthenticationToken,
TokenAuthenticator.User.User == User

var tokenAuthenticator: TokenAuthenticator { get }
func authenticate(token: TokenAuthenticator.User, for request: Request) -> EventLoopFuture<User?>
}

extension UserTokenAuthenticator {
public func authenticate(request: Request) -> EventLoopFuture<User?> {
return self.tokenAuthenticator.authenticate(request: request).flatMap { token in
guard let token = token else {
return request.eventLoop.makeSucceededFuture(nil)
}
return self.authenticate(token: token, for: request)
}
}
}

public protocol AuthenticationToken {
associatedtype User
}

// MARK: Credentials

public protocol CredentialsAuthenticator: RequestAuthenticator {
Expand Down
6 changes: 6 additions & 0 deletions Sources/Vapor/Utilities/Array+Random.swift
Expand Up @@ -25,3 +25,9 @@ extension Array where Element: FixedWidthInteger {
return array
}
}

extension Array where Element == UInt8 {
public var base64: String {
Data(self).base64EncodedString()
}
}