-
Notifications
You must be signed in to change notification settings - Fork 67
SWIFT-593 Add auth variants to Evergreen, enable auth DNS seedlist tests #401
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /// Represents an authentication credential. | ||
| internal struct Credential: Decodable, Equatable { | ||
| /// A string containing the username. For auth mechanisms that do not utilize a password, this may be the entire | ||
| /// `userinfo` token from the connection string. | ||
| internal let username: String? | ||
| /// A string containing the password. | ||
| internal let password: String? | ||
| /// A string containing the authentication database. | ||
| internal let source: String? | ||
| /// The authentication mechanism. A nil value for this property indicates that a mechanism wasn't specified and | ||
| /// that mechanism negotiation is required. | ||
| internal let mechanism: AuthMechanism? | ||
| /// A document containing mechanism-specific properties. | ||
| internal let mechanismProperties: Document? | ||
|
|
||
| private enum CodingKeys: String, CodingKey { | ||
| case username, password, source, mechanism, mechanismProperties = "mechanism_properties" | ||
| } | ||
|
|
||
| // TODO: SWIFT-636: remove this initializer and the one below it. | ||
| internal init(from decoder: Decoder) throws { | ||
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
| self.username = try container.decodeIfPresent(String.self, forKey: .username) | ||
| self.password = try container.decodeIfPresent(String.self, forKey: .password) | ||
| self.source = try container.decodeIfPresent(String.self, forKey: .source) | ||
| self.mechanism = try container.decodeIfPresent(AuthMechanism.self, forKey: .mechanism) | ||
|
|
||
| // libmongoc does not return the service name if it's the default, but it is contained in the spec test files, | ||
| // so filter it out here if it's present. | ||
| let properties = try container.decodeIfPresent(Document.self, forKey: .mechanismProperties) | ||
| let filteredProperties = properties?.filter { !($0.0 == "SERVICE_NAME" && $0.1 == "mongodb") } | ||
| // if SERVICE_NAME was the only key then don't return an empty document. | ||
| if filteredProperties?.isEmpty == true { | ||
| self.mechanismProperties = nil | ||
| } else { | ||
| self.mechanismProperties = filteredProperties | ||
| } | ||
| } | ||
|
|
||
| internal init( | ||
| username: String?, | ||
| password: String?, | ||
| source: String?, | ||
| mechanism: AuthMechanism?, | ||
| mechanismProperties: Document? | ||
| ) { | ||
| self.mechanism = mechanism | ||
| self.mechanismProperties = mechanismProperties | ||
| self.password = password | ||
| self.source = source | ||
| self.username = username | ||
| } | ||
| } | ||
|
|
||
| /// Possible authentication mechanisms. | ||
| internal enum AuthMechanism: String, Decodable { | ||
| case scramSHA1 = "SCRAM-SHA-1" | ||
| case scramSHA256 = "SCRAM-SHA-256" | ||
| case gssAPI = "GSSAPI" | ||
| case mongodbCR = "MONGODB-CR" | ||
| case mongodbX509 = "MONGODB-X509" | ||
| case plain = "PLAIN" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.