auth

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(cfg *config.Config, githubProvider *GitHubAuthProvider) echo.MiddlewareFunc

AuthMiddleware creates authentication middleware

func ExtractTokenFromHeader added in v1.0.0

func ExtractTokenFromHeader(header string) string

ExtractTokenFromHeader extracts GitHub token from Authorization header

func GetConfigFromContext

func GetConfigFromContext(c echo.Context) *config.Config

GetConfigFromContext retrieves config from Echo context

func RequirePermission

func RequirePermission(permission string) echo.MiddlewareFunc

RequirePermission creates permission-checking middleware

func UserOwnsSession

func UserOwnsSession(c echo.Context, sessionUserID string) bool

UserOwnsSession checks if the current user owns the specified session

Types

type GitHubAuthProvider added in v1.0.0

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

GitHubAuthProvider handles GitHub OAuth authentication

func NewGitHubAuthProvider added in v1.0.0

func NewGitHubAuthProvider(cfg *config.GitHubAuthConfig) *GitHubAuthProvider

NewGitHubAuthProvider creates a new GitHub authentication provider

func (*GitHubAuthProvider) Authenticate added in v1.0.0

func (p *GitHubAuthProvider) Authenticate(ctx context.Context, token string) (*UserContext, error)

Authenticate authenticates a user using GitHub OAuth token

type GitHubOAuthProvider added in v1.9.1

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

GitHubOAuthProvider handles GitHub OAuth2 authentication flow

func NewGitHubOAuthProvider added in v1.9.1

func NewGitHubOAuthProvider(cfg *config.GitHubOAuthConfig, githubCfg *config.GitHubAuthConfig) *GitHubOAuthProvider

NewGitHubOAuthProvider creates a new GitHub OAuth provider

func (*GitHubOAuthProvider) ExchangeCode added in v1.9.1

func (p *GitHubOAuthProvider) ExchangeCode(ctx context.Context, code, state string) (*UserContext, error)

ExchangeCode exchanges the authorization code for an access token

func (*GitHubOAuthProvider) GenerateAuthURL added in v1.9.1

func (p *GitHubOAuthProvider) GenerateAuthURL(redirectURI string) (string, string, error)

GenerateAuthURL generates the GitHub OAuth authorization URL

func (*GitHubOAuthProvider) RevokeToken added in v1.9.1

func (p *GitHubOAuthProvider) RevokeToken(ctx context.Context, token string) error

RevokeToken revokes a GitHub access token

type GitHubOrganization added in v1.0.0

type GitHubOrganization struct {
	Login string `json:"login"`
	ID    int64  `json:"id"`
}

GitHubOrganization represents GitHub organization information

type GitHubTeamMembership added in v1.0.0

type GitHubTeamMembership struct {
	Organization string `json:"organization"`
	TeamSlug     string `json:"team_slug"`
	TeamName     string `json:"team_name"`
	Role         string `json:"role"`
}

GitHubTeamMembership represents GitHub team membership

type GitHubUserInfo added in v1.0.0

type GitHubUserInfo struct {
	Login         string                 `json:"login"`
	ID            int64                  `json:"id"`
	Email         string                 `json:"email"`
	Name          string                 `json:"name"`
	Organizations []GitHubOrganization   `json:"organizations"`
	Teams         []GitHubTeamMembership `json:"teams"`
}

GitHubUserInfo represents GitHub user information

type OAuthState added in v1.9.1

type OAuthState struct {
	State       string    `json:"state"`
	RedirectURI string    `json:"redirect_uri"`
	CreatedAt   time.Time `json:"created_at"`
}

OAuthState represents a pending OAuth authentication state

type OAuthTokenResponse added in v1.9.1

type OAuthTokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Scope       string `json:"scope"`
}

OAuthTokenResponse represents the GitHub OAuth token response

type UserCache added in v1.9.1

type UserCache struct {
	User        *GitHubUserInfo
	Role        string
	Permissions []string
	EnvFile     string
}

UserCache represents cached user information, role and permissions

type UserContext

type UserContext struct {
	UserID      string
	Role        string
	Permissions []string
	APIKey      string
	AuthType    string          // "api_key" or "github_oauth"
	GitHubUser  *GitHubUserInfo // GitHub user info when using GitHub auth
	AccessToken string          // OAuth access token (not serialized)
	EnvFile     string          // Path to team-specific environment file
}

UserContext represents the authenticated user context

func GetUserFromContext

func GetUserFromContext(c echo.Context) *UserContext

GetUserFromContext retrieves user context from Echo context

Jump to

Keyboard shortcuts

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