api

package
v0.83.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxPerPage is the maximum amount of results returned for paginated queries to the API
	DefaultMaxPerPage int = 1000

	UserContextKey contextKey = "user"

	DefaultMaxDeleteObjects = 1000
)
View Source
const (
	DefaultLoginExpiration         = 7 * 24 * time.Hour
	DefaultResetPasswordExpiration = 20 * time.Minute
	InternalAuthSessionName        = "internal_auth_session"
	TokenSessionKeyName            = "token"
	OIDCAuthSessionName            = "oidc_auth_session"

	LoginAudience = "login"
)
View Source
const (
	IDTokenClaimsSessionKey = "id_token_claims"
	StateSessionKey         = "state"
)
View Source
const (
	RequestIDHeaderName = "X-Request-ID"
	LoggerServiceName   = "rest_api"
	BaseURL             = "/api/v1"
)

Variables

View Source
var (
	ErrFailedToAccessStorage = errors.New("failed to access storage")
	ErrAuthenticatingRequest = errors.New("error authenticating request")
	ErrInvalidAPIEndpoint    = errors.New("invalid API endpoint")
	ErrRequestSizeExceeded   = errors.New("request size exceeded")
)

Functions

func AuthMiddleware added in v0.40.0

func AuthMiddleware(logger logging.Logger, swagger *openapi3.Swagger, authenticator auth.Authenticator, authService auth.Service, sessionStore sessions.Store, oidcConfig *config.OIDC) func(next http.Handler) http.Handler

func GenerateJWTLogin added in v0.63.0

func GenerateJWTLogin(secret []byte, userID string, issuedAt, expiresAt time.Time) (string, error)

GenerateJWTLogin creates a jwt token which can be used for authentication during login only, i.e. it will not work for password reset. It supports backward compatibility for creating a login jwt. The audience is not set for login token. Any audience will make the token invalid for login. No email is passed to support the ability of login for users via user/access keys which don't have an email yet

func Int64Ptr added in v0.40.0

func Int64Ptr(n int64) *int64

func Int64Value added in v0.40.0

func Int64Value(p *int64) int64

func InvalidAPIEndpointHandler added in v0.48.0

func InvalidAPIEndpointHandler(w http.ResponseWriter, _ *http.Request)

InvalidAPIEndpointHandler returns ErrInvalidAPIEndpoint, and is currently being used to ensure that routes under the pattern it is used with in chi.Router.Mount (i.e. /api/v1) are not accessible.

func IsStatusCodeOK added in v0.40.0

func IsStatusCodeOK(statusCode int) bool

func MetricsMiddleware added in v0.40.0

func MetricsMiddleware(swagger *openapi3.Swagger) func(http.Handler) http.Handler

func NewHandlerWithDefault

func NewHandlerWithDefault(fileSystem http.FileSystem, handler http.Handler, gatewayDomains []string) http.Handler

func NewInjectIndexFS added in v0.66.0

func NewInjectIndexFS(fsys fs.FS, name string, marker string, snippets []params.CodeSnippet) (fs.FS, error)

func NewLogoutHandler

func NewLogoutHandler(sessionStore sessions.Store, logger logging.Logger, logoutRedirectURL string) http.HandlerFunc

NewLogoutHandler returns a handler to clear the user sessions and redirect the user to the login page.

func NewOIDCLoginPageHandler added in v0.69.0

func NewOIDCLoginPageHandler(oidcConfig config.OIDC, sessionStore sessions.Store, oauthConfig *oauth2.Config, logger logging.Logger) http.HandlerFunc

NewOIDCLoginPageHandler returns a handler to redirect the user the OIDC provider's login page.

func NewS3GatewayEndpointErrorHandler added in v0.70.2

func NewS3GatewayEndpointErrorHandler(gatewayDomains []string) http.Handler

func NewUIHandler

func NewUIHandler(gatewayDomains []string, snippets []params.CodeSnippet) http.Handler

func OapiRequestValidatorWithOptions added in v0.40.0

