Sign inSign up

tigerwonghk/dalmarkit-sample-webapi

By tigerwonghk

•Updated 9 months ago

Implementation of ASP.NET Core web API using Dalmarkit https://github.com/tigerwong-hk/Dalmarkit

Image
0

2.4K

tigerwonghk/dalmarkit-sample-webapi repository overview

⁠Dalmarkit-sample-webapi

Sample implementation of a ASP.NET Core web API using Dalmarkit⁠

⁠Prerequisites

  1. AWS IAM user with sufficient permission to:

    1. create user pool in Cognito
    2. create S3 bucket
    3. create CloudFront distribution with S3 bucket as origin
    4. create encrypted parameters in Systems Manager Parameter Store
  2. Runtime AWS IAM credentials (AWS Access Key ID with AWS Secret Access Key) with sufficient permission to:

    1. write logs to CloudWatch Logs (logs:CreateLogGroup, logs:CreateLogStream, logs:DescribeLogGroups, logs:DescribeLogStreams and logs:PutLogEvents)
    2. store objects inside S3 bucket (s3:PutObject)
    3. create invalidations for CloudFront distribution (cloudfront:CreateInvalidation)
    4. read encrypted parameters from Systems Manager Parameter Store (ssm:GetParametersByPath)

⁠Deployment

  1. Create user pool in Cognito with the following:

    1. 2 groups with names bo.adm and tn.adm for backoffice administrators and tenant administrators respectively

    2. 2 or 3 users with 1 user assigned to bo.adm group and 1 or 2 users assigned tn.adm group

    3. 1 resource server with name dalmarkit that has 3 scopes with scope names bo.adm, tn.adm and cmty.usr for backoffice administrators, tenant administrators and community users respectively

    4. 3 app clients

      • public backoffice client with dalmarkit/bo.adm scope
      • public tenant client with dalmarkit/tn.adm scope
      • confidential server-to-server client with dalmarkit/bo.adm scope
  2. Create bucket in S3 to store uploaded images

  3. Create CloudFront distribution with above S3 bucket as origin

  4. Create the following Systems Manager Parameter Store encrypted parameters:

    1. /DalmarkitSample/Api/Development/AwsCognitoAuthenticationOptions/UserPoolId - Cognito user pool ID
    2. /DalmarkitSample/Api/Development/AwsCognitoAuthenticationOptions/ValidClientIds - space delimited list of client IDs allowed to access the web API (e.g. public backoffice client ID, public tenant client ID and confidential server-to-server client ID)
    3. /DalmarkitSample/Api/Development/AwsCognitoAuthorizationOptions/BackofficeAdminClientIds - confidential server to server client ID
    4. /DalmarkitSample/Api/Development/ConnectionStrings/DefaultConnection - database connection string
    5. /DalmarkitSample/Api/Development/EntityOptions/ImageS3BucketName - name of S3 bucket that will store uploaded images
    6. /DalmarkitSample/Api/Development/EntityOptions/ImageCloudFrontDistributionId - ID of CloudFront distribution used to deliver images stored in S3 bucket
  5. Setup PostgreSQL database by running SQL scripts inside Migration folder⁠ in order

  6. Deploy with Docker

docker run -d -it -p 5500:5000 -e ASPNETCORE_ENVIRONMENT=Development -e AWS_ACCESS_KEY_ID=<AwsAccessKeyId> -e AWS_SECRET_ACCESS_KEY=+<AwsSecretAccessKey> tigerwonghk/dalmarkit-sample-webapi
  1. Access Swagger UI web page at http://localhost:5500/swagger⁠ to browse the web API documentation

⁠Feedback

Bug reports and contributions are welcome at our GitHub repository⁠.

Tag summary

Content type

Image

Digest

sha256:6ada96d1f…

Size

95.7 MB

Last updated

about 1 year ago

docker pull tigerwonghk/dalmarkit-sample-webapi