# UserPoolIdentityProviderSaml

Represents an identity provider that integrates with SAML.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › [Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Resource.html) › UserPoolIdentityProviderSaml
Implements: [IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResource.html), [IUserPoolIdentityProvider](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.IUserPoolIdentityProvider.html), [IEnvironmentAware](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.IEnvironmentAware.html), IUserPoolIdentityProviderRef, IConstruct, IDependable

- CloudFormation: [`AWS::Cognito::UserPoolIdentityProvider`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-cognito-userpoolidentityprovider.html)
- L1 type: [`CfnUserPoolIdentityProvider`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.CfnUserPoolIdentityProvider.html)
- Source: [`aws-cognito/lib/user-pool-idps/saml.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/saml.ts#L122)
- Type last changed: v2.235.0 · 15 Jan 2026

## Example

TypeScript:

```ts
const userpool = new cognito.UserPool(this, 'Pool');

// specify the metadata as a file content
new cognito.UserPoolIdentityProviderSaml(this, 'userpoolIdpFile', {
  userPool: userpool,
  metadata: cognito.UserPoolIdentityProviderSamlMetadata.file('my-file-contents'),
  // Whether to require encrypted SAML assertions from IdP
  encryptedResponses: true,
  // The signing algorithm for the SAML requests
  requestSigningAlgorithm: cognito.SigningAlgorithm.RSA_SHA256,
  // Enable IdP initiated SAML auth flow
  idpInitiated: true,
});

// specify the metadata as a URL
new cognito.UserPoolIdentityProviderSaml(this, 'userpoolidpUrl', {
  userPool: userpool,
  metadata: cognito.UserPoolIdentityProviderSamlMetadata.url('https://my-metadata-url.com'),
});
```

Python:

```python
userpool = cognito.UserPool(self, "Pool")

# specify the metadata as a file content
cognito.UserPoolIdentityProviderSaml(self, "userpoolIdpFile",
    user_pool=userpool,
    metadata=cognito.UserPoolIdentityProviderSamlMetadata.file("my-file-contents"),
    # Whether to require encrypted SAML assertions from IdP
    encrypted_responses=True,
    # The signing algorithm for the SAML requests
    request_signing_algorithm=cognito.SigningAlgorithm.RSA_SHA256,
    # Enable IdP initiated SAML auth flow
    idp_initiated=True
)

# specify the metadata as a URL
cognito.UserPoolIdentityProviderSaml(self, "userpoolidpUrl",
    user_pool=userpool,
    metadata=cognito.UserPoolIdentityProviderSamlMetadata.url("https://my-metadata-url.com")
)
```

Java:

```java
UserPool userpool = new UserPool(this, "Pool");

// specify the metadata as a file content
// specify the metadata as a file content
UserPoolIdentityProviderSaml.Builder.create(this, "userpoolIdpFile")
        .userPool(userpool)
        .metadata(UserPoolIdentityProviderSamlMetadata.file("my-file-contents"))
        // Whether to require encrypted SAML assertions from IdP
        .encryptedResponses(true)
        // The signing algorithm for the SAML requests
        .requestSigningAlgorithm(SigningAlgorithm.RSA_SHA256)
        // Enable IdP initiated SAML auth flow
        .idpInitiated(true)
        .build();

// specify the metadata as a URL
// specify the metadata as a URL
UserPoolIdentityProviderSaml.Builder.create(this, "userpoolidpUrl")
        .userPool(userpool)
        .metadata(UserPoolIdentityProviderSamlMetadata.url("https://my-metadata-url.com"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var userpool = new UserPool(this, "Pool");

// specify the metadata as a file content
// specify the metadata as a file content
new UserPoolIdentityProviderSaml(this, "userpoolIdpFile", new UserPoolIdentityProviderSamlProps {
    UserPool = userpool,
    Metadata = UserPoolIdentityProviderSamlMetadata.File("my-file-contents"),
    // Whether to require encrypted SAML assertions from IdP
    EncryptedResponses = true,
    // The signing algorithm for the SAML requests
    RequestSigningAlgorithm = SigningAlgorithm.RSA_SHA256,
    // Enable IdP initiated SAML auth flow
    IdpInitiated = true
});

// specify the metadata as a URL
// specify the metadata as a URL
new UserPoolIdentityProviderSaml(this, "userpoolidpUrl", new UserPoolIdentityProviderSamlProps {
    UserPool = userpool,
    Metadata = UserPoolIdentityProviderSamlMetadata.Url("https://my-metadata-url.com")
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
userpool := cognito.NewUserPool(this, jsii.String("Pool"))

// specify the metadata as a file content
// specify the metadata as a file content
cognito.NewUserPoolIdentityProviderSaml(this, jsii.String("userpoolIdpFile"), &UserPoolIdentityProviderSamlProps{
	UserPool: userpool,
	Metadata: cognito.UserPoolIdentityProviderSamlMetadata_File(jsii.String("my-file-contents")),
	// Whether to require encrypted SAML assertions from IdP
	EncryptedResponses: jsii.Boolean(true),
	// The signing algorithm for the SAML requests
	RequestSigningAlgorithm: cognito.SigningAlgorithm_RSA_SHA256,
	// Enable IdP initiated SAML auth flow
	IdpInitiated: jsii.Boolean(true),
})

// specify the metadata as a URL
// specify the metadata as a URL
cognito.NewUserPoolIdentityProviderSaml(this, jsii.String("userpoolidpUrl"), &UserPoolIdentityProviderSamlProps{
	UserPool: userpool,
	Metadata: cognito.UserPoolIdentityProviderSamlMetadata_Url(jsii.String("https://my-metadata-url.com")),
})
```

## Initializer

TypeScript:

```ts
new UserPoolIdentityProviderSaml(scope: Construct, id: string, props: UserPoolIdentityProviderSamlProps)
```

Python:

```python
UserPoolIdentityProviderSaml(scope: Construct, id: str, props: UserPoolIdentityProviderSamlProps)
```

Java:

```java
new UserPoolIdentityProviderSaml(Construct scope, String id, UserPoolIdentityProviderSamlProps props)
```

C# / .NET:

```csharp
new UserPoolIdentityProviderSaml(Construct scope, string id, UserPoolIdentityProviderSamlProps props)
```

Golang:

```go
NewUserPoolIdentityProviderSaml(Scope Construct, Id *string, Props UserPoolIdentityProviderSamlProps)
```

## Construct Props

- `attributeMapping`: [AttributeMapping](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.AttributeMapping.html) — Mapping attributes from the identity provider to standard and custom attributes of the user pool.

  **Default:** no attribute mapping

- `encryptedResponses`: boolean = false — Whether to require encrypted SAML assertions from IdP.

- `identifiers`: string[] — Identifiers.

  **Default:** no identifiers used

  Identifiers can be used to redirect users to the correct IdP in multitenant apps.

- `idpInitiated`: boolean = false — Whether to enable IdP-initiated SAML auth flows.

- `idpSignout`: boolean = false — Whether to enable the "Sign-out flow" feature.

- `metadata`: [UserPoolIdentityProviderSamlMetadata](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPoolIdentityProviderSamlMetadata.html) (required) — The SAML metadata.

- `name`: string — The name of the provider.

  **Default:** the unique ID of the construct

  Must be between 3 and 32 characters.

- `requestSigningAlgorithm`: [SigningAlgorithm](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.SigningAlgorithm.html) — The signing algorithm for SAML requests.

  **Default:** don't sign requests

- `userPool`: [IUserPool](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.IUserPool.html) (required) — The user pool to which this construct provides identities.

## Properties

- `env`: [ResourceEnvironment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `providerName`: string — The primary identifier of this identity provider.

- `stack`: [Stack](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

- `userPoolIdentityProviderRef`: [UserPoolIdentityProviderReference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_cognito.UserPoolIdentityProviderReference.html) — A reference to a UserPoolIdentityProvider resource.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
