Skip to content

Commit

Permalink
Added thunderclient collections, and updated CDK stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushjain358 committed Oct 24, 2023
1 parent ec0a6f8 commit 3fb91f9
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 20 deletions.
37 changes: 17 additions & 20 deletions cdk/src/Cdk/CdkStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s
#region ASP.NET Core API - Lambda functions

// ASP.NET Core API - Lambda function Anonymous Example
var aspnetCoreAnonymousExample = new Function(this, ASPNETCoreWebAPI_AnonymousExample, new FunctionProps
var aspnetCoreAnonymousExample = new Function(this, nameof(ASPNETCoreWebAPI_AnonymousExample), new FunctionProps
{
MemorySize = 512,
Timeout = Duration.Seconds(30),
Expand All @@ -178,7 +178,7 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s
});

// ASP.NET Core API - Lambda function Authentication Example
var aspnetCoreAuthenticationExample = new Function(this, ASPNETCoreWebAPI_AuthenticationExample, new FunctionProps
var aspnetCoreAuthenticationExample = new Function(this, nameof(ASPNETCoreWebAPI_AuthenticationExample), new FunctionProps
{
MemorySize = 512,
Timeout = Duration.Seconds(30),
Expand All @@ -198,7 +198,7 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s
});

// ASP.NET Core API - Lambda function Role Based Authorization Example
var aspnetCoreRoleBasedAuthorizationExample = new Function(this, ASPNETCoreWebAPI_AuthorizationExample, new FunctionProps
var aspnetCoreRoleBasedAuthorizationExample = new Function(this, nameof(ASPNETCoreWebAPI_AuthorizationExample), new FunctionProps
{
MemorySize = 512,
Timeout = Duration.Seconds(30),
Expand All @@ -218,7 +218,7 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s
});

// ASP.NET Core API - Lambda function Custom Scopes Authorization Example
var aspnetCoreCustomScopesAuthorizationExample = new Function(this, ASPNETCoreWebAPI_CustomScopesAuthorizationExample, new FunctionProps
var aspnetCoreCustomScopesAuthorizationExample = new Function(this, nameof(ASPNETCoreWebAPI_CustomScopesAuthorizationExample), new FunctionProps
{
MemorySize = 512,
Timeout = Duration.Seconds(30),
Expand All @@ -242,7 +242,7 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s
#region .NET Core API - Lambda functions

// .NET Core API - Lambda function Anonymous Example
var dotnetCoreAnonymousExample = new Function(this, DotNetCoreAPI_AnonymousExample, new FunctionProps
var dotnetCoreAnonymousExample = new Function(this, nameof(DotNetCoreAPI_AnonymousExample), new FunctionProps
{
MemorySize = 512,
Timeout = Duration.Seconds(30),
Expand All @@ -255,7 +255,7 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s
});

// .NET Core API - Lambda function Authorization example
var dotnetCoreAuthorizationExample = new Function(this, DotNetCoreAPI_AuthorizationExample, new FunctionProps
var dotnetCoreAuthorizationExample = new Function(this, nameof(DotNetCoreAPI_AuthorizationExample), new FunctionProps
{
MemorySize = 512,
Timeout = Duration.Seconds(30),
Expand Down Expand Up @@ -343,24 +343,21 @@ internal CdkStack(Construct scope, string id, IStackProps props = null) : base(s

dotnetResourceRoute
.AddResource("anonymous-example")
.AddProxy(new ProxyResourceOptions
.AddMethod("ANY", new LambdaIntegration(dotnetCoreAnonymousExample, new LambdaIntegrationOptions
{
AnyMethod = true,
DefaultIntegration = new LambdaIntegration(dotnetCoreAnonymousExample)
});

Proxy = true
}));

dotnetResourceRoute
.AddResource("authorization-example")
.AddProxy(new ProxyResourceOptions
.AddResource("authorization-example")
.AddMethod("ANY", new LambdaIntegration(dotnetCoreAuthorizationExample, new LambdaIntegrationOptions
{
Proxy = true
}),
new MethodOptions
{
AnyMethod = true,
DefaultIntegration = new LambdaIntegration(dotnetCoreAuthorizationExample),
DefaultMethodOptions = new MethodOptions
{
AuthorizationType = AuthorizationType.COGNITO,
Authorizer = authorizer,
}
AuthorizationType = AuthorizationType.COGNITO,
Authorizer = authorizer,
});

#endregion
Expand Down
165 changes: 165 additions & 0 deletions thunder-client/thunder-collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"client": "Thunder Client",
"collectionName": "Serverless APIs with Cognito",
"dateExported": "2023-10-24T08:09:56.900Z",
"version": "1.1",
"folders": [
{
"_id": "9a5020d1-4fd6-4967-bba5-1f4bb17e55dd",
"name": "ASP.NET Core",
"containerId": "",
"created": "2023-10-11T17:49:19.433Z",
"sortNum": 10000
},
{
"_id": "7bb8c720-861e-48cb-a05a-fbabc0120f16",
"name": ".NET Core",
"containerId": "",
"created": "2023-10-11T17:49:19.434Z",
"sortNum": 20000
}
],
"requests": [
{
"_id": "eaae0675-9117-41ed-baf0-9eb8fe716363",
"colId": "325244ca-64a5-486c-aa3c-502fe8f39e39",
"containerId": "9a5020d1-4fd6-4967-bba5-1f4bb17e55dd",
"name": "Anonymous example",
"url": "{{api_gateway_base_url}}/aspnet/anonymous-example/WeatherForecast",
"method": "GET",
"sortNum": 5000,
"created": "2023-10-11T17:49:19.434Z",
"modified": "2023-10-24T07:37:59.392Z",
"headers": [],
"params": [],
"auth": {
"type": "none"
},
"tests": []
},
{
"_id": "1ef8d93b-7d71-497b-b062-bb8ed87d2bae",
"colId": "325244ca-64a5-486c-aa3c-502fe8f39e39",
"containerId": "9a5020d1-4fd6-4967-bba5-1f4bb17e55dd",
"name": "Authentication example",
"url": "{{api_gateway_base_url}}/aspnet/authentication-example/Profile",
"method": "GET",
"sortNum": 10000,
"created": "2023-10-11T17:49:19.433Z",
"modified": "2023-10-24T07:38:06.237Z",
"headers": [],
"params": [],
"auth": {
"type": "oauth2",
"oauth2": {
"grantType": "authorization_code",
"authUrl": "{{cognito_domain_url}}/oauth2/authorize",
"tokenUrl": "{{cognito_domain_url}}/oauth2/token",
"clientId": "{{client_id}}",
"clientSecret": "{{client_secret}}",
"clientAuth": "in-header",
"scope": "{{basic_scopes}}",
"tokenName": "id_token"
}
},
"tests": []
},
{
"_id": "e65dd62d-4019-4837-9ba1-a4d63c02e308",
"colId": "325244ca-64a5-486c-aa3c-502fe8f39e39",
"containerId": "7bb8c720-861e-48cb-a05a-fbabc0120f16",
"name": "Anonymous example",
"url": "{{api_gateway_base_url}}/dotnet/anonymous-example",
"method": "GET",
"sortNum": 10000,
"created": "2023-10-11T17:49:19.437Z",
"modified": "2023-10-24T08:06:16.130Z",
"headers": [],
"params": [],
"auth": {
"type": "none"
},
"tests": []
},
{
"_id": "f2aafc4f-8fa2-47db-95a3-291ea026b0f5",
"colId": "325244ca-64a5-486c-aa3c-502fe8f39e39",
"containerId": "9a5020d1-4fd6-4967-bba5-1f4bb17e55dd",
"name": "RBAC Authorization example",
"url": "{{api_gateway_base_url}}/aspnet/authorization-example/Admin",
"method": "GET",
"sortNum": 20000,
"created": "2023-10-11T17:49:19.435Z",
"modified": "2023-10-24T08:01:31.534Z",
"headers": [],
"params": [],
"auth": {
"type": "oauth2",
"oauth2": {
"grantType": "authorization_code",
"authUrl": "{{cognito_domain_url}}/oauth2/authorize",
"tokenUrl": "{{cognito_domain_url}}/oauth2/token",
"clientId": "{{client_id}}",
"clientSecret": "{{client_secret}}",
"clientAuth": "in-header",
"scope": "{{basic_scopes}}",
"tokenName": "id_token"
}
},
"tests": []
},
{
"_id": "c2f69c46-2aca-44f3-92f8-5c29cc520a92",
"colId": "325244ca-64a5-486c-aa3c-502fe8f39e39",
"containerId": "7bb8c720-861e-48cb-a05a-fbabc0120f16",
"name": "Authorization example",
"url": "{{api_gateway_base_url}}/dotnet/authorization-example",
"method": "GET",
"sortNum": 20000,
"created": "2023-10-11T17:49:19.438Z",
"modified": "2023-10-24T08:05:31.650Z",
"headers": [],
"params": [],
"auth": {
"type": "oauth2",
"oauth2": {
"grantType": "authorization_code",
"authUrl": "{{cognito_domain_url}}/oauth2/authorize",
"tokenUrl": "{{cognito_domain_url}}/oauth2/token",
"clientId": "{{client_id}}",
"clientSecret": "{{client_secret}}",
"clientAuth": "in-header",
"scope": "{{basic_scopes}}",
"tokenName": "id_token"
}
},
"tests": []
},
{
"_id": "895e6287-2df1-4790-862a-cdd1f94d90e5",
"colId": "325244ca-64a5-486c-aa3c-502fe8f39e39",
"containerId": "9a5020d1-4fd6-4967-bba5-1f4bb17e55dd",
"name": "Custom Scopes Authorization example",
"url": "{{api_gateway_base_url}}/aspnet/custom-scopes-authorization-example/Photo",
"method": "POST",
"sortNum": 30000,
"created": "2023-10-11T17:49:19.436Z",
"modified": "2023-10-24T07:38:12.841Z",
"headers": [],
"params": [],
"auth": {
"type": "oauth2",
"oauth2": {
"grantType": "authorization_code",
"authUrl": "{{cognito_domain_url}}/oauth2/authorize",
"tokenUrl": "{{cognito_domain_url}}/oauth2/token",
"clientId": "{{client_id}}",
"clientSecret": "{{client_secret}}",
"clientAuth": "in-header",
"scope": "{{advanced_scopes}}"
}
},
"tests": []
}
]
}
32 changes: 32 additions & 0 deletions thunder-client/thunder-environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"client": "Thunder Client",
"environmentName": "Serverless APIs with Cognito",
"dateExported": "2023-10-24T08:10:21.623Z",
"version": "1.0",
"variables": [
{
"name": "cognito_domain_url",
"value": "https://ankushjain.auth.ap-south-1.amazoncognito.com"
},
{
"name": "client_id",
"value": "5j3rdv8rip1a8c8n79s89dd7gj"
},
{
"name": "client_secret",
"value": "1fl6575s4m67p9qj9jgorb56415n0ur915lp5tva5880flbfk952"
},
{
"name": "basic_scopes",
"value": "openid+profile"
},
{
"name": "advanced_scopes",
"value": "openid+profile+com.example.photos/basic+com.example.photos/read+com.example.photos/write"
},
{
"name": "api_gateway_base_url",
"value": "https://v5ebvuio03.execute-api.ap-south-1.amazonaws.com/prod"
}
]
}

0 comments on commit 3fb91f9

Please sign in to comment.