oauthsessions

package
v0.0.0-...-059fb3b Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidExpirationDate = fmt.Errorf("invalid expiration date")
View Source
var ExampleAliceSession = Session{
	// contains filtered or unexported fields
}

Functions

This section is empty.

Types

type CreateCmd

type CreateCmd struct {
	AccessToken      secret.Text
	AccessExpiresAt  time.Time
	RefreshToken     secret.Text
	RefreshExpiresAt time.Time
	ClientID         string
	UserID           uuid.UUID
	Scope            string
}

func (CreateCmd) Validate

func (t CreateCmd) Validate() error

Validate the fields.

type FakeSessionBuilder

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

func NewFakeSession

func NewFakeSession(t testing.TB) *FakeSessionBuilder

func (*FakeSessionBuilder) Build

func (f *FakeSessionBuilder) Build() *Session

func (*FakeSessionBuilder) CreatedBy

func (f *FakeSessionBuilder) CreatedBy(user *users.User) *FakeSessionBuilder

func (*FakeSessionBuilder) WithClient

func (f *FakeSessionBuilder) WithClient(client *oauthclients.Client) *FakeSessionBuilder

type MockService

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func NewMockService

func NewMockService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockService

NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockService) Create

func (_m *MockService) Create(ctx context.Context, input *CreateCmd) (*Session, error)

Create provides a mock function with given fields: ctx, input

func (*MockService) DeleteAllForUser

func (_m *MockService) DeleteAllForUser(ctx context.Context, userID uuid.UUID) error

DeleteAllForUser provides a mock function with given fields: ctx, userID

func (*MockService) GetByAccessToken

func (_m *MockService) GetByAccessToken(ctx context.Context, access secret.Text) (*Session, error)

GetByAccessToken provides a mock function with given fields: ctx, access

func (*MockService) GetByRefreshToken

func (_m *MockService) GetByRefreshToken(ctx context.Context, refresh secret.Text) (*Session, error)

GetByRefreshToken provides a mock function with given fields: ctx, refresh

func (*MockService) RemoveByAccessToken

func (_m *MockService) RemoveByAccessToken(ctx context.Context, access secret.Text) error

RemoveByAccessToken provides a mock function with given fields: ctx, access

func (*MockService) RemoveByRefreshToken

func (_m *MockService) RemoveByRefreshToken(ctx context.Context, refresh secret.Text) error

RemoveByRefreshToken provides a mock function with given fields: ctx, refresh

type Service

type Service interface {
	Create(ctx context.Context, input *CreateCmd) (*Session, error)
	RemoveByAccessToken(ctx context.Context, access secret.Text) error
	RemoveByRefreshToken(ctx context.Context, refresh secret.Text) error
	GetByAccessToken(ctx context.Context, access secret.Text) (*Session, error)
	GetByRefreshToken(ctx context.Context, refresh secret.Text) (*Session, error)
	DeleteAllForUser(ctx context.Context, userID uuid.UUID) error
}

func Init

func Init(tools tools.Tools, db *sql.DB) Service

type Session

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

func (*Session) AccessCreatedAt

func (s *Session) AccessCreatedAt() time.Time

func (*Session) AccessExpiresAt

func (s *Session) AccessExpiresAt() time.Time

func (*Session) AccessToken

func (s *Session) AccessToken() secret.Text

func (*Session) ClientID

func (s *Session) ClientID() string

func (*Session) RefreshCreatedAt

func (s *Session) RefreshCreatedAt() time.Time

func (*Session) RefreshExpiresAt

func (s *Session) RefreshExpiresAt() time.Time

func (*Session) RefreshToken

func (s *Session) RefreshToken() secret.Text

func (*Session) Scope

func (s *Session) Scope() string

func (*Session) UserID

func (s *Session) UserID() uuid.UUID

Jump to

Keyboard shortcuts

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