auth

package
v0.0.0-...-4ae6852 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const APIKeyHeader = "Gram-Key"
View Source
const KeySecurityScheme = "apikey"
View Source
const ProjectHeader = "Gram-Project"
View Source
const ProjectSlugSecuritySchema = "project_slug"
View Source
const SessionCookie = "gram_session"
View Source
const SessionHeader = "Gram-Session"
View Source
const SessionSecurityScheme = "session"

Variables

View Source
var APIKeyScopes = map[string]APIKeyScope{
	"invalid":  APIKeyScopeInvalid,
	"consumer": APIKeyScopeConsumer,
	"producer": APIKeyScopeProducer,
}

Functions

func Attach

func Attach(mux goahttp.Muxer, service *Service)

func FormSignInRedirectURL

func FormSignInRedirectURL(siteURL string) string

func GetAPIKeyHash

func GetAPIKeyHash(key string) (string, error)

Types

type APIKeyScope

type APIKeyScope int
const (
	APIKeyScopeInvalid  APIKeyScope = iota
	APIKeyScopeConsumer APIKeyScope = iota
	APIKeyScopeProducer APIKeyScope = iota
)

func (APIKeyScope) String

func (scope APIKeyScope) String() string

type Auth

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

func New

func New(logger *slog.Logger, db *pgxpool.Pool, sessions *sessions.Manager) *Auth

func (*Auth) Authorize

func (s *Auth) Authorize(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)

func (*Auth) CheckProjectAccess

func (s *Auth) CheckProjectAccess(ctx context.Context, logger *slog.Logger, projectID uuid.UUID) error

type AuthConfigurations

type AuthConfigurations struct {
	SpeakeasyServerAddress string
	GramServerURL          string
	SignInRedirectURL      string
	Environment            string
}

type ByKey

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

func NewKeyAuth

func NewKeyAuth(db *pgxpool.Pool, logger *slog.Logger, billingRepo billing.Repository) *ByKey

func (*ByKey) KeyBasedAuth

func (k *ByKey) KeyBasedAuth(ctx context.Context, key string, requiredScopes []string) (context.Context, error)

type Service

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

Service for gram dashboard authentication endpoints

func NewService

func NewService(logger *slog.Logger, db *pgxpool.Pool, sessions *sessions.Manager, cfg AuthConfigurations) *Service

func (*Service) APIKeyAuth

func (s *Service) APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)

func (*Service) Callback

func (s *Service) Callback(ctx context.Context, payload *gen.CallbackPayload) (res *gen.CallbackResult, err error)

func (*Service) Info

func (s *Service) Info(ctx context.Context, payload *gen.InfoPayload) (res *gen.InfoResult, err error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, payload *gen.LoginPayload) (res *gen.LoginResult, err error)

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, payload *gen.LogoutPayload) (res *gen.LogoutResult, err error)

func (*Service) Register

func (s *Service) Register(ctx context.Context, payload *gen.RegisterPayload) (err error)

func (*Service) SwitchScopes

func (s *Service) SwitchScopes(ctx context.Context, payload *gen.SwitchScopesPayload) (res *gen.SwitchScopesResult, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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