Documentation ¶
Overview ¶
Package internal contains implementation details of loginsessions module.
Index ¶
- Constants
- Variables
- func DecryptState(ctx context.Context, enc string) (*statepb.OpenIDState, error)
- func EncryptState(ctx context.Context, msg *statepb.OpenIDState) (string, error)
- func RandomAlphaNum(size int) string
- func RandomBlob(bytes int) []byte
- type DatastoreSessionStore
- func (s *DatastoreSessionStore) Cleanup(ctx context.Context) error
- func (s *DatastoreSessionStore) Create(ctx context.Context, session *statepb.LoginSession) error
- func (s *DatastoreSessionStore) Get(ctx context.Context, sessionID string) (*statepb.LoginSession, error)
- func (s *DatastoreSessionStore) Update(ctx context.Context, sessionID string, cb func(*statepb.LoginSession)) (*statepb.LoginSession, error)
- type MemorySessionStore
- func (s *MemorySessionStore) Cleanup(ctx context.Context) error
- func (s *MemorySessionStore) Create(ctx context.Context, session *statepb.LoginSession) error
- func (s *MemorySessionStore) Get(ctx context.Context, sessionID string) (*statepb.LoginSession, error)
- func (s *MemorySessionStore) Update(ctx context.Context, sessionID string, cb func(*statepb.LoginSession)) (*statepb.LoginSession, error)
- type OAuthClient
- type OAuthClientProvider
- type SessionStore
Constants ¶
const GoogleAuthorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"
GoogleAuthorizationEndpoint is Google's authorization endpoint URL.
Variables ¶
var ErrNoSession = errors.New("no login session")
ErrNoSession is returned by SessionStore if the login session is missing.
Functions ¶
func DecryptState ¶
DecryptState is the reverse of EncryptState.
func EncryptState ¶
EncryptState serializes, encrypts and base64-encodes OpenIDState.
func RandomAlphaNum ¶
RandomAlphaNum generates a random alphanumeric string of given length.
Its entropy is ~6*size random bits.
func RandomBlob ¶
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 (s *DatastoreSessionStore) Create(ctx context.Context, session *statepb.LoginSession) error
func (*DatastoreSessionStore) Get ¶
func (s *DatastoreSessionStore) Get(ctx context.Context, sessionID string) (*statepb.LoginSession, error)
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. |