storage

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package storage provides encrypted data store on your local machine that can handle the process of getting refresh tokens for you.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arrangement

type Arrangement struct {
	// ID is how a given arrangement is found.
	ID string
	// RefreshToken is the refresh token for this arrangement.
	RefreshToken string
	// CDRArrangementID is the arrangement ID provided by the dataholder.
	CDRArrangementID string
	// ClientID is the dataholders client id for you.
	ClientID string
	// TokenEndpoint is the dataholders token endpoint
	TokenEndpoint string
}

Arrangement represents an CDR arrangement with a dataholder.

type Store

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

Store can track your access tokens and refresh tokens for you.

func New

func New(name string, secret crypto.Secret) (*Store, error)

New opens a new connection to your data storage and uses the proviced secret for encryption/decription.

func (*Store) AccessToken

func (s *Store) AccessToken(ctx context.Context, id string) (string, error)

AccessToken gets a new access token and refreshes the token in the database. This is an oppinionated function and relies on environment variables being configured for getting an MTLS certificate and signing a client assertion token. For a more flexible method of getting an access token use GetArrangement and cdr.RefreshToken.

func (*Store) GetArrangement

func (s *Store) GetArrangement(id string) (Arrangement, error)

GetArrangement finds an arrangement for a given ID.

func (*Store) NewArrangement

func (s *Store) NewArrangement(a Arrangement) error

NewArrangement saves a new arrangement into the local data store. After it is stored you will be able to fetch new access tokens automatically without worrying about refresh token exchange.

Jump to

Keyboard shortcuts

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