Skip to content
v2.273.0

BasicAuth Class ​

Basic Auth configuration.

Example ​

ts
const amplifyApp = new amplify.App(this, 'MyApp', {
  sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
    owner: '<user>',
    repository: '<repo>',
    oauthToken: SecretValue.secretsManager('my-github-token'),
  }),
  basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'),
});
python
amplify_app = amplify.App(self, "MyApp",
    source_code_provider=amplify.GitHubSourceCodeProvider(
        owner="<user>",
        repository="<repo>",
        oauth_token=SecretValue.secrets_manager("my-github-token")
    ),
    basic_auth=amplify.BasicAuth.from_generated_password("username")
)
java
App amplifyApp = App.Builder.create(this, "MyApp")
        .sourceCodeProvider(GitHubSourceCodeProvider.Builder.create()
                .owner("<user>")
                .repository("<repo>")
                .oauthToken(SecretValue.secretsManager("my-github-token"))
                .build())
        .basicAuth(BasicAuth.fromGeneratedPassword("username"))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
var amplifyApp = new App(this, "MyApp", new AppProps {
    SourceCodeProvider = new GitHubSourceCodeProvider(new GitHubSourceCodeProviderProps {
        Owner = "<user>",
        Repository = "<repo>",
        OauthToken = SecretValue.SecretsManager("my-github-token")
    }),
    BasicAuth = BasicAuth.FromGeneratedPassword("username")
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
amplifyApp := amplify.NewApp(this, jsii.String("MyApp"), &AppProps{
	SourceCodeProvider: amplify.NewGitHubSourceCodeProvider(&GitHubSourceCodeProviderProps{
		Owner: jsii.String("<user>"),
		Repository: jsii.String("<repo>"),
		OauthToken: awscdk.SecretValue_SecretsManager(jsii.String("my-github-token")),
	}),
	BasicAuth: amplify.BasicAuth_FromGeneratedPassword(jsii.String("username")),
})

Initializer ​

ts
new BasicAuth(props: BasicAuthProps)
python
BasicAuth(props: BasicAuthProps)
java
new BasicAuth(BasicAuthProps props)
csharp
new BasicAuth(BasicAuthProps props)
go
NewBasicAuth(Props BasicAuthProps)

Methods ​

bind(scope: Construct, id: string): BasicAuthConfigdef bind(self, scope: Construct, id: str) -> BasicAuthConfigpublic BasicAuthConfig bind(Construct scope, String id)public BasicAuthConfig Bind(Construct scope, string id)func Bind(Scope Construct, Id *string) BasicAuthConfig#
Binds this Basic Auth configuration to an App.
fromCredentials(username: string, password: SecretValue): BasicAuth // chainable@staticmethod def from_credentials(username: str, password: SecretValue) -> BasicAuthpublic static BasicAuth fromCredentials(String username, SecretValue password)public static BasicAuth FromCredentials(string username, SecretValue password)func FromCredentials(Username *string, Password SecretValue) BasicAuthstatic#
Creates a Basic Auth configuration from a username and a password.
2 parameters

Parameters

  • usernameusernameusernameusernameUsername — The username.
  • passwordpasswordpasswordpasswordPassword — The password.
fromGeneratedPassword(username: string, encryptionKey?: IKey): BasicAuth // chainable@staticmethod def from_generated_password(username: str, encryption_key: typing.Optional[IKey] = None) -> BasicAuthpublic static BasicAuth fromGeneratedPassword(String username, IKey encryptionKey)public static BasicAuth FromGeneratedPassword(string username, IKey? encryptionKey = null)func FromGeneratedPassword(Username *string, EncryptionKey IKey) BasicAuthstatic#
Creates a Basic Auth configuration with a password generated in Secrets Manager.
2 parameters

Parameters

  • usernameusernameusernameusernameUsername — The username.
  • encryptionKeyencryption_keyencryptionKeyencryptionKeyEncryptionKey — The encryption key to use to encrypt the password in Secrets Manager.