Skip to content

Commit

Permalink
feat(auth): Add Password Policies support in Project and Tenant config (
Browse files Browse the repository at this point in the history
#2107)

* Password Policy Tenant and Project Changes
- Config changes
- Basic integration tests
- Basic unit tests

* Adding unit tests for PasswordPolicyAuthConfig
+ Comment for PasswordPolicyEnforcementState type

* Adding Project Config Unit Tests

* Tenant Unit Tests

* Lint fixes

* `npm run api-extractor:local` changes

* 1. `npm run api-extractor:local` changes
2. Documentation for some PasswordPolicyConfig interfaces/methods

* Revert formatting changes

* Lint changes

* Line break lint changes

* `eslint --fix .` fixes

* 1. Changing type of passwordPolicies to PasswordPolicyConfig on Tenant and ProjectConfig
2. Removing toJSON() method from PasswordPolicyAuthConfig
3. Marking PasswordPolicyAuthConfig as `internal`

* Minor changes

* Changes with approved config

* Undo package-lock.json changes

* Undo package-lock.json changes

* Undo package-lock.json changes

* Update package-lock.json

* Lint fixes

* Cleanup

* Revert package-lock.json

* Update project-config.ts

* Minor formatting

* Descriptive constants

* Lint fixes

* Fix import

* Update test/integration/auth.spec.ts

Co-authored-by: Lahiru Maramba <llahiru@gmail.com>

* Apply suggestions from code review

Co-authored-by: Lahiru Maramba <llahiru@gmail.com>

* Apply suggestions from code review

Co-authored-by: Kevin Cheung <kevinthecheung@users.noreply.github.com>

* Integration tests fix

* Small fix

* Reset password policy in integration tests to prevent breaking changes

* lint fix

* package-lock.json undo changes

* update merge

* lint fixes

* merge fixes

* Update package-lock.json

* Update package.json

* Allow enforcementState `OFF` with default constraints

* Lint fixes

* Adding recaptcha to server request

* Fill default passwordPolicyVersions values

* Lint fix

* remove debug logging

---------

Co-authored-by: Lahiru Maramba <llahiru@gmail.com>
Co-authored-by: Kevin Cheung <kevinthecheung@users.noreply.github.com>
  • Loading branch information
3 people committed May 24, 2023
1 parent ce6b13c commit c87f8a5
Show file tree
Hide file tree
Showing 9 changed files with 1,209 additions and 148 deletions.
24 changes: 24 additions & 0 deletions etc/firebase-admin.auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ export interface CreateRequest extends UpdateRequest {
// @public
export type CreateTenantRequest = UpdateTenantRequest;

// @public
export interface CustomStrengthOptionsConfig {
maxLength?: number;
minLength?: number;
requireLowercase?: boolean;
requireNonAlphanumeric?: boolean;
requireNumeric?: boolean;
requireUppercase?: boolean;
}

// @alpha (undocumented)
export interface DecodedAuthBlockingToken {
// (undocumented)
Expand Down Expand Up @@ -329,6 +339,16 @@ export interface OIDCUpdateAuthProviderRequest {
responseType?: OAuthResponseType;
}

// @public
export interface PasswordPolicyConfig {
constraints?: CustomStrengthOptionsConfig;
enforcementState?: PasswordPolicyEnforcementState;
forceUpgradeOnSignin?: boolean;
}

// @public
export type PasswordPolicyEnforcementState = 'ENFORCE' | 'OFF';

// @public
export interface PhoneIdentifier {
// (undocumented)
Expand All @@ -344,6 +364,7 @@ export class PhoneMultiFactorInfo extends MultiFactorInfo {
// @public
export class ProjectConfig {
get multiFactorConfig(): MultiFactorConfig | undefined;
readonly passwordPolicyConfig?: PasswordPolicyConfig;
get recaptchaConfig(): RecaptchaConfig | undefined;
readonly smsRegionConfig?: SmsRegionConfig;
toJSON(): object;
Expand Down Expand Up @@ -427,6 +448,7 @@ export class Tenant {
readonly displayName?: string;
get emailSignInConfig(): EmailSignInProviderConfig | undefined;
get multiFactorConfig(): MultiFactorConfig | undefined;
readonly passwordPolicyConfig?: PasswordPolicyConfig;
get recaptchaConfig(): RecaptchaConfig | undefined;
readonly smsRegionConfig?: SmsRegionConfig;
readonly tenantId: string;
Expand Down Expand Up @@ -479,6 +501,7 @@ export interface UpdatePhoneMultiFactorInfoRequest extends BaseUpdateMultiFactor
// @public
export interface UpdateProjectConfigRequest {
multiFactorConfig?: MultiFactorConfig;
passwordPolicyConfig?: PasswordPolicyConfig;
recaptchaConfig?: RecaptchaConfig;
smsRegionConfig?: SmsRegionConfig;
}
Expand All @@ -503,6 +526,7 @@ export interface UpdateTenantRequest {
displayName?: string;
emailSignInConfig?: EmailSignInProviderConfig;
multiFactorConfig?: MultiFactorConfig;
passwordPolicyConfig?: PasswordPolicyConfig;
recaptchaConfig?: RecaptchaConfig;
smsRegionConfig?: SmsRegionConfig;
testPhoneNumbers?: {
Expand Down
Loading

0 comments on commit c87f8a5

Please sign in to comment.