storage

package module
v0.0.0-...-1afc69b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2016 License: MIT Imports: 3 Imported by: 0

README

Couchbase storage for osin OAuth server library

Provides storage for osin

Installation

go get github.com/elgris/osin-couchbase-storage

Running tests

Tests are not pure unit tests, they require running Couchbase instance. You can provide all necessary connection parameters via command line:

go test -couchbase="couchbase://localhost" -bucket="test" -password="111"

Using with osin

Example:

import (
    "github.com/elgris/osin-couchbase-storage"
    "github.com/RangelReale/osin"
)

s, err := storage.NewStorage(storage.Config{
    ConnectionString: "couchbase://localhost",
    BucketName:       "default",
    BucketPassword:   "",
})

if err != nil {
    panic(err.Error())
}

server := osin.NewServer(osin.NewServerConfig(), s)

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConnectionString string
	BucketName       string
	BucketPassword   string
}

func (Config) Validate

func (c Config) Validate() error

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(config Config) (*Storage, error)

func (*Storage) Clone

func (s *Storage) Clone() osin.Storage

Clone implements osin.Storage interface, but in fact does not clone the storage

func (*Storage) Close

func (s *Storage) Close()

Close closes connections and cleans up resources

func (*Storage) GetClient

func (s *Storage) GetClient(id string) (osin.Client, error)

GetClient loads the client by id (client_id)

func (*Storage) LoadAccess

func (s *Storage) LoadAccess(token string) (*osin.AccessData, error)

LoadAccess retrieves access data by token.

func (*Storage) LoadAuthorize

func (s *Storage) LoadAuthorize(code string) (*osin.AuthorizeData, error)

LoadAuthorize looks up AuthorizeData by a code. Client information MUST be loaded together. Optionally can return error if expired.

func (*Storage) LoadRefresh

func (s *Storage) LoadRefresh(token string) (*osin.AccessData, error)

LoadRefresh retrieves refresh AccessData. Client information MUST be loaded together. AuthorizeData and AccessData DON'T NEED to be loaded if not easily available. Optionally can return error if expired.

func (*Storage) RemoveAccess

func (s *Storage) RemoveAccess(token string) error

RemoveAccess revokes or deletes an AccessData.

func (*Storage) RemoveAuthorize

func (s *Storage) RemoveAuthorize(code string) error

RemoveAuthorize revokes or deletes the authorization code.

func (*Storage) RemoveRefresh

func (s *Storage) RemoveRefresh(token string) error

RemoveRefresh revokes or deletes refresh AccessData.

func (*Storage) SaveAccess

func (s *Storage) SaveAccess(data *osin.AccessData) error

SaveAccess writes AccessData. If RefreshToken is not blank, it must save in a way that can be loaded using LoadRefresh.

func (*Storage) SaveAuthorize

func (s *Storage) SaveAuthorize(data *osin.AuthorizeData) error

SaveAuthorize saves authorize data.

func (*Storage) SetClient

func (s *Storage) SetClient(client osin.Client) error

SetClient saves client record to the storage. Client record must provide Id in client.Id

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL