-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pr/invoke-batch
- Loading branch information
Showing
27 changed files
with
1,151 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ pack/ | |
.tools/ | ||
coverage/ | ||
.nyc_output | ||
.nycrc | ||
.LAST_BUILD | ||
*.sw[a-z] | ||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/@aws-cdk/aws-apigateway/lib/authorizers/identity-source.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* 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. | ||
*/ | ||
export class IdentitySource { | ||
/** | ||
* Provides a properly formatted header identity source. | ||
* @param headerName the name of the header the `IdentitySource` will represent. | ||
* | ||
* @returns a header identity source. | ||
*/ | ||
public static header(headerName: string): string { | ||
return IdentitySource.toString(headerName, 'method.request.header'); | ||
} | ||
|
||
/** | ||
* Provides a properly formatted query string identity source. | ||
* @param queryString the name of the query string the `IdentitySource` will represent. | ||
* | ||
* @returns a query string identity source. | ||
*/ | ||
public static queryString(queryString: string): string { | ||
return IdentitySource.toString(queryString, 'method.request.querystring'); | ||
} | ||
|
||
/** | ||
* Provides a properly formatted API Gateway stage variable identity source. | ||
* @param stageVariable the name of the stage variable the `IdentitySource` will represent. | ||
* | ||
* @returns an API Gateway stage variable identity source. | ||
*/ | ||
public static stageVariable(stageVariable: string): string { | ||
return IdentitySource.toString(stageVariable, 'stageVariables'); | ||
} | ||
|
||
/** | ||
* Provides a properly formatted request context identity source. | ||
* @param context the name of the context variable the `IdentitySource` will represent. | ||
* | ||
* @returns a request context identity source. | ||
*/ | ||
public static context(context: string): string { | ||
return IdentitySource.toString(context, 'context'); | ||
} | ||
|
||
private static toString(source: string, type: string) { | ||
if (!source.trim()) { | ||
throw new Error(`IdentitySources must be a non-empty string.`); | ||
} | ||
|
||
return `${type}.${source}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './lambda'; | ||
export * from './lambda'; | ||
export * from './identity-source'; |
Oops, something went wrong.