{"modulePath":"github.com/Stackdome/stackdome","version":"v0.0.7-alpha","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package auth\n\nPackage auth is a generated GoMock package.\n\nPackage auth is a generated GoMock package.\n\n## Constants\n\n```go\nconst (\n\tApiTokenPrefix  = \"sdm_\"\n\tApiTokenByteLen = 32\n)\n```\n\n```go\nconst (\n\tAuthenticationTokenKey AuthenticationToken = \"AuthToken\"\n\tContextUserKey         ContextUser         = \"UserInContext\"\n)\n```\n\n```go\nconst (\n\t// 30 days.\n\tRefreshTokenExpiry = 30 * 24 * time.Hour\n\t// 1 hour.\n\tJwtTokenExpiry = 1 * time.Hour\n)\n```\n\n```go\nconst (\n\tResourceStacks              = \"stacks\"\n\tResourceSecrets             = \"secrets\"\n\tResourceRegistryCredentials = \"registry-credentials\"\n\tResourceGitIntegrations     = \"git-integrations\"\n\tResourceVolumes             = \"volumes\"\n\tResourceAddonsPostgres      = \"addons/postgres\"\n\tResourceClusters            = \"clusters\"\n\tResourceImageRegistries     = \"image-registries\"\n\tResourceOrgs                = \"orgs\"\n\tResourceProjects            = \"projects\"\n\tResourceObjectStores        = \"object-stores\"\n\tResourceUsers               = \"users\"\n\tResourceImageBuilds         = \"image-builds\"\n\tResourceAddons              = \"addons\"\n\tResourceDomains             = \"domains\"\n\tResourceInvites             = \"invites\"\n\tResourcePreviewConfigs      = \"preview-configs\"\n\tResourcePreviewStacks       = \"preview-stacks\"\n)\n```\n\n```go\nconst (\n\tActionRead   = \"read\"\n\tActionWrite  = \"write\"\n\tActionDelete = \"delete\"\n\tActionCreate = \"create\"\n\tActionList   = \"list\"\n\tActionLogs   = \"logs\"\n\tActionExec   = \"exec\"\n\n\tScopeFullAccess = \"*:*\"\n)\n```\n\n```go\nconst DefaultAuthCookieName = \"auth_token\"\n```\n\n## Variables\n\n```go\nvar ResourceTypes = []ResourceType{\n\t{Name: ResourceStacks, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate, ActionLogs, ActionExec}},\n\t{Name: ResourceSecrets, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceRegistryCredentials, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceGitIntegrations, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceVolumes, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceClusters, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceImageRegistries, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceOrgs, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceAddonsPostgres, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate, ActionLogs, ActionExec}, Parent: ResourceAddons},\n\t{Name: ResourceObjectStores, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceUsers, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceImageBuilds, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceAddons, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate, ActionLogs, ActionExec}},\n\t{Name: ResourceDomains, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceProjects, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourceInvites, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourcePreviewConfigs, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n\t{Name: ResourcePreviewStacks, Actions: []string{ActionRead, ActionWrite, ActionDelete, ActionList, ActionCreate}},\n}\n```\n\n## Functions\n\n```go\nfunc CanAuthenticateWithAPIToken(r *http.Request) bool\n```\n\n```go\nfunc CanAuthenticateWithCookie(r *http.Request) bool\n```\n\n```go\nfunc ContactEmailFromCtx(ctx context.Context) string\n```\nContactEmailFromCtx resolves the contact email for the caller: the authenticated user's email, or the identity's ContactEmail for system identities. Empty when neither is present.\n\n```go\nfunc CreateRefreshToken(ctx context.Context, store stores.RefreshTokenStore, userID string) (string, error)\n```\n\n```go\nfunc DefaultPolicies() [][]string\n```\n\n```go\nfunc GetCurrentUserFromCtx(ctx context.Context) (*models.User, error)\n```\n\n```go\nfunc IsJwtTokenInCtx(ctx context.Context) bool\n```\n\n```go\nfunc LoadDefaultPolicies(addPolicy func(subject, domain, resource, action string) error) error\n```\n\n```go\nfunc NewAPITokenHandler(next http.Handler, spec ApiTokenAuthnHandlerSpec) http.Handler\n```\n\n```go\nfunc NewGitHubOAuthHandler(spec GitHubOAuthHandlerSpec) *gitHubOAuthHandler\n```\n\n```go\nfunc NewJwtAuthnHandler(next http.Handler, spec JWTAuthnHandlerSpec) http.Handler\n```\n\n```go\nfunc NewJwtCookieAuthnHandler(next http.Handler, spec JWTCookieAuthnHandlerSpec) http.Handler\n```\n\n```go\nfunc NewRefreshHandler(spec RefreshHandlerSpec) *refreshHandler\n```\n\n```go\nfunc ScopeCovers(grantedScope, requestedResource, requestedAction string) bool\n```\nScopeCovers returns true if grantedScope permits the requested resource and action. Supports wildcard matching: \"stacks:\\*\" covers \"stacks:read\", and \"addons:\\*\" covers \"addons/postgres:write\".\n\n```go\nfunc SetIdentityInContext(ctx context.Context, identity *Identity) context.Context\n```\n\n```go\nfunc SetUserInContext(ctx context.Context, user *models.User) context.Context\n```\n\n```go\nfunc ValidateScope(scope string) bool\n```\nValidateScope checks whether a scope string is valid against the resource type registry. Scopes use \"resource:action\" format. Wildcards are supported: \"\\*:\\*\" grants everything, \"stacks:\\*\" grants all actions on stacks, and \"addons:\\*\" covers child resources like \"addons/postgres\".\n\n## Types\n\n```go\ntype ApiTokenAuthnHandlerSpec struct {\n\tTokenLookup TokenLookup\n\tUserGetter  UserGetter\n}\n```\n\n```go\ntype AuthMethod string\n```\n\n```go\nconst (\n\tAuthMethodJWT      AuthMethod = \"jwt\"\n\tAuthMethodAPIToken AuthMethod = \"api_token\"\n\tAuthMethodOAuth    AuthMethod = \"oauth\"\n)\n```\n\n```go\ntype AuthenticationToken string\n```\n\n```go\ntype AuthnMiddleware interface {\n\tAuthenticateUser(next http.Handler) http.Handler\n\tGetAvailableAuthenticators() []authenticator\n}\n```\n\n```go\nfunc NewAuthMiddleware(userGetter UserGetter) AuthnMiddleware\n```\n\n```go\ntype Claims struct {\n\tUserID string `json:\"userId\"`\n\tRole   string `json:\"role\"`\n\tjwt.StandardClaims\n}\n```\n\n```go\ntype ContextUser string\n```\n\n```go\ntype GitHubOAuthHandlerSpec struct {\n\tClientID          string\n\tClientSecret      string\n\tRedirectURI       string\n\tOAuthUserService  oAuthUserService\n\tOAuthStateStore   stores.OAuthStateStore\n\tRefreshTokenStore stores.RefreshTokenStore\n\tJWTSecret         []byte\n\tJWTClaimsBuilder  JWTClaimsBuilder\n\tOrgInviteService  oAuthInviteService\n\tEncryptionService oAuthEncryptionService\n\tLogger            logger.Logger\n}\n```\n\n```go\ntype Identity struct {\n\tUserID      string\n\tOrgID       string\n\tRole        string\n\tAuthMethod  AuthMethod\n\tTokenID     string\n\tTokenScopes []string\n\tResourceIDs []string\n\tIsSystem    bool\n\t// ContactEmail carries the operator contact for system identities,\n\t// which have no backing user.\n\tContactEmail string\n}\n```\n\n```go\nfunc GetIdentityFromCtx(ctx context.Context) *Identity\n```\n\n```go\nfunc (i *Identity) IsOrgAdmin() bool\n```\n\n```go\ntype IdentityKey string\n```\n\n```go\ntype JWTAuthnHandlerSpec struct {\n\tJWTSecret  []byte\n\tUserGetter UserGetter\n}\n```\n\n```go\ntype JWTClaimsBuilder interface {\n\tBuildClaims(user *models.User, expirationTime time.Time) jwt.Claims\n}\n```\n\n```go\ntype JWTClaimsBuilderImpl struct{}\n```\n\n```go\nfunc NewJWTClaimsBuilder() *JWTClaimsBuilderImpl\n```\nNewJWTClaimsBuilder returns a new instance of JWTClaimsBuilder.\n\n```go\nfunc (c *JWTClaimsBuilderImpl) BuildClaims(user *models.User, expirationTime time.Time) jwt.Claims\n```\n\n```go\ntype JWTCookieAuthnHandlerSpec struct {\n\tJWTSecret  []byte\n\tUserGetter UserGetter\n}\n```\n\n```go\ntype JwtAuthPayload struct {\n\tUserID string `json:\"userId\"`\n\tRole   string `json:\"role\"`\n}\n```\n\n```go\nfunc GetJwtAuthPayloadFromContext(ctx context.Context) (*JwtAuthPayload, error)\n```\n\n```go\ntype MockAuthnMiddleware struct {\n\t// contains filtered or unexported fields\n}\n```\nMockAuthnMiddleware is a mock of AuthnMiddleware interface.\n\n```go\nfunc NewMockAuthnMiddleware(ctrl *gomock.Controller) *MockAuthnMiddleware\n```\nNewMockAuthnMiddleware creates a new mock instance.\n\n```go\nfunc (m *MockAuthnMiddleware) AuthenticateUser(next http.Handler) http.Handler\n```\nAuthenticateUser mocks base method.\n\n```go\nfunc (m *MockAuthnMiddleware) EXPECT() *MockAuthnMiddlewareMockRecorder\n```\nEXPECT returns an object that allows the caller to indicate expected use.\n\n```go\nfunc (m *MockAuthnMiddleware) GetAvailableAuthenticators() []authenticator\n```\nGetAvailableAuthenticators mocks base method.\n\n```go\ntype MockAuthnMiddlewareMockRecorder struct {\n\t// contains filtered or unexported fields\n}\n```\nMockAuthnMiddlewareMockRecorder is the mock recorder for MockAuthnMiddleware.\n\n```go\nfunc (mr *MockAuthnMiddlewareMockRecorder) AuthenticateUser(next any) *gomock.Call\n```\nAuthenticateUser indicates an expected call of AuthenticateUser.\n\n```go\nfunc (mr *MockAuthnMiddlewareMockRecorder) GetAvailableAuthenticators() *gomock.Call\n```\nGetAvailableAuthenticators indicates an expected call of GetAvailableAuthenticators.\n\n```go\ntype MockTokenLookup struct {\n\t// contains filtered or unexported fields\n}\n```\nMockTokenLookup is a mock of TokenLookup interface.\n\n```go\nfunc NewMockTokenLookup(ctrl *gomock.Controller) *MockTokenLookup\n```\nNewMockTokenLookup creates a new mock instance.\n\n```go\nfunc (m *MockTokenLookup) EXPECT() *MockTokenLookupMockRecorder\n```\nEXPECT returns an object that allows the caller to indicate expected use.\n\n```go\nfunc (m *MockTokenLookup) ValidateToken(ctx context.Context, rawToken string) (*models.APIToken, *errors.ServiceError)\n```\nValidateToken mocks base method.\n\n```go\ntype MockTokenLookupMockRecorder struct {\n\t// contains filtered or unexported fields\n}\n```\nMockTokenLookupMockRecorder is the mock recorder for MockTokenLookup.\n\n```go\nfunc (mr *MockTokenLookupMockRecorder) ValidateToken(ctx, rawToken any) *gomock.Call\n```\nValidateToken indicates an expected call of ValidateToken.\n\n```go\ntype MockUserGetter struct {\n\t// contains filtered or unexported fields\n}\n```\nMockUserGetter is a mock of UserGetter interface.\n\n```go\nfunc NewMockUserGetter(ctrl *gomock.Controller) *MockUserGetter\n```\nNewMockUserGetter creates a new mock instance.\n\n```go\nfunc (m *MockUserGetter) EXPECT() *MockUserGetterMockRecorder\n```\nEXPECT returns an object that allows the caller to indicate expected use.\n\n```go\nfunc (m *MockUserGetter) InternalGet(ctx context.Context, ID string) (*models.User, *errors.ServiceError)\n```\nInternalGet mocks base method.\n\n```go\ntype MockUserGetterMockRecorder struct {\n\t// contains filtered or unexported fields\n}\n```\nMockUserGetterMockRecorder is the mock recorder for MockUserGetter.\n\n```go\nfunc (mr *MockUserGetterMockRecorder) InternalGet(ctx, ID any) *gomock.Call\n```\nInternalGet indicates an expected call of InternalGet.\n\n```go\ntype Mockauthenticator struct {\n\t// contains filtered or unexported fields\n}\n```\nMockauthenticator is a mock of authenticator interface.\n\n```go\nfunc NewMockauthenticator(ctrl *gomock.Controller) *Mockauthenticator\n```\nNewMockauthenticator creates a new mock instance.\n\n```go\nfunc (m *Mockauthenticator) AuthenticaticationHandler(w http.ResponseWriter, r *http.Request, next http.Handler)\n```\nAuthenticaticationHandler mocks base method.\n\n```go\nfunc (m *Mockauthenticator) EXPECT() *MockauthenticatorMockRecorder\n```\nEXPECT returns an object that allows the caller to indicate expected use.\n\n```go\nfunc (m *Mockauthenticator) Select(requestCtx context.Context) bool\n```\nSelect mocks base method.\n\n```go\ntype MockauthenticatorMockRecorder struct {\n\t// contains filtered or unexported fields\n}\n```\nMockauthenticatorMockRecorder is the mock recorder for Mockauthenticator.\n\n```go\nfunc (mr *MockauthenticatorMockRecorder) AuthenticaticationHandler(w, r, next any) *gomock.Call\n```\nAuthenticaticationHandler indicates an expected call of AuthenticaticationHandler.\n\n```go\nfunc (mr *MockauthenticatorMockRecorder) Select(requestCtx any) *gomock.Call\n```\nSelect indicates an expected call of Select.\n\n```go\ntype PermissionService interface {\n\tCheck(ctx context.Context, domain, resource, resourceID, action string) *errors.ServiceError\n}\n```\n\n```go\nfunc NewPermissionService(spec PermissionServiceSpec) PermissionService\n```\n\n```go\ntype PermissionServiceSpec struct {\n\tPolicyManager resourceaccess.ResourceAccessPolicyManager\n\tProjectStore  stores.ProjectStore\n\tLogger        logger.Logger\n}\n```\n\n```go\ntype RefreshHandlerSpec struct {\n\tRefreshTokenStore stores.RefreshTokenStore\n\tUserGetter        UserGetter\n\tJWTSecret         []byte\n\tJWTClaimsBuilder  JWTClaimsBuilder\n}\n```\n\n```go\ntype ResourceType struct {\n\tName    string\n\tParent  string // Optional parent resource for hierarchical permissions (e.g. \"addons\" is parent of \"addons/postgres\")\n\tActions []string\n}\n```\n\n```go\ntype TokenLookup interface {\n\tValidateToken(ctx context.Context, rawToken string) (*models.APIToken, *errors.ServiceError)\n}\n```\nTokenLookup validates a raw token and returns the stored token record.\n\n```go\ntype UserGetter interface {\n\tInternalGet(ctx context.Context, ID string) (*models.User, *errors.ServiceError)\n}\n```\n\n","path":"github.com/Stackdome/stackdome/pkg/auth","name":"auth","synopsis":"Package auth is a generated GoMock package.","isRedistributable":true}
