-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update OAuthUser to have an id property of type Identifer to make Flu…
…ent integration simple
- Loading branch information
Showing
23 changed files
with
69 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import Node | ||
|
||
public struct EmptyUserManager: UserManager { | ||
|
||
public init() {} | ||
|
||
public func getUser(id: String) -> OAuthUser? { | ||
public func getUser(id: Identifier) -> OAuthUser? { | ||
return nil | ||
} | ||
|
||
public func authenticateUser(username: String, password: String) -> String? { | ||
public func authenticateUser(username: String, password: String) -> Identifier? { | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import Authentication | ||
import Core | ||
import Node | ||
|
||
public final class OAuthUser: Authenticatable, Extendable { | ||
public let username: String | ||
public let emailAddress: String? | ||
public let password: Bytes | ||
public let userID: String? | ||
public var id: Identifier? | ||
|
||
public var extend: [String: Any] = [:] | ||
|
||
public init(userID: String?, username: String, emailAddress: String?, password: Bytes) { | ||
public init(id: Identifier? = nil, username: String, emailAddress: String?, password: Bytes) { | ||
self.username = username | ||
self.emailAddress = emailAddress | ||
self.password = password | ||
self.userID = userID | ||
self.id = id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import Node | ||
|
||
public protocol UserManager { | ||
func authenticateUser(username: String, password: String) -> String? | ||
func getUser(id: String) -> OAuthUser? | ||
func authenticateUser(username: String, password: String) -> Identifier? | ||
func getUser(id: Identifier) -> OAuthUser? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import OAuth | ||
import Node | ||
|
||
struct StubUserManager: UserManager { | ||
func authenticateUser(username: String, password: String) -> String? { | ||
func authenticateUser(username: String, password: String) -> Identifier? { | ||
return nil | ||
} | ||
|
||
func getUser(id: String) -> OAuthUser? { | ||
func getUser(id: Identifier) -> OAuthUser? { | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,10 +381,10 @@ class ImplicitGrantTests: XCTestCase { | |
} | ||
|
||
func testThatUserIDIsSetOnToken() throws { | ||
let userID = "abcdef-123453-cbdhe" | ||
let userID: Identifier = "abcdef-123453-cbdhe" | ||
let accessToken = "IMPLICIT-GRANT-ACCESS-TOKEN" | ||
fakeTokenManager.accessTokenToReturn = accessToken | ||
let user = OAuthUser(userID: userID, username: "luke", emailAddress: "[email protected]", password: "obiwan".makeBytes()) | ||
let user = OAuthUser(id: userID, username: "luke", emailAddress: "[email protected]", password: "obiwan".makeBytes()) | ||
_ = try getImplicitGrantResponse(user: user) | ||
|
||
guard let token = fakeTokenManager.getAccessToken(accessToken) else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import OAuth | |
import Vapor | ||
import Cookies | ||
import Sessions | ||
import Node | ||
|
||
class TestDataBuilder | ||
{ | ||
|
@@ -171,8 +172,8 @@ class TestDataBuilder | |
return try drop.respond(to: authRequest) | ||
} | ||
|
||
static let anyUserID = "12345-asbdsadi" | ||
static let anyUserID: Identifier = "12345-asbdsadi" | ||
static func anyOAuthUser() -> OAuthUser { | ||
return OAuthUser(userID: TestDataBuilder.anyUserID, username: "hansolo", emailAddress: "[email protected]", password: "leia".makeBytes()) | ||
return OAuthUser(id: TestDataBuilder.anyUserID, username: "hansolo", emailAddress: "[email protected]", password: "leia".makeBytes()) | ||
} | ||
} |
Oops, something went wrong.