Documentation
¶
Index ¶
- Variables
- type APIHandler
- func (h *APIHandler) CSRFGet(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) ChangeUsername(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) LoginPost(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) LogoutPost(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) OrganizationCurrentGet(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) OrganizationCurrentMembersGet(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) OrganizationSwitchPost(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) OrganizationsGet(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) RefreshPost(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) SignupPost(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) TokenRefreshPost(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) UserGet(w http.ResponseWriter, r *http.Request)
- type RouteContractSpec
Constants ¶
This section is empty.
Variables ¶
View Source
var APIRouteSpecs = []RouteContractSpec{ { Method: http.MethodGet, Path: "/auth/api/v1/csrf", Errors: CSRFGetErrors, }, { Method: http.MethodPost, Path: "/auth/api/v1/login", Errors: LoginPostErrors, }, { Method: http.MethodPost, Path: "/auth/api/v1/signup", Errors: SignupPostErrors, }, { 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 CSRFGetErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var LoginPostErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeInvalidRequest: { Status: http.StatusBadRequest, Code: response.CodeInvalidRequest, }, response.CodeUnauthorized: { Status: http.StatusUnauthorized, Code: response.CodeUnauthorized, }, response.CodeForbidden: { Status: http.StatusForbidden, Code: response.CodeForbidden, }, response.CodeRateLimited: { Status: http.StatusTooManyRequests, Code: response.CodeRateLimited, }, response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var LogoutPostErrors = map[response.ErrorCode]response.ErrorSpec{}
View Source
var OrganizationMembersGetErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeUnauthorized: { Status: http.StatusUnauthorized, Code: response.CodeUnauthorized, }, response.CodeForbidden: { Status: http.StatusForbidden, Code: response.CodeForbidden, }, response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var OrganizationSwitchPostErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeUnauthorized: { Status: http.StatusUnauthorized, Code: response.CodeUnauthorized, }, response.CodeInvalidRequest: { Status: http.StatusBadRequest, Code: response.CodeInvalidRequest, }, response.CodeForbidden: { Status: http.StatusForbidden, Code: response.CodeForbidden, }, response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var OrganizationsGetErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeUnauthorized: { Status: http.StatusUnauthorized, Code: response.CodeUnauthorized, }, response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var RefreshPostErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeUnauthorized: { Status: http.StatusUnauthorized, Code: response.CodeUnauthorized, }, response.CodeInvalidRequest: { Status: http.StatusBadRequest, Code: response.CodeInvalidRequest, }, response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var SignupPostErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeInvalidRequest: { Status: http.StatusBadRequest, Code: response.CodeInvalidRequest, }, response.CodeForbidden: { Status: http.StatusForbidden, Code: response.CodeForbidden, }, response.CodeRateLimited: { Status: http.StatusTooManyRequests, Code: response.CodeRateLimited, }, response.CodeInternalError: { Status: http.StatusInternalServerError, Code: response.CodeInternalError, }, }
View Source
var UserGetErrors = map[response.ErrorCode]response.ErrorSpec{ response.CodeUnauthorized: { Status: http.StatusUnauthorized, Code: response.CodeUnauthorized, }, }
Functions ¶
This section is empty.
Types ¶
type APIHandler ¶
type APIHandler struct {
Auth *auth.Service
Session *session.Service
Organizations *organization.Service
Limiter ratelimiter.AuthLimiter
Logger *slog.Logger
Google *google.Client
ChallengeEnabled bool
AccessTTL time.Duration
RefreshTTL time.Duration
}
func New ¶
func New( auth *auth.Service, session *session.Service, organizations *organization.Service, limiter ratelimiter.AuthLimiter, logger *slog.Logger, google *google.Client, challengeEnabled bool, accessTTL time.Duration, refreshTTL time.Duration, ) *APIHandler
func (*APIHandler) CSRFGet ¶
func (h *APIHandler) CSRFGet(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) 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) 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) TokenRefreshPost ¶
func (h *APIHandler) TokenRefreshPost(w http.ResponseWriter, r *http.Request)
func (*APIHandler) UserGet ¶
func (h *APIHandler) UserGet(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.