-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[AC-1070] Enforce master password policy on login #2714
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
+149
−12
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1db8da1
[EC-1070] Add API endpoint to retrieve all policies for the current user
shane-melton 515564d
[EC-1070] Add MasterPasswordPolicyData model
shane-melton 5a0d36c
[EC-1070] Move PolicyResponseModel to Core project
shane-melton 869045c
[EC-1070] Supply master password polices as a custom identity token r…
shane-melton aec0da7
[EC-1070] Include master password policies in 2FA token response
shane-melton bdfe85a
[EC-1070] Add response model to verify-password endpoint that include…
shane-melton 97bf2db
Merge branch 'master' into EC-1070-expand-master-pass-reqs
shane-melton 63cba51
[AC-1070] Introduce MasterPasswordPolicyResponseModel
shane-melton 1dfa772
[AC-1070] Add policy service method to retrieve a user's master passw…
shane-melton af6795b
[AC-1070] User new policy service method
shane-melton 63f4437
[AC-1070] Cleanup new policy service method
shane-melton b49b100
[AC-1070] Cleanup MasterPasswordPolicy models
shane-melton 3b6566a
[AC-1070] Remove now un-used GET /policies endpoint
shane-melton 207d0ed
[AC-1070] Update policy service method to use GetManyByUserIdAsync
shane-melton 5054498
[AC-1070] Ensure existing value is not null before comparison
shane-melton 9286cdf
[AC-1070] Remove redundant VerifyMasterPasswordResponse model
shane-melton 40a4cb8
[AC-1070] Fix service typo in constructor
shane-melton d5d3fc6
Merge branch 'master' into EC-1070-expand-master-pass-reqs
shane-melton 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
36 changes: 36 additions & 0 deletions
36
src/Core/Models/Api/Response/MasterPasswordPolicyResponseModel.cs
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,36 @@ | ||
| using Bit.Core.Models.Data.Organizations.Policies; | ||
|
|
||
| namespace Bit.Core.Models.Api.Response; | ||
|
|
||
| public class MasterPasswordPolicyResponseModel : ResponseModel | ||
| { | ||
| public MasterPasswordPolicyResponseModel(MasterPasswordPolicyData data) : base("masterPasswordPolicy") | ||
| { | ||
| if (data == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| MinComplexity = data.MinComplexity; | ||
| MinLength = data.MinLength; | ||
| RequireLower = data.RequireLower; | ||
| RequireUpper = data.RequireUpper; | ||
| RequireNumbers = data.RequireNumbers; | ||
| RequireSpecial = data.RequireSpecial; | ||
| EnforceOnLogin = data.EnforceOnLogin; | ||
| } | ||
|
|
||
| public int? MinComplexity { get; set; } | ||
|
|
||
| public int? MinLength { get; set; } | ||
|
|
||
| public bool? RequireLower { get; set; } | ||
|
|
||
| public bool? RequireUpper { get; set; } | ||
|
|
||
| public bool? RequireNumbers { get; set; } | ||
|
|
||
| public bool? RequireSpecial { get; set; } | ||
|
|
||
| public bool? EnforceOnLogin { get; set; } | ||
| } |
3 changes: 1 addition & 2 deletions
3
...pi/Models/Response/PolicyResponseModel.cs → ...odels/Api/Response/PolicyResponseModel.cs
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
40 changes: 40 additions & 0 deletions
40
src/Core/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs
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,40 @@ | ||
| namespace Bit.Core.Models.Data.Organizations.Policies; | ||
|
|
||
| public class MasterPasswordPolicyData : IPolicyDataModel | ||
| { | ||
| public int? MinComplexity { get; set; } | ||
| public int? MinLength { get; set; } | ||
| public bool? RequireLower { get; set; } | ||
| public bool? RequireUpper { get; set; } | ||
| public bool? RequireNumbers { get; set; } | ||
| public bool? RequireSpecial { get; set; } | ||
| public bool? EnforceOnLogin { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Combine the other policy data with this instance, taking the most secure options | ||
| /// </summary> | ||
| /// <param name="other">The other policy instance to combine with this</param> | ||
| public void CombineWith(MasterPasswordPolicyData other) | ||
| { | ||
| if (other == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (other.MinComplexity.HasValue && (!MinComplexity.HasValue || other.MinComplexity > MinComplexity)) | ||
| { | ||
| MinComplexity = other.MinComplexity; | ||
| } | ||
|
|
||
| if (other.MinLength.HasValue && (!MinLength.HasValue || other.MinLength > MinLength)) | ||
| { | ||
| MinLength = other.MinLength; | ||
| } | ||
|
|
||
| RequireLower = (other.RequireLower ?? false) || (RequireLower ?? false); | ||
| RequireUpper = (other.RequireUpper ?? false) || (RequireUpper ?? false); | ||
| RequireNumbers = (other.RequireNumbers ?? false) || (RequireNumbers ?? false); | ||
| RequireSpecial = (other.RequireSpecial ?? false) || (RequireSpecial ?? false); | ||
| EnforceOnLogin = (other.EnforceOnLogin ?? false) || (EnforceOnLogin ?? false); | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| using Bit.Core.Entities; | ||
| using Bit.Core.Models.Data.Organizations.Policies; | ||
|
|
||
| namespace Bit.Core.Services; | ||
|
|
||
| public interface IPolicyService | ||
| { | ||
| Task SaveAsync(Policy policy, IUserService userService, IOrganizationService organizationService, | ||
| Guid? savingUserId); | ||
|
|
||
| /// <summary> | ||
| /// Get the combined master password policy options for the specified user. | ||
| /// </summary> | ||
| Task<MasterPasswordPolicyData> GetMasterPasswordPolicyForUserAsync(User user); | ||
| } |
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
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.