-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nevissecurity/feature/NEVISACCESSAPP-5973-…
…password-policy NEVISACCESSAPP-5973: Added simple password policy requiring a password to be longer than 6 characters.
- Loading branch information
Showing
9 changed files
with
104 additions
and
36 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,7 +1,7 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'cocoapods', '~> 1.15.2' | ||
gem 'fastlane', '~> 2.219' | ||
gem 'fastlane', '~> 2.221' | ||
|
||
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') | ||
eval_gemfile(plugins_path) if File.exist?(plugins_path) |
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
42 changes: 42 additions & 0 deletions
42
NevisExampleApp/Utility/Validation/PasswordPolicyImpl.swift
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Nevis Mobile Authentication SDK Example App | ||
// | ||
// Copyright © 2024 Nevis Security AG. All rights reserved. | ||
// | ||
|
||
import NevisMobileAuthentication | ||
|
||
/// Implementation of the ``PasswordPolicy``. | ||
/// This policy validates the password entered by the user during registration or password changing, | ||
/// and allows only passwords longer than 6 characters. | ||
final class PasswordPolicyImpl {} | ||
|
||
// MARK: PasswordPolicy | ||
|
||
extension PasswordPolicyImpl: PasswordPolicy { | ||
func validatePasswordForEnrollment(_ password: String, onSuccess: @escaping () -> (), onError: @escaping (PasswordEnrollmentValidationError) -> ()) { | ||
guard isValid(password) else { | ||
return onError(.InvalidPassword(message: errorMessage)) | ||
} | ||
onSuccess() | ||
} | ||
|
||
func validatePasswordForPasswordChange(_ password: String, onSuccess: @escaping () -> (), onError: @escaping (PasswordChangeValidationError) -> ()) { | ||
guard isValid(password) else { | ||
return onError(.InvalidPassword(message: errorMessage)) | ||
} | ||
onSuccess() | ||
} | ||
} | ||
|
||
// MARK: - Private extension | ||
|
||
private extension PasswordPolicyImpl { | ||
var errorMessage: String { | ||
"The password must be more than 6 characters." | ||
} | ||
|
||
func isValid(_ password: String) -> Bool { | ||
password.trimmingCharacters(in: .whitespacesAndNewlines).count >= 6 | ||
} | ||
} |