internal

package
v0.0.0-...-9a0570b Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package internal contains implementation details of loginsessions module.

Index

Constants

View Source
const GoogleAuthorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"

GoogleAuthorizationEndpoint is Google's authorization endpoint URL.

Variables

View Source
var ErrNoSession = errors.New("no login session")

ErrNoSession is returned by SessionStore if the login session is missing.

Functions

func DecryptState

func DecryptState(ctx context.Context, enc string) (*statepb.OpenIDState, error)

DecryptState is the reverse of EncryptState.

func EncryptState

func EncryptState(ctx context.Context, msg *statepb.OpenIDState) (string, error)

EncryptState serializes, encrypts and base64-encodes OpenIDState.

func RandomAlphaNum

func RandomAlphaNum(size int) string

RandomAlphaNum generates a random alphanumeric string of given length.

Its entropy is ~6*size random bits.

func RandomBlob

func RandomBlob(bytes int) []byte

RandomBlob generates a completely random byte string of given length.

Types

type DatastoreSessionStore

type DatastoreSessionStore struct{}

DatastoreSessionStore implements SessionStore using Cloud Datastore.

func (*DatastoreSessionStore) Cleanup

func (s *DatastoreSessionStore) Cleanup(ctx context.Context) error

func (*DatastoreSessionStore) Create

func (*DatastoreSessionStore) Get

func (*DatastoreSessionStore) Update

func (s *DatastoreSessionStore) Update(ctx context.Context, sessionID string, cb func(*statepb.LoginSession)) (*statepb.LoginSession, error)

type MemorySessionStore

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

MemorySessionStore implements SessionStore using an in-memory map.

For tests and running locally during development.

func (*MemorySessionStore) Cleanup

func (s *MemorySessionStore) Cleanup(ctx context.Context) error

func (*MemorySessionStore) Create

func (s *MemorySessionStore) Create(ctx context.Context, session *statepb.LoginSession) error

func (*MemorySessionStore) Get

func (s *MemorySessionStore) Get(ctx context.Context, sessionID string) (*statepb.LoginSession, error)

func (*MemorySessionStore) Update

func (s *MemorySessionStore) Update(ctx context.Context, sessionID string, cb func(*statepb.LoginSession)) (*statepb.LoginSession, error)

type OAuthClient

type OAuthClient struct {
	// ProviderName is the name of the identity provider shown on the web pages.
	ProviderName string
	// AuthorizationEndpoint is OAuth endpoint to redirect the user to.
	AuthorizationEndpoint string
}

OAuthClient represents a known accepted OAuth client.

func AuthDBClientProvider

func AuthDBClientProvider(ctx context.Context, clientID string) (*OAuthClient, error)

AuthDBClientProvider checks if a client is registered in the AuthDB.

type OAuthClientProvider

type OAuthClientProvider func(ctx context.Context, clientID string) (*OAuthClient, error)

OAuthClientProvider returns OAuth client details for known clients.

Returns nil if the client is not known or an error if the check failed.

type SessionStore

type SessionStore interface {
	// Create transactionally stores a session if it didn't exist before.
	//
	// The caller should have session.Id populated already with a random ID.
	//
	// Returns an error if there's already such session or the transaction failed.
	Create(ctx context.Context, session *statepb.LoginSession) error

	// Get returns an existing session or ErrNoSession if it is missing.
	//
	// Always returns a new copy of the protobuf message that can be safely
	// mutated by the caller.
	Get(ctx context.Context, sessionID string) (*statepb.LoginSession, error)

	// Update transactionally updates an existing session.
	//
	// The callback is called to mutate the session in-place. The resulting
	// session is then stored back (if it really was mutated). The callback may
	// be called multiple times if the transaction is retried.
	//
	// If there's no such session returns ErrNoSession. May return other errors
	// if the transaction fails.
	//
	// On success returns the session that is stored in the store now.
	Update(ctx context.Context, sessionID string, cb func(*statepb.LoginSession)) (*statepb.LoginSession, error)

	// Cleanup deletes login sessions that expired sufficiently long ago.
	Cleanup(ctx context.Context) error
}

SessionStore is a storage layer for login sessions.

Directories

Path Synopsis
Package assets is generated by go.chromium.org/luci/tools/cmd/assets.
Package assets is generated by go.chromium.org/luci/tools/cmd/assets.
Package statepb contains protos used internally by loginsessions.
Package statepb contains protos used internally by loginsessions.

Jump to

Keyboard shortcuts

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