httpmw

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const AuthCookie = "session_token"

AuthCookie represents the name of the cookie the API key is stored in.

View Source
const UserKey = "user"

Variables

This section is empty.

Functions

func APIKey

func APIKey(r *http.Request) database.APIKey

APIKey returns the API key from the ExtractAPIKey handler.

func ExtractAPIKey

func ExtractAPIKey(db database.Store, oauthConfig OAuth2Config) func(http.Handler) http.Handler

ExtractAPIKey requires authentication using a valid API key. It handles extending an API key if it comes close to expiry, updating the last used time in the database.

func ExtractOrganizationParam

func ExtractOrganizationParam(db database.Store) func(http.Handler) http.Handler

ExtractOrganizationParam grabs an organization and user membership from the "organization" URL parameter. This middleware requires the API key middleware higher in the call stack for authentication.

func ExtractProjectParam

func ExtractProjectParam(db database.Store) func(http.Handler) http.Handler

ExtractProjectParam grabs a project from the "project" URL parameter.

func ExtractProjectVersionParam

func ExtractProjectVersionParam(db database.Store) func(http.Handler) http.Handler

ExtractProjectVersionParam grabs project version from the "projectversion" URL parameter.

func ExtractUserParam

func ExtractUserParam(db database.Store) func(http.Handler) http.Handler

ExtractUserParam extracts a user from an ID/username in the {user} URL parameter.

func ExtractWorkspaceAgent

func ExtractWorkspaceAgent(db database.Store) func(http.Handler) http.Handler

ExtractWorkspaceAgent requires authentication using a valid agent token.

func ExtractWorkspaceBuildParam

func ExtractWorkspaceBuildParam(db database.Store) func(http.Handler) http.Handler

ExtractWorkspaceBuildParam grabs workspace build from the "workspacebuild" URL parameter.

func ExtractWorkspaceParam

func ExtractWorkspaceParam(db database.Store) func(http.Handler) http.Handler

ExtractWorkspaceParam grabs a workspace from the "workspace" URL parameter.

func ExtractWorkspaceResourceParam

func ExtractWorkspaceResourceParam(db database.Store) func(http.Handler) http.Handler

ExtractWorkspaceResourceParam grabs a workspace resource from the "provisionerjob" URL parameter.

func OrganizationMemberParam

func OrganizationMemberParam(r *http.Request) database.OrganizationMember

OrganizationMemberParam returns the organization membership that allowed the query from the ExtractOrganizationParam handler.

func OrganizationParam

func OrganizationParam(r *http.Request) database.Organization

OrganizationParam returns the organization from the ExtractOrganizationParam handler.

func ProjectParam

func ProjectParam(r *http.Request) database.Project

ProjectParam returns the project from the ExtractProjectParam handler.

func ProjectVersionParam

func ProjectVersionParam(r *http.Request) database.ProjectVersion

ProjectVersionParam returns the project version from the ExtractProjectVersionParam handler.

func RateLimitPerMinute

func RateLimitPerMinute(count int) func(http.Handler) http.Handler

RateLimitPerMinute returns a handler that limits requests per-minute based on IP, endpoint, and user ID (if available).

func UserParam

func UserParam(r *http.Request) database.User

UserParam returns the user from the ExtractUserParam handler.

func WorkspaceAgent

func WorkspaceAgent(r *http.Request) database.WorkspaceAgent

WorkspaceAgent returns the workspace agent from the ExtractAgent handler.

func WorkspaceBuildParam

func WorkspaceBuildParam(r *http.Request) database.WorkspaceBuild

WorkspaceBuildParam returns the workspace build from the ExtractWorkspaceBuildParam handler.

func WorkspaceParam

func WorkspaceParam(r *http.Request) database.Workspace

WorkspaceParam returns the workspace from the ExtractWorkspaceParam handler.

func WorkspaceResourceParam

func WorkspaceResourceParam(r *http.Request) database.WorkspaceResource

ProvisionerJobParam returns the project from the ExtractProjectParam handler.

Types

type OAuth2Config

type OAuth2Config interface {
	TokenSource(context.Context, *oauth2.Token) oauth2.TokenSource
}

OAuth2Config contains a subset of functions exposed from oauth2.Config. It is abstracted for simple testing.

Jump to

Keyboard shortcuts

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