func OapiRequestValidatorWithOptions(swagger *openapi3.Swagger, options *openapi3filter.Options) func(http.Handler) http.Handler

OapiRequestValidatorWithOptions Creates middleware to validate request by swagger spec. This middleware is good for net/http either since go-chi is 100% compatible with net/http. The original implementation can be found at https://github.com/deepmap/oapi-codegen/blob/master/pkg/chi-middleware/oapi_validate.go Used our own implementation in order to:

  1. Use the latest version kin-openapi (can switch back when oapi-codegen will be updated)
  2. For file upload wanted to skip body validation for two reasons: a. didn't find a way for the validator to accept any file content type b. didn't want the validator to read the complete request body for the specific request

func Serve

func Serve(
	cfg *config.Config,
	catalog catalog.Interface,
	middlewareAuthenticator auth.Authenticator,
	controllerAuthenticator auth.Authenticator,
	authService auth.Service,
	blockAdapter block.Adapter,
	metadataManager auth.MetadataManager,
	migrator db.Migrator,
	collector stats.Collector,
	cloudMetadataProvider cloud.MetadataProvider,
	actions actionsHandler,
	auditChecker AuditChecker,
	logger logging.Logger,
	emailer *email.Emailer,
	templater templater.Service,
	gatewayDomains []string,
	snippets []params.CodeSnippet,
	oidcProvider *oidc.Provider,
	oauthConfig *oauth2.Config,
) http.Handler

func StringPtr added in v0.40.0

func StringPtr(s string) *string

func StringValue added in v0.40.0

func StringValue(s *string) string

func VerifyResetPasswordToken added in v0.63.0

func VerifyResetPasswordToken(ctx context.Context, authService auth.Service, token string) (*jwt.StandardClaims, error)

Types

type AuditChecker added in v0.57.0

type AuditChecker interface {
	LastCheck() (*version.AuditResponse, error)
}

type Controller

type Controller struct {
	Config                *config.Config
	Catalog               catalog.Interface
	Authenticator         auth.Authenticator
	Auth                  auth.Service
	BlockAdapter          block.Adapter
	MetadataManager       auth.MetadataManager
	Migrator              db.Migrator
	Collector             stats.Collector
	CloudMetadataProvider cloud.MetadataProvider
	Actions               actionsHandler
	AuditChecker          AuditChecker
	Logger                logging.Logger
	Emailer               *email.Emailer
	Templater             templater.Service
	// contains filtered or unexported fields
}

func NewController

func NewController(
	cfg *config.Config,
	catalog catalog.Interface,
	authenticator auth.Authenticator,
	authService auth.Service,
	blockAdapter block.Adapter,
	metadataManager auth.MetadataManager,
	migrator db.Migrator,
	collector stats.Collector,
	cloudMetadataProvider cloud.MetadataProvider,
	actions actionsHandler,
	auditChecker AuditChecker,
	logger logging.Logger,
	emailer *email.Emailer,
	templater templater.Service,
	oidcAuthenticator *oidc.Authenticator,
	sessionStore sessions.Store,
) *Controller

func (*Controller) AddGroupMembership added in v0.40.0

func (c *Controller) AddGroupMembership(w http.ResponseWriter, r *http.Request, groupID string, userID string)

func (*Controller) AttachPolicyToGroup added in v0.40.0

func (c *Controller) AttachPolicyToGroup(w http.ResponseWriter, r *http.Request, groupID string, policyID string)

func (*Controller) AttachPolicyToUser added in v0.40.0

func (c *Controller) AttachPolicyToUser(w http.ResponseWriter, r *http.Request, userID string, policyID string)

func (*Controller) Commit added in v0.40.0

func (c *Controller) Commit(w http.ResponseWriter, r *http.Request, body CommitJSONRequestBody, repository string, branch string, params CommitParams)

func (*Controller) CreateBranch added in v0.40.0

func (c *Controller) CreateBranch(w http.ResponseWriter, r *http.Request, body CreateBranchJSONRequestBody, repository string)

