Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithPrincipal(ctx context.Context, principal *Principal) context.Context
- type PermissionGroup
- type Principal
- type Role
- type Service
- func (s *Service) AuthenticatePassword(ctx context.Context, username, password string) (*Session, *Principal, error)
- func (s *Service) AuthenticateSession(ctx context.Context, sessionID string) (*Principal, error)
- func (s *Service) AuthenticateToken(ctx context.Context, rawToken string) (*Principal, error)
- func (s *Service) Bootstrap(ctx context.Context) error
- func (s *Service) CreateToken(ctx context.Context, userID, name string) (*Token, string, error)
- func (s *Service) DeleteRole(ctx context.Context, roleID string) error
- func (s *Service) DeleteUser(ctx context.Context, userID string) error
- func (s *Service) GetUser(ctx context.Context, userID string) (*StoredUser, error)
- func (s *Service) ListRoles(ctx context.Context) ([]Role, error)
- func (s *Service) ListTokens(ctx context.Context) ([]Token, error)
- func (s *Service) ListTokensByUser(ctx context.Context, userID string) ([]Token, error)
- func (s *Service) ListUsers(ctx context.Context) ([]StoredUser, error)
- func (s *Service) LogoutSession(ctx context.Context, sessionID string) error
- func (s *Service) RevokeToken(ctx context.Context, tokenID string) error
- func (s *Service) RevokeTokenForUser(ctx context.Context, userID, tokenID string) error
- func (s *Service) SetupInitialUser(ctx context.Context, username, password string) (*Session, *Principal, error)
- func (s *Service) SetupRequired(ctx context.Context) (bool, error)
- func (s *Service) UpsertRole(ctx context.Context, role Role) (*Role, error)
- func (s *Service) UpsertUser(ctx context.Context, user StoredUser, password string, roleIDs []string) (*StoredUser, error)
- type Session
- type Store
- type StoredToken
- type StoredUser
- type Token
- type User
Constants ¶
View Source
const ( PermissionIndexerReleasesRead = "indexer.releases.read" PermissionIndexerReleasesOverride = "indexer.releases.override" PermissionIndexerReleasesHide = "indexer.releases.hide" PermissionIndexerReleasesPurge = "indexer.releases.purge" PermissionIndexerRuntimeRead = "indexer.runtime.read" PermissionIndexerRuntimeRun = "indexer.runtime.run" PermissionIndexerRuntimePause = "indexer.runtime.pause" PermissionIndexerRuntimeConfigure = "indexer.runtime.configure" PermissionAdminSettingsRead = "admin.settings.read" PermissionAdminSettingsWrite = "admin.settings.write" PermissionAggregatorReleasesRead = "aggregator.releases.read" PermissionAggregatorRuntimeRead = "aggregator.runtime.read" PermissionAggregatorRuntimeConfigure = "aggregator.runtime.configure" PermissionGoNZBNetSearch = "gonzbnet.search" PermissionGoNZBNetGet = "gonzbnet.get" PermissionGoNZBNetResolveManifest = "gonzbnet.resolve_manifest" PermissionGoNZBNetViewTrustScore = "gonzbnet.view_trust_score" PermissionGoNZBNetViewSourceNode = "gonzbnet.view_source_node" PermissionGoNZBNetViewCoverage = "gonzbnet.view.coverage" PermissionGoNZBNetAdminRead = "gonzbnet.admin.read" PermissionGoNZBNetAdminWrite = "gonzbnet.admin.write" PermissionGoNZBNetAdminPeers = "gonzbnet.admin.peers" PermissionGoNZBNetAdminPools = "gonzbnet.admin.pools" PermissionGoNZBNetAdminModeration = "gonzbnet.admin.moderation" PermissionGoNZBNetAdminKeys = "gonzbnet.admin.keys" PermissionGoNZBNetAdminCoverage = "gonzbnet.admin.coverage" PermissionGoNZBNetAdminScanner = "gonzbnet.admin.scanner" PermissionGoNZBNetAdminValidator = "gonzbnet.admin.validator" PermissionGoNZBNetAdminScheduler = "gonzbnet.admin.scheduler" PermissionDownloadClientsSend = "download_clients.send" PermissionUploaderSubmissionsRead = "uploader.submissions.read" PermissionUploaderSubmissionsCreate = "uploader.submissions.create" PermissionUploaderSubmissionsReview = "uploader.submissions.review" PermissionUploaderPublicationsManage = "uploader.publications.manage" PermissionAuthUsersRead = "auth.users.read" PermissionAuthUsersWrite = "auth.users.write" PermissionAuthRolesRead = "auth.roles.read" PermissionAuthRolesWrite = "auth.roles.write" PermissionAuthTokensRead = "auth.tokens.read" PermissionAuthTokensWrite = "auth.tokens.write" )
Variables ¶
Functions ¶
Types ¶
type PermissionGroup ¶ added in v0.10.4
type PermissionGroup struct {
Label string `json:"label"`
Permissions []string `json:"permissions"`
}
func PermissionGroups ¶ added in v0.10.4
func PermissionGroups() []PermissionGroup
PermissionGroups is the canonical permission catalog presented by the API and used to validate custom roles.
type Principal ¶
type Principal struct {
UserID string
Username string
RoleIDs []string
Permissions map[string]struct{}
}
func PrincipalFromContext ¶ added in v0.9.0
type Role ¶
type Role struct {
ID string `json:"id"`
Name string `json:"name"`
Builtin bool `json:"builtin"`
Permissions []string `json:"permissions"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func DefaultRoles ¶
func DefaultRoles() []Role
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AuthenticatePassword ¶
func (*Service) AuthenticateSession ¶
func (*Service) AuthenticateToken ¶
func (*Service) CreateToken ¶
func (*Service) ListTokensByUser ¶
func (*Service) LogoutSession ¶
func (*Service) RevokeToken ¶
func (*Service) RevokeTokenForUser ¶
func (*Service) SetupInitialUser ¶
func (*Service) UpsertRole ¶
func (*Service) UpsertUser ¶
func (s *Service) UpsertUser(ctx context.Context, user StoredUser, password string, roleIDs []string) (*StoredUser, error)
type Store ¶
type Store interface {
EnsureAuthDefaults(ctx context.Context, roles []Role) error
CountAuthUsers(ctx context.Context) (int, error)
CreateInitialAuthUser(ctx context.Context, user StoredUser, roleIDs []string) error
GetAuthUserByUsername(ctx context.Context, username string) (*StoredUser, error)
GetAuthUserByID(ctx context.Context, userID string) (*StoredUser, error)
ListAuthUsers(ctx context.Context) ([]StoredUser, error)
UpsertAuthUser(ctx context.Context, user StoredUser) error
DeleteAuthUser(ctx context.Context, userID string) error
ListAuthRoles(ctx context.Context) ([]Role, error)
UpsertAuthRole(ctx context.Context, role Role) error
DeleteAuthRole(ctx context.Context, roleID string) error
ReplaceAuthUserRoles(ctx context.Context, userID string, roleIDs []string) error
ListAuthUserRoleIDs(ctx context.Context, userID string) ([]string, error)
CreateAuthSession(ctx context.Context, session Session) error
GetAuthSession(ctx context.Context, sessionID string) (*Session, error)
TouchAuthSession(ctx context.Context, sessionID string, seenAt time.Time) error
DeleteAuthSession(ctx context.Context, sessionID string) error
CreateAuthToken(ctx context.Context, token StoredToken) error
ListAuthTokens(ctx context.Context) ([]Token, error)
ListAuthTokensByUserID(ctx context.Context, userID string) ([]Token, error)
GetAuthTokenByHash(ctx context.Context, tokenHash string) (*StoredToken, error)
GetAuthTokenByID(ctx context.Context, tokenID string) (*StoredToken, error)
TouchAuthToken(ctx context.Context, tokenID string, seenAt time.Time) error
RevokeAuthToken(ctx context.Context, tokenID string) error
}
type StoredToken ¶
type StoredUser ¶
Click to show internal directories.
Click to hide internal directories.