Skip to content
v2.275.0

HttpNoneAuthorizer Class ​

Explicitly configure no authorizers on specific HTTP API routes.

Example ​

ts
import { HttpJwtAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
import { HttpUrlIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

const issuer = 'https://test.us.auth0.com';
const authorizer = new HttpJwtAuthorizer('DefaultAuthorizer', issuer, {
  jwtAudience: ['3131231'],
});

const api = new apigwv2.HttpApi(this, 'HttpApi', {
  defaultAuthorizer: authorizer,
  defaultAuthorizationScopes: ['read:books'],
});

api.addRoutes({
  integration: new HttpUrlIntegration('BooksIntegration', 'https://get-books-proxy.example.com'),
  path: '/books',
  methods: [apigwv2.HttpMethod.GET],
});

api.addRoutes({
  integration: new HttpUrlIntegration('BooksIdIntegration', 'https://get-books-proxy.example.com'),
  path: '/books/{id}',
  methods: [apigwv2.HttpMethod.GET],
});

api.addRoutes({
  integration: new HttpUrlIntegration('BooksIntegration', 'https://get-books-proxy.example.com'),
  path: '/books',
  methods: [apigwv2.HttpMethod.POST],
  authorizationScopes: ['write:books']
});

api.addRoutes({
  integration: new HttpUrlIntegration('LoginIntegration', 'https://get-books-proxy.example.com'),
  path: '/login',
  methods: [apigwv2.HttpMethod.POST],
  authorizer: new apigwv2.HttpNoneAuthorizer(),
});
python
from aws_cdk.aws_apigatewayv2_authorizers import HttpJwtAuthorizer
from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration


issuer = "https://test.us.auth0.com"
authorizer = HttpJwtAuthorizer("DefaultAuthorizer", issuer,
    jwt_audience=["3131231"]
)

api = apigwv2.HttpApi(self, "HttpApi",
    default_authorizer=authorizer,
    default_authorization_scopes=["read:books"]
)

api.add_routes(
    integration=HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"),
    path="/books",
    methods=[apigwv2.HttpMethod.GET]
)

api.add_routes(
    integration=HttpUrlIntegration("BooksIdIntegration", "https://get-books-proxy.example.com"),
    path="/books/{id}",
    methods=[apigwv2.HttpMethod.GET]
)

api.add_routes(
    integration=HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"),
    path="/books",
    methods=[apigwv2.HttpMethod.POST],
    authorization_scopes=["write:books"]
)

api.add_routes(
    integration=HttpUrlIntegration("LoginIntegration", "https://get-books-proxy.example.com"),
    path="/login",
    methods=[apigwv2.HttpMethod.POST],
    authorizer=apigwv2.HttpNoneAuthorizer()
)
java
import software.amazon.awscdk.aws_apigatewayv2_authorizers.HttpJwtAuthorizer;
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpUrlIntegration;


String issuer = "https://test.us.auth0.com";
HttpJwtAuthorizer authorizer = HttpJwtAuthorizer.Builder.create("DefaultAuthorizer", issuer)
        .jwtAudience(List.of("3131231"))
        .build();

HttpApi api = HttpApi.Builder.create(this, "HttpApi")
        .defaultAuthorizer(authorizer)
        .defaultAuthorizationScopes(List.of("read:books"))
        .build();

api.addRoutes(AddRoutesOptions.builder()
        .integration(new HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"))
        .path("/books")
        .methods(List.of(HttpMethod.GET))
        .build());

api.addRoutes(AddRoutesOptions.builder()
        .integration(new HttpUrlIntegration("BooksIdIntegration", "https://get-books-proxy.example.com"))
        .path("/books/{id}")
        .methods(List.of(HttpMethod.GET))
        .build());

api.addRoutes(AddRoutesOptions.builder()
        .integration(new HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"))
        .path("/books")
        .methods(List.of(HttpMethod.POST))
        .authorizationScopes(List.of("write:books"))
        .build());

api.addRoutes(AddRoutesOptions.builder()
        .integration(new HttpUrlIntegration("LoginIntegration", "https://get-books-proxy.example.com"))
        .path("/login")
        .methods(List.of(HttpMethod.POST))
        .authorizer(new HttpNoneAuthorizer())
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Authorizers;
using Amazon.CDK.AwsApigatewayv2Integrations;


var issuer = "https://test.us.auth0.com";
var authorizer = new HttpJwtAuthorizer("DefaultAuthorizer", issuer, new HttpJwtAuthorizerProps {
    JwtAudience = new [] { "3131231" }
});

var api = new HttpApi(this, "HttpApi", new HttpApiProps {
    DefaultAuthorizer = authorizer,
    DefaultAuthorizationScopes = new [] { "read:books" }
});

api.AddRoutes(new AddRoutesOptions {
    Integration = new HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"),
    Path = "/books",
    Methods = new [] { HttpMethod.GET }
});

api.AddRoutes(new AddRoutesOptions {
    Integration = new HttpUrlIntegration("BooksIdIntegration", "https://get-books-proxy.example.com"),
    Path = "/books/{id}",
    Methods = new [] { HttpMethod.GET }
});

api.AddRoutes(new AddRoutesOptions {
    Integration = new HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"),
    Path = "/books",
    Methods = new [] { HttpMethod.POST },
    AuthorizationScopes = new [] { "write:books" }
});

api.AddRoutes(new AddRoutesOptions {
    Integration = new HttpUrlIntegration("LoginIntegration", "https://get-books-proxy.example.com"),
    Path = "/login",
    Methods = new [] { HttpMethod.POST },
    Authorizer = new HttpNoneAuthorizer()
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"


issuer := "https://test.us.auth0.com"
authorizer := awscdk.NewHttpJwtAuthorizer(jsii.String("DefaultAuthorizer"), issuer, &HttpJwtAuthorizerProps{
	JwtAudience: []*string{
		jsii.String("3131231"),
	},
})

api := apigwv2.NewHttpApi(this, jsii.String("HttpApi"), &HttpApiProps{
	DefaultAuthorizer: authorizer,
	DefaultAuthorizationScopes: []*string{
		jsii.String("read:books"),
	},
})

api.AddRoutes(&AddRoutesOptions{
	Integration: awscdk.NewHttpUrlIntegration(jsii.String("BooksIntegration"), jsii.String("https://get-books-proxy.example.com")),
	Path: jsii.String("/books"),
	Methods: []HttpMethod{
		apigwv2.HttpMethod_GET,
	},
})

api.AddRoutes(&AddRoutesOptions{
	Integration: awscdk.NewHttpUrlIntegration(jsii.String("BooksIdIntegration"), jsii.String("https://get-books-proxy.example.com")),
	Path: jsii.String("/books/{id}"),
	Methods: []HttpMethod{
		apigwv2.HttpMethod_GET,
	},
})

api.AddRoutes(&AddRoutesOptions{
	Integration: awscdk.NewHttpUrlIntegration(jsii.String("BooksIntegration"), jsii.String("https://get-books-proxy.example.com")),
	Path: jsii.String("/books"),
	Methods: []HttpMethod{
		apigwv2.HttpMethod_POST,
	},
	AuthorizationScopes: []*string{
		jsii.String("write:books"),
	},
})

api.AddRoutes(&AddRoutesOptions{
	Integration: awscdk.NewHttpUrlIntegration(jsii.String("LoginIntegration"), jsii.String("https://get-books-proxy.example.com")),
	Path: jsii.String("/login"),
	Methods: []HttpMethod{
		apigwv2.HttpMethod_POST,
	},
	Authorizer: apigwv2.NewHttpNoneAuthorizer(),
})

Initializer ​

ts
new HttpNoneAuthorizer()
python
HttpNoneAuthorizer()
java
new HttpNoneAuthorizer()
csharp
new HttpNoneAuthorizer()
go
NewHttpNoneAuthorizer()

Properties ​

authorizationTypestringauthorization_typestrauthorizationTypeStringAuthorizationTypestringAuthorizationType*string#
The authorizationType used for IAM Authorizer.

Methods ​

bind(_options: HttpRouteAuthorizerBindOptions): HttpRouteAuthorizerConfigdef bind(self, _options: HttpRouteAuthorizerBindOptions) -> HttpRouteAuthorizerConfigpublic HttpRouteAuthorizerConfig bind(HttpRouteAuthorizerBindOptions _options)public HttpRouteAuthorizerConfig Bind(HttpRouteAuthorizerBindOptions _options)func Bind(_options HttpRouteAuthorizerBindOptions) HttpRouteAuthorizerConfig#
Bind this authorizer to a specified Http route.