func (*Controller) CreateBranchProtectionRule added in v0.52.0

func (c *Controller) CreateBranchProtectionRule(w http.ResponseWriter, r *http.Request, body CreateBranchProtectionRuleJSONRequestBody, repository string)

func (*Controller) CreateCredentials added in v0.40.0

func (c *Controller) CreateCredentials(w http.ResponseWriter, r *http.Request, userID string)

func (*Controller) CreateGroup added in v0.40.0

func (c *Controller) CreateGroup(w http.ResponseWriter, r *http.Request, body CreateGroupJSONRequestBody)

func (*Controller) CreateMetaRange added in v0.65.0

func (c *Controller) CreateMetaRange(w http.ResponseWriter, r *http.Request, body CreateMetaRangeJSONRequestBody, repository string)

func (*Controller) CreatePolicy added in v0.40.0

func (c *Controller) CreatePolicy(w http.ResponseWriter, r *http.Request, body CreatePolicyJSONRequestBody)

func (*Controller) CreateRepository added in v0.40.0

func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, body CreateRepositoryJSONRequestBody, params CreateRepositoryParams)

func (*Controller) CreateSymlinkFile added in v0.40.0

func (c *Controller) CreateSymlinkFile(w http.ResponseWriter, r *http.Request, repository string, branch string, params CreateSymlinkFileParams)

func (*Controller) CreateTag added in v0.40.0

func (c *Controller) CreateTag(w http.ResponseWriter, r *http.Request, body CreateTagJSONRequestBody, repository string)

func (*Controller) CreateUser added in v0.40.0

func (c *Controller) CreateUser(w http.ResponseWriter, r *http.Request, body CreateUserJSONRequestBody)

func (*Controller) DeleteBranch added in v0.40.0

func (c *Controller) DeleteBranch(w http.ResponseWriter, r *http.Request, repository string, branch string)

func (*Controller) DeleteBranchProtectionRule added in v0.52.0

func (c *Controller) DeleteBranchProtectionRule(w http.ResponseWriter, r *http.Request, body DeleteBranchProtectionRuleJSONRequestBody, repository string)

func (*Controller) DeleteCredentials added in v0.40.0

func (c *Controller) DeleteCredentials(w http.ResponseWriter, r *http.Request, userID string, accessKeyID string)

func (*Controller) DeleteGarbageCollectionRules added in v0.82.0

func (c *Controller) DeleteGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string)

func (*Controller) DeleteGroup added in v0.40.0

func (c *Controller) DeleteGroup(w http.ResponseWriter, r *http.Request, groupID string)

func (*Controller) DeleteGroupMembership added in v0.40.0

func (c *Controller) DeleteGroupMembership(w http.ResponseWriter, r *http.Request, groupID string, userID string)

func (*Controller) DeleteObject added in v0.40.0

func (c *Controller) DeleteObject(w http.ResponseWriter, r *http.Request, repository string, branch string, params DeleteObjectParams)

func (*Controller) DeleteObjects added in v0.57.0

func (c *Controller) DeleteObjects(w http.ResponseWriter, r *http.Request, body DeleteObjectsJSONRequestBody, repository string, branch string)

func (*Controller) DeletePolicy added in v0.40.0

func (c *Controller) DeletePolicy(w http.ResponseWriter, r *http.Request, policyID string)

func (*Controller) DeleteRepository added in v0.40.0

func (c *Controller) DeleteRepository(w http.ResponseWriter, r *http.Request, repository string)

func (*Controller) DeleteTag added in v0.40.0

func (c *Controller) DeleteTag(w http.ResponseWriter, r *http.Request, repository string, tag string)

func (*Controller) DeleteUser added in v0.40.0

func (c *Controller) DeleteUser(w http.ResponseWriter, r *http.Request, userID string)

func (*Controller) DetachPolicyFromGroup added in v0.40.0

func (c *Controller) DetachPolicyFromGroup(w http.ResponseWriter, r *http.Request, groupID string, policyID string)

