auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionCookieName = "e2a_session"
	StateCookieName   = "e2a_oauth_state"
	SessionMaxAge     = 7 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func EncodeOAuthState

func EncodeOAuthState(s *OAuthState) string

Types

type OAuthState

type OAuthState struct {
	Nonce       string `json:"n"`
	CLICallback string `json:"cb,omitempty"`
	CLIState    string `json:"cs,omitempty"`
}

OAuthState is encoded into the OAuth state parameter. It carries the CSRF nonce and, for CLI-initiated logins, the callback URL and CLI state token.

type UserAuth

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

func NewUserAuth

func NewUserAuth(cfg *config.OAuthConfig, store *identity.Store, production bool) *UserAuth

func NewUserAuthWithOAuthConfig

func NewUserAuthWithOAuthConfig(cfg *config.OAuthConfig, oauthCfg *oauth2.Config, store *identity.Store, production bool, userInfoURL string) *UserAuth

NewUserAuthWithOAuthConfig creates a UserAuth with a custom oauth2.Config and userinfo URL. This is intended for testing against fake OAuth servers.

func (*UserAuth) AuthenticateRequest

func (ua *UserAuth) AuthenticateRequest(r *http.Request) *identity.User

AuthenticateRequest extracts the user from the session cookie. Returns nil if not authenticated.

func (*UserAuth) HandleAgentActivity

func (ua *UserAuth) HandleAgentActivity(w http.ResponseWriter, r *http.Request)

HandleAgentActivity returns recent message activity for an agent owned by the authenticated user.

func (*UserAuth) HandleCallback

func (ua *UserAuth) HandleCallback(w http.ResponseWriter, r *http.Request)

HandleCallback processes the Google OAuth callback and creates a session.

func (*UserAuth) HandleCreateAPIKey

func (ua *UserAuth) HandleCreateAPIKey(w http.ResponseWriter, r *http.Request)

HandleCreateAPIKey creates a new API key for the authenticated user.

func (*UserAuth) HandleDashboardAgents

func (ua *UserAuth) HandleDashboardAgents(w http.ResponseWriter, r *http.Request)

HandleDashboardAgents lists agents owned by the authenticated user.

func (*UserAuth) HandleDeleteAPIKey

func (ua *UserAuth) HandleDeleteAPIKey(w http.ResponseWriter, r *http.Request)

HandleDeleteAPIKey deletes an API key owned by the authenticated user.

func (*UserAuth) HandleDeleteAgent

func (ua *UserAuth) HandleDeleteAgent(w http.ResponseWriter, r *http.Request)

HandleDeleteAgent deletes an agent owned by the authenticated user.

func (*UserAuth) HandleListAPIKeys

func (ua *UserAuth) HandleListAPIKeys(w http.ResponseWriter, r *http.Request)

HandleListAPIKeys lists API keys for the authenticated user (without key values).

func (*UserAuth) HandleLogin

func (ua *UserAuth) HandleLogin(w http.ResponseWriter, r *http.Request)

HandleLogin redirects the user to Google OAuth. CLI login params (cli_callback, cli_state) are encoded into the OAuth state parameter so they survive the redirect through Google without relying on cookies.

func (*UserAuth) HandleLogout

func (ua *UserAuth) HandleLogout(w http.ResponseWriter, r *http.Request)

HandleLogout deletes the session and clears the cookie.

func (*UserAuth) HandleMe

func (ua *UserAuth) HandleMe(w http.ResponseWriter, r *http.Request)

HandleMe returns the current authenticated user's info.

func (*UserAuth) HandleUpdateAgent

func (ua *UserAuth) HandleUpdateAgent(w http.ResponseWriter, r *http.Request)

HandleUpdateAgent updates an agent owned by the authenticated user.

Jump to

Keyboard shortcuts

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