GithubHelp home page GithubHelp logo

gostudentorg / go-oauth2-dynamodb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from contamobi/go-oauth2-dynamodb

0.0 0.0 0.0 14 KB

DynamoDB storage for OAuth 2.0

License: MIT License

Shell 5.17% Go 94.83%

go-oauth2-dynamodb's Introduction

DynamoDB Storage for OAuth 2.0

Based on the https://github.com/go-oauth2/mongo

License

Install

$ go get -u github.com/contamobi/go-oauth2-dynamodb

Usage (specifying credentials)

package main

import (
	"github.com/contamobi/go-oauth2-dynamodb"
	"github.com/contamobi/go-oauth2/manage"
)

func main() {
	manager := manage.NewDefaultManager()
	manager.MustTokenStorage(
		dynamo.NewTokenStore(dynamo.NewConfig(
			"us-east-1", // AWS Region
			"http://localhost:8000", // AWS DynamoDB Endpoint
			"AKIA*********", // AWS Access Key
			"*************", // AWS Secret
                        "oauth2_basic", // Oauth2 basic table name
			"oauth2_access", // Oauth2 access table name
			"oauth2_refresh", // Oauth2 refresh table name
		)),
	)
	// ...
}

Usage (with IAM Role configured for ec2 or Lambda)

package main

import (
	"github.com/contamobi/go-oauth2-dynamodb"
	"github.com/contamobi/go-oauth2/manage"
)

func main() {
	manager := manage.NewDefaultManager()
	manager.MustTokenStorage(
		dynamo.NewTokenStore(dynamo.NewConfig(
			"us-east-1", // AWS Region
			"", // Emtpy
			"", // Emtpy
			"", // Emtpy
			"oauth2_basic", // Oauth2 basic table name
                        "oauth2_access", // Oauth2 access table name
                        "oauth2_refresh", // Oauth2 refresh table name

		)),
	)
	// ...
}

Run tests

Start dynamodb local

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb 

Export env variables

export AWS_REGION=us-east-1
export DYNAMODB_ENDPOINT='http://localhost:8000'
export AWS_ACCESS_KEY=AKIA******
export AWS_SECRET=**************

Run tests

go test

MIT License

Copyright (c) 2018 Conta.MOBI

go-oauth2-dynamodb's People

Contributors

dhanielo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.