func (*Controller) DetachPolicyFromUser added in v0.40.0

func (c *Controller) DetachPolicyFromUser(w http.ResponseWriter, r *http.Request, userID string, policyID string)

func (*Controller) DiffBranch added in v0.40.0

func (c *Controller) DiffBranch(w http.ResponseWriter, r *http.Request, repository string, branch string, params DiffBranchParams)

func (*Controller) DiffRefs added in v0.40.0

func (c *Controller) DiffRefs(w http.ResponseWriter, r *http.Request, repository string, leftRef string, rightRef string, params DiffRefsParams)

func (*Controller) DumpRefs added in v0.40.0

func (c *Controller) DumpRefs(w http.ResponseWriter, r *http.Request, repository string)

func (*Controller) ExpandTemplate added in v0.69.0

func (c *Controller) ExpandTemplate(w http.ResponseWriter, r *http.Request, templateLocation string, p ExpandTemplateParams)

func (*Controller) ForgotPassword added in v0.63.0

func (c *Controller) ForgotPassword(w http.ResponseWriter, r *http.Request, body ForgotPasswordJSONRequestBody)

func (*Controller) GetAuthCapabilities added in v0.64.0

func (c *Controller) GetAuthCapabilities(w http.ResponseWriter, _ *http.Request)

func (*Controller) GetBranch added in v0.40.0

func (c *Controller) GetBranch(w http.ResponseWriter, r *http.Request, repository string, branch string)

func (*Controller) GetBranchProtectionRules added in v0.52.0

func (c *Controller) GetBranchProtectionRules(w http.ResponseWriter, r *http.Request, repository string)

func (*Controller) GetCommit added in v0.40.0

func (c *Controller) GetCommit(w http.ResponseWriter, r *http.Request, repository string, commitID string)

func (*Controller) GetCredentials added in v0.40.0

func (c *Controller) GetCredentials(w http.ResponseWriter, r *http.Request, userID string, accessKeyID string)

func (*Controller) GetCurrentUser added in v0.40.0

func (c *Controller) GetCurrentUser(w http.ResponseWriter, r *http.Request)

func (*Controller) GetGarbageCollectionRules added in v0.43.0

func (c *Controller) GetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string)

func (*Controller) GetGroup added in v0.40.0

func (c *Controller) GetGroup(w http.ResponseWriter, r *http.Request, groupID string)

func (*Controller) GetLakeFSVersion added in v0.43.0

func (c *Controller) GetLakeFSVersion(w http.ResponseWriter, r *http.Request)

func (*Controller) GetMetaRange added in v0.40.0

func (c *Controller) GetMetaRange(w http.ResponseWriter, r *http.Request, repository string, metaRange string)

func (*Controller) GetObject added in v0.40.0

func (c *Controller) GetObject(w http.ResponseWriter, r *http.Request, repository string, ref string, params GetObjectParams)

func (*Controller) GetPhysicalAddress added in v0.40.0

func (c *Controller) GetPhysicalAddress(w http.ResponseWriter, r *http.Request, repository string, branch string, params GetPhysicalAddressParams)

func (*Controller) GetPolicy added in v0.40.0

func (c *Controller) GetPolicy(w http.ResponseWriter, r *http.Request, policyID string)

func (*Controller) GetRange added in v0.40.0

func (c *Controller) GetRange(w http.ResponseWriter, r *http.Request, repository string, pRange string)

func (*Controller) GetRepository added in v0.40.0

func (c *Controller) GetRepository(w http.ResponseWriter, r *http.Request, repository string)

func (*Controller) GetRun added in v0.40.0

func (c *Controller) GetRun(w http.ResponseWriter, r *http.Request, repository string, runID string)

func (*Controller) GetRunHookOutput added in v0.40.0

func (c *Controller) GetRunHookOutput(w http.ResponseWriter, r *http.Request, repository string, runID string, hookRunID string)

func (*Controller) GetSetupState added in v0.56.0

