Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static site on S3 with Github OAuth?

Tags:

Title says it all: is it possible to host a static-generated site on S3 and restrict access to it based on Github OAuth?

Scenario: You generate a static site (using Hugo or whatever) and you upload it to S3 as a static site. Is there some combination of AWS services (API Gateway, Lambda, etc.) that can make it so that only members of my Github organization can access this site? Authenticating with Github's OAuth? Anyone not authenticated should be treated with a 404.

Has anyone done this or know how to do it? Is such a thing possible without running a backing server (EC2, Heroku, DigitalOcean Droplet, etc.) of some kind?

Looking for a complete answer that outlines steps on how to set this up (if possible) with the lowest cost/complexity.

like image 688
neezer Avatar asked Feb 02 '17 01:02

neezer


1 Answers

Yes this is possible. I've followed this tutorial in the past to secure a static site on S3 behind an Auth0 authentication, using DynamoDB as the user account store, and API Gateway + AWS Lambda as the authentication service. That was an AngularJS SPA, but the general concept should be the same.

Github is listed as an Auth0 identity provider. I would recommend looking at this documentation for using Auth0 on your site. Once you get it working you would have to configure your static site generator to include the authentication JavaScript code on every page it generates.

like image 53
Mark B Avatar answered Sep 25 '22 18:09

Mark B