Skip to main content

Store files in Amazon S3

This guide explains how to store the uploaded files of Casdoor, such as avatars, in Amazon S3.


Learning outcomes​

  • Create an access key and prepare the bucket.
  • Add Amazon S3 as a storage provider in Casdoor.
  • Serve the files through a VPC endpoint or CloudFront.

What you need​

  • An AWS account and an S3 bucket
  • Administrator access to the Casdoor admin console

Prepare AWS​

  1. Create an access key and a secret access key. See Managing access keys.

  2. In the Permissions of the bucket, turn off Block all public access, or add a bucket policy that allows Casdoor, and save.

    Block all public access turned off

  3. In Object Ownership, turn on ACLs and set the ownership that you need.

    ACLs turned on

Add the provider in Casdoor​

  1. In the Casdoor admin console, go to Identity > Providers and add a provider.

  2. Set Category to Storage and Type to AWS S3.

  3. Fill in the fields:

    Casdoor fieldIn AWS / S3Required
    Client IDAccess keyYes
    Client secretSecret access keyYes
    EndpointEndpointYes
    Endpoint (Intranet)VPC endpointNo
    BucketBucket nameYes
    Path prefix—No
    DomainBucket URL or CloudFront domainYes
    Region IDAWS regionYes

    Endpoint is the S3 REST API endpoint of the region, such as https://s3.us-east-1.amazonaws.com. See Amazon S3 endpoints. Don't use a website endpoint.

    Set Domain to the URL that serves the files, such as https://<bucket>.s3.us-east-1.amazonaws.com or the domain of a CloudFront distribution. Casdoor builds the URLs of uploaded files from it. If Domain is empty, Casdoor fills it with the endpoint, which doesn't contain the bucket name, so the file URLs don't work.

    Amazon S3 provider in Casdoor

  4. Save the provider.

Optional settings​

See also​