api

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIRouteSpecs = []RouteContractSpec{
	{
		Method: http.MethodGet,
		Path:   "/auth/api/v1/csrf",
		Errors: CSRFGetErrors,
	},
	{
		Method: http.MethodGet,
		Path:   "/auth/api/v1/oauth/google/options",
		Errors: GoogleOptionsGetErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/oauth/google",
		Errors: GoogleLoginPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/login",
		Errors: LoginPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/signup",
		Errors: SignupPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/signup/verify",
		Errors: SignupVerifyPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/challenges/resend",
		Errors: ChallengeResendPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/passkeys/authenticate/options",
		Errors: PasskeyAuthenticateOptionsPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/passkeys/authenticate/finish",
		Errors: PasskeyAuthenticateFinishPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/passkeys/register/options",
		Errors: PasskeyRegisterOptionsPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/passkeys/register/finish",
		Errors: PasskeyRegisterFinishPostErrors,
	},
	{
		Method: http.MethodGet,
		Path:   "/auth/api/v1/user",
		Errors: UserGetErrors,
	},
	{
		Method: http.MethodGet,
		Path:   "/auth/api/v1/organizations",
		Errors: OrganizationsGetErrors,
	},
	{
		Method: http.MethodGet,
		Path:   "/auth/api/v1/organizations/current",
		Errors: OrganizationsGetErrors,
	},
	{
		Method: http.MethodGet,
		Path:   "/auth/api/v1/organizations/current/members",
		Errors: OrganizationMembersGetErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/organizations/{organizationID}/switch",
		Errors: OrganizationSwitchPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/sessions/refresh",
		Errors: RefreshPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/tokens/refresh",
		Errors: RefreshPostErrors,
	},
	{
		Method: http.MethodPost,
		Path:   "/auth/api/v1/sessions/logout",
		Errors: LogoutPostErrors,
	},
}
View Source
var LogoutPostErrors = map[response.ErrorCode]response.ErrorSpec{}

Functions

This section is empty.

Types

type APIHandler

type APIHandler struct {
	Auth           *auth.Service
	Passkeys       *passkey.Service
	Session        *session.Service
	Organizations  *organization.Service
	Challenge      *challenge.Service
	Verification   *challenge.VerificationCodeService
	Limiter        ratelimiter.AuthLimiter
	Logger         *slog.Logger
	Google         *google.Client
	OAuthProviders oauth.OAuthProviders

	ChallengeEnabled bool
	AccessTTL        time.Duration
	RefreshTTL       time.Duration
}

func New

func New(
	auth *auth.Service,
	passkeys *passkey.Service,
	session *session.Service,
	organizations *organization.Service,
	challenge *challenge.Service,
	verification *challenge.VerificationCodeService,
	limiter ratelimiter.AuthLimiter,
	logger *slog.Logger,
	google *google.Client,
	oauthProviders oauth.OAuthProviders,
	challengeEnabled bool,
	accessTTL time.Duration,
	refreshTTL time.Duration,
) *APIHandler

func (*APIHandler) CSRFGet

func (h *APIHandler) CSRFGet(w http.ResponseWriter, r *http.Request)

func (*APIHandler) ChallengeResendPost added in v0.1.27

func (h *APIHandler) ChallengeResendPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) ChangeUsername

func (h *APIHandler) ChangeUsername(w http.ResponseWriter, r *http.Request)

func (*APIHandler) DeleteUser

func (h *APIHandler) DeleteUser(w http.ResponseWriter, r *http.Request)

func (*APIHandler) GoogleLoginPost added in v0.1.27

func (h *APIHandler) GoogleLoginPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) GoogleOptionsGet added in v0.1.27

func (h *APIHandler) GoogleOptionsGet(w http.ResponseWriter, r *http.Request)

func (*APIHandler) LoginPost

func (h *APIHandler) LoginPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) LogoutPost

func (h *APIHandler) LogoutPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) OrganizationCurrentGet

func (h *APIHandler) OrganizationCurrentGet(w http.ResponseWriter, r *http.Request)

func (*APIHandler) OrganizationCurrentMembersGet added in v0.1.25

func (h *APIHandler) OrganizationCurrentMembersGet(w http.ResponseWriter, r *http.Request)

func (*APIHandler) OrganizationSwitchPost

func (h *APIHandler) OrganizationSwitchPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) OrganizationsGet

func (h *APIHandler) OrganizationsGet(w http.ResponseWriter, r *http.Request)

func (*APIHandler) PasskeyAuthenticateFinishPost added in v0.1.27

func (h *APIHandler) PasskeyAuthenticateFinishPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) PasskeyAuthenticateOptionsPost added in v0.1.27

func (h *APIHandler) PasskeyAuthenticateOptionsPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) PasskeyRegisterFinishPost added in v0.1.27

func (h *APIHandler) PasskeyRegisterFinishPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) PasskeyRegisterOptionsPost added in v0.1.27

func (h *APIHandler) PasskeyRegisterOptionsPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) RefreshPost

func (h *APIHandler) RefreshPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) SignupPost

func (h *APIHandler) SignupPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) SignupVerifyPost added in v0.1.27

func (h *APIHandler) SignupVerifyPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) TokenRefreshPost

func (h *APIHandler) TokenRefreshPost(w http.ResponseWriter, r *http.Request)

func (*APIHandler) UserGet

func (h *APIHandler) UserGet(w http.ResponseWriter, r *http.Request)

type RouteContractSpec

type RouteContractSpec struct {
	Method string
	Path   string
	Errors map[response.ErrorCode]response.ErrorSpec
}

Jump to

Keyboard shortcuts

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