auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(cfg *config.Config) 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 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 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
}

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