https://github.com/niradler/serverless-auth-go
Simple authentication mechanism base on aws serverless services (Dynmodb, Lambda, ApiGateway)
https://github.com/niradler/serverless-auth-go
authentication aws aws-lambda golang serverless
Last synced: 7 months ago
JSON representation
Simple authentication mechanism base on aws serverless services (Dynmodb, Lambda, ApiGateway)
- Host: GitHub
- URL: https://github.com/niradler/serverless-auth-go
- Owner: niradler
- License: mit
- Created: 2022-03-25T22:26:12.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-10T12:56:06.000Z (over 3 years ago)
- Last Synced: 2023-08-08T01:12:10.957Z (over 2 years ago)
- Topics: authentication, aws, aws-lambda, golang, serverless
- Language: HTML
- Homepage: https://github.com/niradler/serverless-auth-go
- Size: 132 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Serverless Auth
Simple authentication mechanism base on aws serverless services (Dynmodb, Lambda, ApiGateway)
## Features
- Basic user authentication with email/password
- Passwordless user authentication with email only (need to configure email provider)
- Login with providers like Google, Facebook, etc.
- Authorization roles.
- Multi tenants (create an org, and start inviting users, and assign roles to users, admin is the default role for the user that create the org)
## Usage
| method | route | payload | Role | public | description |
| ------ | ------------------------------------ | ------------------------- | ----- | ------ | ----------------------- |
| POST | /v1/auth/login | email,password | | true | Login |
| POST | /v1/auth/login/email | email | | true | Passwordless Login |
| POST | /v1/auth/signup | email,password,data | | true | Signup |
| GET | /v1/auth/validate | | | true | ValidateToken |
| POST | /v1/auth/renew | | | false | Get new Token |
| GET | /v1/auth/provider/:provider | | | true | Login with provider |
| GET | /v1/auth/provider/:provider/callback | | | true | Validate provider login |
| GET | /v1/users/me | | | true | Health check |
| PUT | /v1/users/me | data | | false | Update user data |
| PUT | /v1/users/me/password | password,repeatedPassword | | false | Update user password |
| POST | /v1/orgs | name | | false | Create Org |
| POST | /v1/orgs/:orgId/invite | email,role | admin | false | Invite user to me org |
| GET | /v1/orgs/:orgId/users | | admin | false | Get org users |
## Deploy
use deploy.sh script to setup and customize the deployment
to customize the deployment, you can use the following environment variables:
```.env
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
SLS_AUTH_GOOGLE_CLIENT_ID=
SLS_AUTH_GOOGLE_CLIENT_SECRET=
SLS_AUTH_GOOGLE_CALLBACK=
SLS_AUTH_CLIENT_CALLBACK=
SLS_AUTH_SESSION_SECRET=
SLS_AUTH_JWT_SECRET=
SLS_AUTH_APP_NAME=
SLS_AUTH_SENDGRID_API_KEY=
SLS_AUTH_FROM_EMAIL=
SLS_AUTH_EMAIL_TEMPLATES_FOLDER=
SLS_AUTH_APP_NAME=
SLS_AUTH_APP_CONTACT=
```
## Develop
```sh
npm i -g cdk
git clone https://github.com/niradler/serverless-auth-go.git
cd serverless-auth-go
$env:GOOS = 'linux' or export GOOS=linux
cd server && go get && go build -o build/main ./src
cd infra && cdk deploy
# run
cd server
go run ./src/.
```
## Tech Stack
- Using aws cdk (iac) to deploy the aws services. (golang)
- Scalable api using Gin framework. (golang)
- goth for providers logins. (github/bitbucket/gitlab/facebook/google) (only google/github is tested)
## Contribution
Contribution is welcome.
[Roadmap](https://github.com/niradler/serverless-auth-go/projects/1)