io.cloudshiftdev.awscdk.services.cognito.PasswordPolicy.kt Maven / Gradle / Ivy
The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package io.cloudshiftdev.awscdk.services.cognito
import io.cloudshiftdev.awscdk.Duration
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.Boolean
import kotlin.Number
import kotlin.Unit
/**
* Password policy for User Pools.
*
* Example:
*
* ```
* UserPool.Builder.create(this, "myuserpool")
* // ...
* .passwordPolicy(PasswordPolicy.builder()
* .minLength(12)
* .requireLowercase(true)
* .requireUppercase(true)
* .requireDigits(true)
* .requireSymbols(true)
* .tempPasswordValidity(Duration.days(3))
* .build())
* .build();
* ```
*/
public interface PasswordPolicy {
/**
* Minimum length required for a user's password.
*
* Default: 8
*/
public fun minLength(): Number? = unwrap(this).getMinLength()
/**
* Whether the user is required to have digits in their password.
*
* Default: true
*/
public fun requireDigits(): Boolean? = unwrap(this).getRequireDigits()
/**
* Whether the user is required to have lowercase characters in their password.
*
* Default: true
*/
public fun requireLowercase(): Boolean? = unwrap(this).getRequireLowercase()
/**
* Whether the user is required to have symbols in their password.
*
* Default: true
*/
public fun requireSymbols(): Boolean? = unwrap(this).getRequireSymbols()
/**
* Whether the user is required to have uppercase characters in their password.
*
* Default: true
*/
public fun requireUppercase(): Boolean? = unwrap(this).getRequireUppercase()
/**
* The length of time the temporary password generated by an admin is valid.
*
* This must be provided as whole days, like Duration.days(3) or Duration.hours(48).
* Fractional days, such as Duration.hours(20), will generate an error.
*
* Default: Duration.days(7)
*/
public fun tempPasswordValidity(): Duration? =
unwrap(this).getTempPasswordValidity()?.let(Duration::wrap)
/**
* A builder for [PasswordPolicy]
*/
@CdkDslMarker
public interface Builder {
/**
* @param minLength Minimum length required for a user's password.
*/
public fun minLength(minLength: Number)
/**
* @param requireDigits Whether the user is required to have digits in their password.
*/
public fun requireDigits(requireDigits: Boolean)
/**
* @param requireLowercase Whether the user is required to have lowercase characters in their
* password.
*/
public fun requireLowercase(requireLowercase: Boolean)
/**
* @param requireSymbols Whether the user is required to have symbols in their password.
*/
public fun requireSymbols(requireSymbols: Boolean)
/**
* @param requireUppercase Whether the user is required to have uppercase characters in their
* password.
*/
public fun requireUppercase(requireUppercase: Boolean)
/**
* @param tempPasswordValidity The length of time the temporary password generated by an admin
* is valid.
* This must be provided as whole days, like Duration.days(3) or Duration.hours(48).
* Fractional days, such as Duration.hours(20), will generate an error.
*/
public fun tempPasswordValidity(tempPasswordValidity: Duration)
}
private class BuilderImpl : Builder {
private val cdkBuilder: software.amazon.awscdk.services.cognito.PasswordPolicy.Builder =
software.amazon.awscdk.services.cognito.PasswordPolicy.builder()
/**
* @param minLength Minimum length required for a user's password.
*/
override fun minLength(minLength: Number) {
cdkBuilder.minLength(minLength)
}
/**
* @param requireDigits Whether the user is required to have digits in their password.
*/
override fun requireDigits(requireDigits: Boolean) {
cdkBuilder.requireDigits(requireDigits)
}
/**
* @param requireLowercase Whether the user is required to have lowercase characters in their
* password.
*/
override fun requireLowercase(requireLowercase: Boolean) {
cdkBuilder.requireLowercase(requireLowercase)
}
/**
* @param requireSymbols Whether the user is required to have symbols in their password.
*/
override fun requireSymbols(requireSymbols: Boolean) {
cdkBuilder.requireSymbols(requireSymbols)
}
/**
* @param requireUppercase Whether the user is required to have uppercase characters in their
* password.
*/
override fun requireUppercase(requireUppercase: Boolean) {
cdkBuilder.requireUppercase(requireUppercase)
}
/**
* @param tempPasswordValidity The length of time the temporary password generated by an admin
* is valid.
* This must be provided as whole days, like Duration.days(3) or Duration.hours(48).
* Fractional days, such as Duration.hours(20), will generate an error.
*/
override fun tempPasswordValidity(tempPasswordValidity: Duration) {
cdkBuilder.tempPasswordValidity(tempPasswordValidity.let(Duration.Companion::unwrap))
}
public fun build(): software.amazon.awscdk.services.cognito.PasswordPolicy = cdkBuilder.build()
}
private class Wrapper(
cdkObject: software.amazon.awscdk.services.cognito.PasswordPolicy,
) : CdkObject(cdkObject),
PasswordPolicy {
/**
* Minimum length required for a user's password.
*
* Default: 8
*/
override fun minLength(): Number? = unwrap(this).getMinLength()
/**
* Whether the user is required to have digits in their password.
*
* Default: true
*/
override fun requireDigits(): Boolean? = unwrap(this).getRequireDigits()
/**
* Whether the user is required to have lowercase characters in their password.
*
* Default: true
*/
override fun requireLowercase(): Boolean? = unwrap(this).getRequireLowercase()
/**
* Whether the user is required to have symbols in their password.
*
* Default: true
*/
override fun requireSymbols(): Boolean? = unwrap(this).getRequireSymbols()
/**
* Whether the user is required to have uppercase characters in their password.
*
* Default: true
*/
override fun requireUppercase(): Boolean? = unwrap(this).getRequireUppercase()
/**
* The length of time the temporary password generated by an admin is valid.
*
* This must be provided as whole days, like Duration.days(3) or Duration.hours(48).
* Fractional days, such as Duration.hours(20), will generate an error.
*
* Default: Duration.days(7)
*/
override fun tempPasswordValidity(): Duration? =
unwrap(this).getTempPasswordValidity()?.let(Duration::wrap)
}
public companion object {
public operator fun invoke(block: Builder.() -> Unit = {}): PasswordPolicy {
val builderImpl = BuilderImpl()
return Wrapper(builderImpl.apply(block).build())
}
internal fun wrap(cdkObject: software.amazon.awscdk.services.cognito.PasswordPolicy):
PasswordPolicy = CdkObjectWrappers.wrap(cdkObject) as? PasswordPolicy ?: Wrapper(cdkObject)
internal fun unwrap(wrapped: PasswordPolicy):
software.amazon.awscdk.services.cognito.PasswordPolicy = (wrapped as CdkObject).cdkObject as
software.amazon.awscdk.services.cognito.PasswordPolicy
}
}