Skip to main content

s3authbasic

Project description

s3authbasic

s3authbasic is a Pyramid application aimed to serve a static websites stored in Amazon S3 protected by Auth Basic authentication. You need a IAM user with its credentials and read access on the bucket which contains the static files.

Amazon Settings

I assumed that you have a protected bucket. To create the IAM user with the correct permissions you need go to the IAM app in the AWS Console

Click Users section and click in the Creare New User blue button.

Enter the username you want. It can’t contains whitespaces. And click on create

Click on Download Credential or write down the credentials info.

Now, we need to add the policy to give read access permissions to the user.

Click in the created user and go to the permissions tab below.

Click on the Attach User Policy.

Click on Custom Policy and in the Select button.

Give a policy name, like s3-reader-policy.

Copy the follow block in the Policy Document box. Please, replace protected-html with your bucket name.

{
    "Statement": [
     {
       "Effect": "Allow",
       "Action": [
         "s3:Get*",
         "s3:ListBucket"
       ],
       "Resource": [
         "arn:aws:s3:::protected-html",
         "arn:aws:s3:::protected-html/*"
       ]
     }
   ]
}

Application deployment

I suggest you to use a virtualenv but I don’t use that in this doc.

pip install s3authbasic

You need a Pyramid ini settings file. You can find one example in the github reposity in the config-templates directory.

Configuration

You can config the app by editing the settings file or by using envionment variables.

If you want to use the file, then the AWS and the user settings are documented in the file.

The AWS environment variables are like this:

export AWS_BUCKET_NAME='bucketname'
export AWS_SECRET_ACCESS_KEY='12312sdf32'
export AES_ACCESS_KEY_ID='123123123aaa'

To define users to access the app, the variable should starts with USER_. The user name is the word after the underscore character and shoud be defined in the correct capitalization. This is, if you want a user called admin, you should create the environment variable USER_admin.

You can setup many users as you need.

The password should be hashed by sha256.

You can get the hash of your password by this command in linux:

echo -n thepassword | sha256sum

The environment variable should look like this:

export USER_admin='123123123123123123123'

Start the application

You use the follow command:

pserve development.ini

If you are using the default ini file, the application should be available in the 6543 port. If you are deployed the app in your own system, you can access it through http://127.0.0.1:6543/

0.1

  • Fix WebTest error

  • Add files needed by heroku

0.1

  • The first published version

0.0

  • Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3authbasic-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file s3authbasic-0.1.1.tar.gz.

File metadata

  • Download URL: s3authbasic-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for s3authbasic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7402a71bcb4b4b52acd0975a2c10eabe5d749c7445e088283e3bf99688502b3a
MD5 c0244af86323a0680fe3b839aad9736f
BLAKE2b-256 452ed008f1701fbdd312ef86e269b47e73d9245df29482a58accfc560d60e192

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page