Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/api/Accounts/PasswordPolicy.cs
diff options
context:
space:
mode:
authorLeitwolf112026-10-03 18:46:59 +0300
committerLeitwolf112026-10-03 18:46:59 +0300
commitb84a2216c26cc5392d0dc300b7a605ccb288d8c8 (patch)
tree048ae623f49cc5f2f94234d747351f9e659f5267 /apps/api/Accounts/PasswordPolicy.cs
parentec774db15976385a6d5ea6f48d3622fe507d3843 (diff)
parentcf444eb3bccf99c10f59ed5330b61c0397e0aeaa (diff)
downloadprogmaweb-fix/api-without-google.tar.gz
Merge remote-tracking branch 'origin/main' into fix/api-without-googlefix/api-without-google
Diffstat (limited to 'apps/api/Accounts/PasswordPolicy.cs')
-rw-r--r--apps/api/Accounts/PasswordPolicy.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/api/Accounts/PasswordPolicy.cs b/apps/api/Accounts/PasswordPolicy.cs
index baf8c75..6a5bf38 100644
--- a/apps/api/Accounts/PasswordPolicy.cs
+++ b/apps/api/Accounts/PasswordPolicy.cs
@@ -3,11 +3,22 @@
namespace Progmasoft.Progmaweb.Api.Accounts;
+/// <summary>Rules for passwords.</summary>
+/// <remarks>
+/// Only length is constrained, so long passphrases are welcome. The upper bound keeps hashing cost bounded for a
+/// request that an anonymous caller can send.
+/// </remarks>
internal static class PasswordPolicy
{
+ /// <summary>Fewest characters a password may have.</summary>
public const int MinimumLength = 12;
+ /// <summary>Most characters a password may have.</summary>
public const int MaximumLength = 256;
+ /// <summary>Validates a new password.</summary>
+ /// <param name="password">The password in plain text.</param>
+ /// <param name="error">Message for the user when the password is refused; empty otherwise.</param>
+ /// <returns><see langword="true"/> when the password may be used.</returns>
public static bool TryValidate(string? password, out string error)
{
if (password is null || password.Length < MinimumLength)