auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package auth provides contracts for N26 authentication.

Index

Constants

View Source
const (
	// BasicAuthUsername is the username which is used in Authorization header while logging to n26api.
	BasicAuthUsername = "nativeweb"
	// BasicAuthPassword is the password which is used in Authorization header while logging to n26api.
	BasicAuthPassword = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OAuthToken added in v0.1.1

type OAuthToken struct {
	AccessToken      Token     `json:"access_token"`
	RefreshToken     Token     `json:"refresh_token"`
	ExpiresAt        time.Time `json:"expires_at"`
	RefreshExpiresAt time.Time `json:"refresh_expires_at"`
}

OAuthToken contains all relevant information to access to the service and refresh the token. nolint:tagliatelle

func (OAuthToken) IsExpired added in v0.1.1

func (t OAuthToken) IsExpired(timestamp time.Time) bool

IsExpired checks whether the access token is expired or not.

func (OAuthToken) IsRefreshable added in v0.1.1

func (t OAuthToken) IsRefreshable(timestamp time.Time) bool

IsRefreshable checks whether the refresh token is alive or not.

type Token

type Token string

Token is an oauth2 token.

type TokenProvider

type TokenProvider interface {
	// Token provides a token.
	Token(ctx context.Context) (Token, error)
}

TokenProvider provides oauth2 token.

type TokenStorage added in v0.1.1

type TokenStorage interface {
	// Get gets OAuthToken from data source.
	Get(ctx context.Context, key string) (OAuthToken, error)
	// Set sets OAuthToken to data source.
	Set(ctx context.Context, key string, token OAuthToken) error
}

TokenStorage persists or gets OAuthToken.

Jump to

Keyboard shortcuts

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