modulepackage
0.0.0-20180628151818-365d46dce245
Repository: https://github.com/uniplaces/osin-dynamodb.git
Documentation: pkg.go.dev
# README
osin-dynamodb
This package implements the storage for OSIN with Amazon DynamoDB using aws-sdk-go.
Installation
Install library with go get github.com/uniplaces/osin-dynamodb
or if you use glide with glide get github.com/uniplaces/osin-dynamodb
Usage
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/uniplaces/osin-dynamodb"
"github.com/RangelReale/osin"
"os"
)
func main() {
// This is configuration for local DynamoDB instance used in tests,
// for details how to configure your real AWS DynamoDB connection check DynamoDB documentation
os.Clearenv()
os.Setenv("AWS_ACCESS_KEY_ID", "a")
os.Setenv("AWS_SECRET_ACCESS_KEY", "b")
svc := dynamodb.New(session.New(&aws.Config{
Endpoint: aws.String("http://localhost:4567"),
Region: aws.String("us-west-1"),
}))
// You can use CreateStorageConfig helper to create configuration or you can create it by yourself
storageConfig := osindynamodb.CreateStorageConfig("oauth_table_prefix_")
// Initialization
store := osindynamodb.New(svc, storageConfig)
server := osin.NewServer(osin.NewServerConfig(), store)
// For further details how to use osin server check osin documentation
}
# Functions
CreateStorageConfig prefixes all table names and returns StorageConfig.
New returns a new DynamoDB storage instance.
# Variables
ErrAccessNotFound is returned by LoadAccess if access token was not found.
ErrAuthorizeNotFound is returned by LoadAuthorize if authorization code was not found.
ErrClientNotFound is returned by GetClient if client was not found.
ErrRefreshNotFound is returned by LoadRefresh if refresh token was not found.
ErrTokenExpired is returned by LoadAccess, LoadAuthorize or LoadRefresh if token or code expired.
# Structs
Storage implements the storage interface for OSIN (https://github.com/RangelReale/osin) with Amazon DynamoDB (https://aws.amazon.com/dynamodb/) using aws-sdk-go (https://github.com/aws/aws-sdk-go).
StorageConfig allows to pass configuration to Storage on initialization.
# Interfaces
UserData is an interface that allows you to store UserData values as DynamoDB attributes in AccessTable and RefreshTable.