func (c *Controller) GetSetupState(w http.ResponseWriter, r *http.Request)

func (*Controller) GetStorageConfig added in v0.42.0

func (c *Controller) GetStorageConfig(w http.ResponseWriter, r *http.Request)

func (*Controller) GetTag added in v0.40.0

func (c *Controller) GetTag(w http.ResponseWriter, r *http.Request, repository string, tag string)

func (*Controller) GetUnderlyingProperties added in v0.40.0

func (c *Controller) GetUnderlyingProperties(w http.ResponseWriter, r *http.Request, repository string, ref string, params GetUnderlyingPropertiesParams)

func (*Controller) GetUser added in v0.40.0

func (c *Controller) GetUser(w http.ResponseWriter, r *http.Request, userID string)

func (*Controller) HealthCheck added in v0.40.0

func (c *Controller) HealthCheck(w http.ResponseWriter, _ *http.Request)

func (*Controller) IngestRange added in v0.65.0

func (c *Controller) IngestRange(w http.ResponseWriter, r *http.Request, body IngestRangeJSONRequestBody, repository string)

func (*Controller) LinkPhysicalAddress added in v0.40.0

func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request, body LinkPhysicalAddressJSONRequestBody, repository string, branch string, params LinkPhysicalAddressParams)

func (*Controller) ListBranches added in v0.40.0

func (c *Controller) ListBranches(w http.ResponseWriter, r *http.Request, repository string, params ListBranchesParams)

func (*Controller) ListGroupMembers added in v0.40.0

func (c *Controller) ListGroupMembers(w http.ResponseWriter, r *http.Request, groupID string, params ListGroupMembersParams)

func (*Controller) ListGroupPolicies added in v0.40.0

func (c *Controller) ListGroupPolicies(w http.ResponseWriter, r *http.Request, groupID string, params ListGroupPoliciesParams)

func (*Controller) ListGroups added in v0.40.0

func (c *Controller) ListGroups(w http.ResponseWriter, r *http.Request, params ListGroupsParams)

func (*Controller) ListObjects added in v0.40.0

func (c *Controller) ListObjects(w http.ResponseWriter, r *http.Request, repository string, ref string, params ListObjectsParams)

func (*Controller) ListPolicies added in v0.40.0

func (c *Controller) ListPolicies(w http.ResponseWriter, r *http.Request, params ListPoliciesParams)

func (*Controller) ListRepositories added in v0.40.0

func (c *Controller) ListRepositories(w http.ResponseWriter, r *http.Request, params ListRepositoriesParams)

func (*Controller) ListRepositoryRuns added in v0.40.0

func (c *Controller) ListRepositoryRuns(w http.ResponseWriter, r *http.Request, repository string, params ListRepositoryRunsParams)

func (*Controller) ListRunHooks added in v0.40.0

func (c *Controller) ListRunHooks(w http.ResponseWriter, r *http.Request, repository string, runID string, params ListRunHooksParams)

func (*Controller) ListTags added in v0.40.0

func (c *Controller) ListTags(w http.ResponseWriter, r *http.Request, repository string, params ListTagsParams)

func (*Controller) ListUserCredentials added in v0.40.0

func (c *Controller) ListUserCredentials(w http.ResponseWriter, r *http.Request, userID string, params ListUserCredentialsParams)

func (*Controller) ListUserGroups added in v0.40.0

func (c *Controller) ListUserGroups(w http.ResponseWriter, r *http.Request, userID string, params ListUserGroupsParams)

func (*Controller) ListUserPolicies added in v0.40.0

func (c *Controller) ListUserPolicies(w http.ResponseWriter, r *http.Request, userID string, params ListUserPoliciesParams)

func (*Controller) ListUsers added in v0.40.0

func (c *Controller) ListUsers(w http.ResponseWriter, r *http.Request, params ListUsersParams)

func (*Controller) LogAction

func (c *Controller) LogAction(ctx context.Context, action string, r *http.Request, repository, ref, sourceRef string)

