# NamespaceAuthConfig

Authorization configuration for the Channel Namespace.

- Source: [`aws-appsync/lib/channel-namespace.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-appsync/lib/channel-namespace.ts#L35)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

TypeScript:

```ts
declare const api: appsync.EventApi;

new appsync.ChannelNamespace(this, 'Namespace', {
  api,
  authorizationConfig: {
    // Override publishing authorization to API Key
    publishAuthModeTypes: [appsync.AppSyncAuthorizationType.API_KEY],
    // Override subscribing authorization to Lambda
    subscribeAuthModeTypes: [appsync.AppSyncAuthorizationType.LAMBDA],
  },
});
```

Python:

```python
# api: appsync.EventApi

appsync.ChannelNamespace(self, "Namespace",
    api=api,
    authorization_config=appsync.NamespaceAuthConfig(
        # Override publishing authorization to API Key
        publish_auth_mode_types=[appsync.AppSyncAuthorizationType.API_KEY],
        # Override subscribing authorization to Lambda
        subscribe_auth_mode_types=[appsync.AppSyncAuthorizationType.LAMBDA]
    )
)
```

Java:

```java
EventApi api;

ChannelNamespace.Builder.create(this, "Namespace")
        .api(api)
        .authorizationConfig(NamespaceAuthConfig.builder()
                // Override publishing authorization to API Key
                .publishAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
                // Override subscribing authorization to Lambda
                .subscribeAuthModeTypes(List.of(AppSyncAuthorizationType.LAMBDA))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
EventApi api;

new ChannelNamespace(this, "Namespace", new ChannelNamespaceProps {
    Api = api,
    AuthorizationConfig = new NamespaceAuthConfig {
        // Override publishing authorization to API Key
        PublishAuthModeTypes = new [] { AppSyncAuthorizationType.API_KEY },
        // Override subscribing authorization to Lambda
        SubscribeAuthModeTypes = new [] { AppSyncAuthorizationType.LAMBDA }
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var api EventApi

appsync.NewChannelNamespace(this, jsii.String("Namespace"), &ChannelNamespaceProps{
	Api: Api,
	AuthorizationConfig: &NamespaceAuthConfig{
		// Override publishing authorization to API Key
		PublishAuthModeTypes: []AppSyncAuthorizationType{
			appsync.AppSyncAuthorizationType_API_KEY,
		},
		// Override subscribing authorization to Lambda
		SubscribeAuthModeTypes: []AppSyncAuthorizationType{
			appsync.AppSyncAuthorizationType_LAMBDA,
		},
	},
})
```

## Properties

- `publishAuthModeTypes`: [AppSyncAuthorizationType](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncAuthorizationType.html)[] — The publish auth modes for this Event Api.

  **Default:** API Key authorization

- `subscribeAuthModeTypes`: [AppSyncAuthorizationType](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncAuthorizationType.html)[] — The subscribe auth modes for this Event Api.

  **Default:** API Key authorization
