IdentitySource Class
Represents an identity source.
The source can be specified either as a literal value (e.g: Auth) which cannot be blank, or as an unresolved string token.
Example
ts
declare const authFn: lambda.Function;
declare const books: apigateway.Resource;
const auth = new apigateway.RequestAuthorizer(this, 'booksAuthorizer', {
handler: authFn,
identitySources: [apigateway.IdentitySource.header('Authorization')]
});
books.addMethod('GET', new apigateway.HttpIntegration('http://amazon.com'), {
authorizer: auth
});
python
# auth_fn: lambda.Function
# books: apigateway.Resource
auth = apigateway.RequestAuthorizer(self, "booksAuthorizer",
handler=auth_fn,
identity_sources=[apigateway.IdentitySource.header("Authorization")]
)
books.add_method("GET", apigateway.HttpIntegration("http://amazon.com"),
authorizer=auth
)
java
Function authFn;
Resource books;
RequestAuthorizer auth = RequestAuthorizer.Builder.create(this, "booksAuthorizer")
.handler(authFn)
.identitySources(List.of(IdentitySource.header("Authorization")))
.build();
books.addMethod("GET", new HttpIntegration("http://amazon.com"), MethodOptions.builder()
.authorizer(auth)
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Function authFn;
Resource books;
var auth = new RequestAuthorizer(this, "booksAuthorizer", new RequestAuthorizerProps {
Handler = authFn,
IdentitySources = new [] { IdentitySource.Header("Authorization") }
});
books.AddMethod("GET", new HttpIntegration("http://amazon.com"), new MethodOptions {
Authorizer = auth
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var authFn Function
var books Resource
auth := apigateway.NewRequestAuthorizer(this, jsii.String("booksAuthorizer"), &RequestAuthorizerProps{
Handler: authFn,
IdentitySources: []*string{
apigateway.IdentitySource_Header(jsii.String("Authorization")),
},
})
books.AddMethod(jsii.String("GET"), apigateway.NewHttpIntegration(jsii.String("http://amazon.com")), &MethodOptions{
Authorizer: auth,
})
Initializer
ts
new IdentitySource()
python
IdentitySource()
java
new IdentitySource()
csharp
new IdentitySource()
go
NewIdentitySource()
Methods
context(context: string): string@staticmethod def context(context: str) -> strpublic static String context(String context)public static string Context(string context)func Context(Context *string) *stringstatic#Provides a properly formatted request context identity source.
1 parameter · returns
Parameters
contextcontextcontextcontextContext— the name of the context variable theIdentitySourcewill represent.
Returns: a request context identity source.
header(headerName: string): string@staticmethod def header(header_name: str) -> strpublic static String header(String headerName)public static string Header(string headerName)func Header(HeaderName *string) *stringstatic#Provides a properly formatted header identity source.
1 parameter · returns
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header theIdentitySourcewill represent.
Returns: a header identity source.
queryString(queryString: string): string@staticmethod def query_string(query_string: str) -> strpublic static String queryString(String queryString)public static string QueryString(string queryString)func QueryString(QueryString *string) *stringstatic#Provides a properly formatted query string identity source.
1 parameter · returns
Parameters
queryStringquery_stringqueryStringqueryStringQueryString— the name of the query string theIdentitySourcewill represent.
Returns: a query string identity source.
stageVariable(stageVariable: string): string@staticmethod def stage_variable(stage_variable: str) -> strpublic static String stageVariable(String stageVariable)public static string StageVariable(string stageVariable)func StageVariable(StageVariable *string) *stringstatic#Provides a properly formatted API Gateway stage variable identity source.
1 parameter · returns
Parameters
stageVariablestage_variablestageVariablestageVariableStageVariable— the name of the stage variable theIdentitySourcewill represent.
Returns: an API Gateway stage variable identity source.