func (*Controller) LogBranchCommits added in v0.40.0

func (c *Controller) LogBranchCommits(w http.ResponseWriter, r *http.Request, repository string, branch string, params LogBranchCommitsParams)

LogBranchCommits deprecated replaced by LogCommits

func (*Controller) LogCommits added in v0.40.0

func (c *Controller) LogCommits(w http.ResponseWriter, r *http.Request, repository string, ref string, params LogCommitsParams)

func (*Controller) Login added in v0.40.0

func (c *Controller) Login(w http.ResponseWriter, r *http.Request, body LoginJSONRequestBody)

func (*Controller) MergeIntoBranch added in v0.40.0

func (c *Controller) MergeIntoBranch(w http.ResponseWriter, r *http.Request, body MergeIntoBranchJSONRequestBody, repository string, sourceRef string, destinationBranch string)

func (*Controller) OauthCallback added in v0.69.0

func (c *Controller) OauthCallback(w http.ResponseWriter, r *http.Request)

OauthCallback gets a code generated by an OIDC provider. It exchanges the code for an id token, and saves the claims from the ID token on a session.

func (*Controller) PrepareGarbageCollectionCommits added in v0.43.0

func (c *Controller) PrepareGarbageCollectionCommits(w http.ResponseWriter, r *http.Request, body PrepareGarbageCollectionCommitsJSONRequestBody, repository string)

func (*Controller) ResetBranch added in v0.40.0

func (c *Controller) ResetBranch(w http.ResponseWriter, r *http.Request, body ResetBranchJSONRequestBody, repository string, branch string)

func (*Controller) RestoreRefs added in v0.40.0

func (c *Controller) RestoreRefs(w http.ResponseWriter, r *http.Request, body RestoreRefsJSONRequestBody, repository string)

func (*Controller) RevertBranch added in v0.40.0

func (c *Controller) RevertBranch(w http.ResponseWriter, r *http.Request, body RevertBranchJSONRequestBody, repository string, branch string)

func (*Controller) SetGarbageCollectionRules added in v0.43.0

func (c *Controller) SetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, body SetGarbageCollectionRulesJSONRequestBody, repository string)

func (*Controller) Setup added in v0.40.0

func (c *Controller) Setup(w http.ResponseWriter, r *http.Request, body SetupJSONRequestBody)

func (*Controller) StageObject added in v0.40.0

func (c *Controller) StageObject(w http.ResponseWriter, r *http.Request, body StageObjectJSONRequestBody, repository string, branch string, params StageObjectParams)

func (*Controller) StatObject added in v0.40.0

func (c *Controller) StatObject(w http.ResponseWriter, r *http.Request, repository string, ref string, params StatObjectParams)

func (*Controller) UpdatePassword added in v0.63.0

func (c *Controller) UpdatePassword(w http.ResponseWriter, r *http.Request, body UpdatePasswordJSONRequestBody)

func (*Controller) UpdatePolicy added in v0.40.0

func (c *Controller) UpdatePolicy(w http.ResponseWriter, r *http.Request, body UpdatePolicyJSONRequestBody, policyID string)

func (*Controller) UploadObject added in v0.40.0

func (c *Controller) UploadObject(w http.ResponseWriter, r *http.Request, repository string, branch string, params UploadObjectParams)

type InjectSnippetsFS added in v0.66.0

type InjectSnippetsFS struct {
	fs.FS
	// contains filtered or unexported fields
}

func (*InjectSnippetsFS) Open added in v0.66.0

func (i *InjectSnippetsFS) Open(name string) (fs.File, error)

type LoginRequestData

type LoginRequestData struct {
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
}

type LoginResponseData

type LoginResponseData struct {
	Token string `json:"token"`
}

Directories

Path Synopsis
Package helpers provides useful wrappers for clients using the lakeFS OpenAPI.
Package helpers provides useful wrappers for clients using the lakeFS OpenAPI.

Jump to

Keyboard shortcuts

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