Documentation
¶
Index ¶
- Variables
- func MapTenantRole(roleName string) string
- type AccessTokenRepository
- type AssignmentRepository
- func (r *AssignmentRepository) CheckExists(ctx context.Context, roleID string, scope role.Scope, scopeContextID *string) (bool, error)
- func (r *AssignmentRepository) DeleteByContextID(ctx context.Context, scope role.Scope, contextID string) error
- func (r *AssignmentRepository) Grant(ctx context.Context, a *role.Assignment) error
- func (r *AssignmentRepository) ListByRole(ctx context.Context, roleID string, scope role.Scope, scopeContextID *string) ([]string, error)
- func (r *AssignmentRepository) ListForUser(ctx context.Context, userID string) ([]*role.Assignment, error)
- func (r *AssignmentRepository) Revoke(ctx context.Context, userID, roleID string, scope role.Scope, ...) error
- type AuditRepository
- type AuthorizationCodeRepository
- func (r *AuthorizationCodeRepository) Create(c *client.AuthorizationCode) error
- func (r *AuthorizationCodeRepository) Delete(code string) error
- func (r *AuthorizationCodeRepository) DeleteExpired() error
- func (r *AuthorizationCodeRepository) GetByCode(codeStr string) (*client.AuthorizationCode, error)
- func (r *AuthorizationCodeRepository) MarkAsUsed(code string) error
- type ClientRepository
- func (r *ClientRepository) Create(ctx context.Context, c *client.Client) error
- func (r *ClientRepository) Delete(ctx context.Context, tenantID string, id string) error
- func (r *ClientRepository) DeleteByTenantID(ctx context.Context, tenantID string) error
- func (r *ClientRepository) GetByClientID(ctx context.Context, tenantID string, clientID string) (*client.Client, error)
- func (r *ClientRepository) GetByID(ctx context.Context, tenantID string, id string) (*client.Client, error)
- func (r *ClientRepository) ListByOwner(ctx context.Context, ownerID string) ([]*client.Client, error)
- func (r *ClientRepository) ListByTenant(ctx context.Context, tenantID string) ([]*client.Client, error)
- func (r *ClientRepository) Update(ctx context.Context, c *client.Client) error
- type Config
- type DB
- type MembershipRepository
- func (r *MembershipRepository) AddMember(ctx context.Context, m *tenant.Membership) error
- func (r *MembershipRepository) CheckMembership(ctx context.Context, tenantID, userID string) (bool, error)
- func (r *MembershipRepository) DeleteByTenantID(ctx context.Context, tenantID string) error
- func (r *MembershipRepository) ListMembers(ctx context.Context, tenantID string) ([]*tenant.Membership, error)
- func (r *MembershipRepository) RemoveMember(ctx context.Context, tenantID, userID string) error
- type PolicyAssignmentRepository
- func (pr *PolicyAssignmentRepository) CheckExists(ctx context.Context, roleID string, scope policy.Scope, scopeContextID *string) (bool, error)
- func (pr *PolicyAssignmentRepository) DeleteByContextID(ctx context.Context, scope policy.Scope, contextID string) error
- func (pr *PolicyAssignmentRepository) Grant(ctx context.Context, a *policy.Assignment) error
- func (pr *PolicyAssignmentRepository) ListByRole(ctx context.Context, roleID string, scope policy.Scope, scopeContextID *string) ([]string, error)
- func (pr *PolicyAssignmentRepository) ListForUser(ctx context.Context, userID string) ([]*policy.Assignment, error)
- func (pr *PolicyAssignmentRepository) Revoke(ctx context.Context, userID, roleID string, scope policy.Scope, ...) error
- type PolicyProjectRepository
- type ProjectRepository
- func (r *ProjectRepository) Create(ctx context.Context, p *project.Project) error
- func (r *ProjectRepository) CreatePolicy(ctx context.Context, p *policy.Project) error
- func (r *ProjectRepository) Delete(ctx context.Context, id string) error
- func (r *ProjectRepository) GetByID(ctx context.Context, id string) (*project.Project, error)
- func (r *ProjectRepository) GetByIDPolicy(ctx context.Context, id string) (*policy.Project, error)
- func (r *ProjectRepository) GetByName(ctx context.Context, name string) (*project.Project, error)
- func (r *ProjectRepository) ListByOwner(ctx context.Context, ownerID string) ([]*project.Project, error)
- func (r *ProjectRepository) ListByUser(ctx context.Context, userID string) ([]*project.Project, error)
- func (r *ProjectRepository) Update(ctx context.Context, p *project.Project) error
- type RefreshTokenRepository
- type RoleRepository
- func (r *RoleRepository) Create(ctx context.Context, ro *role.Role) error
- func (r *RoleRepository) Delete(ctx context.Context, id string) error
- func (r *RoleRepository) GetByID(ctx context.Context, id string) (*role.Role, error)
- func (r *RoleRepository) GetByName(ctx context.Context, name string, scope role.Scope) (*role.Role, error)
- func (r *RoleRepository) List(ctx context.Context, scope *role.Scope) ([]*role.Role, error)
- func (r *RoleRepository) Update(ctx context.Context, ro *role.Role) error
- type SessionRepository
- func (r *SessionRepository) Create(ctx context.Context, sess *session.Session) error
- func (r *SessionRepository) Delete(ctx context.Context, sessionID string) error
- func (r *SessionRepository) DeleteByUserID(ctx context.Context, userID string) error
- func (r *SessionRepository) DeleteExpired(ctx context.Context) error
- func (r *SessionRepository) Get(ctx context.Context, sessionID string) (*session.Session, error)
- func (r *SessionRepository) Update(ctx context.Context, sess *session.Session) error
- type TenantRepository
- func (r *TenantRepository) Create(ctx context.Context, t *tenant.Tenant) error
- func (r *TenantRepository) Delete(ctx context.Context, id string) error
- func (r *TenantRepository) GetByID(ctx context.Context, id string) (*tenant.Tenant, error)
- func (r *TenantRepository) GetByName(ctx context.Context, name string) (*tenant.Tenant, error)
- func (r *TenantRepository) List(ctx context.Context, limit, offset int) ([]*tenant.Tenant, error)
- func (r *TenantRepository) Update(ctx context.Context, t *tenant.Tenant) error
- type TenantRoleRepository
- func (r *TenantRoleRepository) AssignRole(ctx context.Context, tenantID, userID, roleName, grantedBy string) error
- func (r *TenantRoleRepository) DeleteByTenantID(ctx context.Context, tenantID string) error
- func (r *TenantRoleRepository) GetTenantUsers(ctx context.Context, tenantID string) ([]*tenant.TenantUserRole, error)
- func (r *TenantRoleRepository) GetUserRoles(ctx context.Context, tenantID, userID string) ([]*tenant.TenantUserRole, error)
- func (r *TenantRoleRepository) RevokeRole(ctx context.Context, tenantID, userID, roleName string) error
- type UserRepository
- func (r *UserRepository) AddCredentials(ctx context.Context, c *user.Credentials) error
- func (r *UserRepository) Create(ctx context.Context, u *user.User) error
- func (r *UserRepository) Delete(ctx context.Context, id string) error
- func (r *UserRepository) GetByHash(ctx context.Context, hash string) (*user.User, error)
- func (r *UserRepository) GetByID(ctx context.Context, id string) (*user.User, error)
- func (r *UserRepository) GetCredentials(ctx context.Context, userID string) (*user.Credentials, error)
- func (r *UserRepository) Update(ctx context.Context, u *user.User) error
- func (r *UserRepository) UpdateLockout(ctx context.Context, userID string, failedAttempts int, lockedUntil *time.Time) error
- func (r *UserRepository) UpdatePassword(ctx context.Context, userID string, passwordHash string) error
Constants ¶
This section is empty.
Variables ¶
var InitialSchema string
Functions ¶
func MapTenantRole ¶
MapTenantRole maps internal tenant role names to seeded RBAC role IDs
Types ¶
type AccessTokenRepository ¶
type AccessTokenRepository struct {
// contains filtered or unexported fields
}
AccessTokenRepository implements client.AccessTokenRepository
func NewAccessTokenRepository ¶
func NewAccessTokenRepository(db *DB) *AccessTokenRepository
NewAccessTokenRepository creates a new access token repository
func (*AccessTokenRepository) Create ¶
func (r *AccessTokenRepository) Create(t *client.AccessToken) error
Create creates a new access token
func (*AccessTokenRepository) DeleteExpired ¶
func (r *AccessTokenRepository) DeleteExpired() error
DeleteExpired deletes all expired access tokens
func (*AccessTokenRepository) GetByTokenHash ¶
func (r *AccessTokenRepository) GetByTokenHash(tokenHash string) (*client.AccessToken, error)
GetByTokenHash retrieves an access token
func (*AccessTokenRepository) Revoke ¶
func (r *AccessTokenRepository) Revoke(tokenHash string) error
Revoke revokes an access token
type AssignmentRepository ¶
type AssignmentRepository struct {
// contains filtered or unexported fields
}
AssignmentRepository implements role.AssignmentRepository
func NewAssignmentRepository ¶
func NewAssignmentRepository(db *DB) *AssignmentRepository
NewAssignmentRepository creates a new assignment repository
func (*AssignmentRepository) CheckExists ¶
func (r *AssignmentRepository) CheckExists(ctx context.Context, roleID string, scope role.Scope, scopeContextID *string) (bool, error)
CheckExists checks if a specific assignment exists
func (*AssignmentRepository) DeleteByContextID ¶
func (r *AssignmentRepository) DeleteByContextID(ctx context.Context, scope role.Scope, contextID string) error
DeleteByContextID removes all assignments for a specific scope and context
func (*AssignmentRepository) Grant ¶
func (r *AssignmentRepository) Grant(ctx context.Context, a *role.Assignment) error
Grant assigns a role to a user
func (*AssignmentRepository) ListByRole ¶
func (r *AssignmentRepository) ListByRole(ctx context.Context, roleID string, scope role.Scope, scopeContextID *string) ([]string, error)
ListByRole retrieves all users assigned a specific role at a scope
func (*AssignmentRepository) ListForUser ¶
func (r *AssignmentRepository) ListForUser(ctx context.Context, userID string) ([]*role.Assignment, error)
ListForUser retrieves all assignments for a user
type AuditRepository ¶
type AuditRepository struct {
// contains filtered or unexported fields
}
AuditRepository implements audit.Repository
func NewAuditRepository ¶
func NewAuditRepository(db *DB) *AuditRepository
NewAuditRepository creates a new audit repository
type AuthorizationCodeRepository ¶
type AuthorizationCodeRepository struct {
// contains filtered or unexported fields
}
AuthorizationCodeRepository implements client.AuthorizationCodeRepository
func NewAuthorizationCodeRepository ¶
func NewAuthorizationCodeRepository(db *DB) *AuthorizationCodeRepository
NewAuthorizationCodeRepository creates a new authorization code repository
func (*AuthorizationCodeRepository) Create ¶
func (r *AuthorizationCodeRepository) Create(c *client.AuthorizationCode) error
Create creates a new authorization code
func (*AuthorizationCodeRepository) Delete ¶
func (r *AuthorizationCodeRepository) Delete(code string) error
Delete deletes an authorization code
func (*AuthorizationCodeRepository) DeleteExpired ¶
func (r *AuthorizationCodeRepository) DeleteExpired() error
DeleteExpired deletes all expired authorization codes
func (*AuthorizationCodeRepository) GetByCode ¶
func (r *AuthorizationCodeRepository) GetByCode(codeStr string) (*client.AuthorizationCode, error)
GetByCode retrieves an authorization code
func (*AuthorizationCodeRepository) MarkAsUsed ¶
func (r *AuthorizationCodeRepository) MarkAsUsed(code string) error
MarkAsUsed marks the code as used
type ClientRepository ¶
type ClientRepository struct {
// contains filtered or unexported fields
}
ClientRepository implements client.ClientRepository
func NewClientRepository ¶
func NewClientRepository(db *DB) *ClientRepository
NewClientRepository creates a new client repository
func (*ClientRepository) DeleteByTenantID ¶
func (r *ClientRepository) DeleteByTenantID(ctx context.Context, tenantID string) error
DeleteByTenantID soft-deletes all clients belonging to a tenant
func (*ClientRepository) GetByClientID ¶
func (r *ClientRepository) GetByClientID(ctx context.Context, tenantID string, clientID string) (*client.Client, error)
GetByClientID retrieves a client by client_id and tenant_id
func (*ClientRepository) GetByID ¶
func (r *ClientRepository) GetByID(ctx context.Context, tenantID string, id string) (*client.Client, error)
GetByID retrieves a client by tenant_id and internal ID
func (*ClientRepository) ListByOwner ¶
func (r *ClientRepository) ListByOwner(ctx context.Context, ownerID string) ([]*client.Client, error)
ListByOwner retrieves all clients for an owner
func (*ClientRepository) ListByTenant ¶
func (r *ClientRepository) ListByTenant(ctx context.Context, tenantID string) ([]*client.Client, error)
ListByTenant retrieves all clients for a tenant
type Config ¶
type Config struct {
Host string
Port string
User string
Password string
Database string
SSLMode string
MaxOpenConns int
MaxIdleConns int
}
Config holds database configuration.
Purpose: Structured configuration for establishing database connectivity. Domain: Platform (Infrastructure)
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps the PostgreSQL connection pool.
Purpose: Primary handle for PostgreSQL database interactions. Domain: Platform (Infrastructure)
func New ¶
New creates a new database connection.
Purpose: Factory for the primary database handle using structured config. Domain: Platform (Infrastructure) Audited: No Errors: Connectivity and configuration errors
func SetupTestDB ¶
SetupTestDB creates a connection to the test database and runs migrations.
type MembershipRepository ¶
type MembershipRepository struct {
// contains filtered or unexported fields
}
MembershipRepository implements tenant.MembershipRepository
func NewMembershipRepository ¶
func NewMembershipRepository(db *DB) *MembershipRepository
NewMembershipRepository creates a new membership repository
func (*MembershipRepository) AddMember ¶
func (r *MembershipRepository) AddMember(ctx context.Context, m *tenant.Membership) error
AddMember inserts a new membership record
func (*MembershipRepository) CheckMembership ¶
func (r *MembershipRepository) CheckMembership(ctx context.Context, tenantID, userID string) (bool, error)
CheckMembership checks if a user is a member of a tenant
func (*MembershipRepository) DeleteByTenantID ¶
func (r *MembershipRepository) DeleteByTenantID(ctx context.Context, tenantID string) error
DeleteByTenantID removes all memberships for a tenant
func (*MembershipRepository) ListMembers ¶
func (r *MembershipRepository) ListMembers(ctx context.Context, tenantID string) ([]*tenant.Membership, error)
ListMembers retrieves all memberships for a tenant
func (*MembershipRepository) RemoveMember ¶
func (r *MembershipRepository) RemoveMember(ctx context.Context, tenantID, userID string) error
RemoveMember removes a specific membership record
type PolicyAssignmentRepository ¶
type PolicyAssignmentRepository struct {
// contains filtered or unexported fields
}
PolicyAssignmentRepository implements policy.AssignmentRepository
func NewPolicyAssignmentRepository ¶
func NewPolicyAssignmentRepository(db *DB) *PolicyAssignmentRepository
func (*PolicyAssignmentRepository) CheckExists ¶
func (*PolicyAssignmentRepository) DeleteByContextID ¶
func (*PolicyAssignmentRepository) Grant ¶
func (pr *PolicyAssignmentRepository) Grant(ctx context.Context, a *policy.Assignment) error
func (*PolicyAssignmentRepository) ListByRole ¶
func (*PolicyAssignmentRepository) ListForUser ¶
func (pr *PolicyAssignmentRepository) ListForUser(ctx context.Context, userID string) ([]*policy.Assignment, error)
type PolicyProjectRepository ¶
type PolicyProjectRepository struct {
// contains filtered or unexported fields
}
type ProjectRepository ¶
type ProjectRepository struct {
// contains filtered or unexported fields
}
ProjectRepository implements project.ProjectRepository and policy.ProjectRepository
func NewProjectRepository ¶
func NewProjectRepository(db *DB) *ProjectRepository
NewProjectRepository creates a new project repository
func (*ProjectRepository) CreatePolicy ¶
func (*ProjectRepository) Delete ¶
func (r *ProjectRepository) Delete(ctx context.Context, id string) error
Delete soft-deletes a project
func (*ProjectRepository) GetByIDPolicy ¶
func (*ProjectRepository) ListByOwner ¶
func (r *ProjectRepository) ListByOwner(ctx context.Context, ownerID string) ([]*project.Project, error)
ListByOwner retrieves all projects owned by a user
func (*ProjectRepository) ListByUser ¶
func (r *ProjectRepository) ListByUser(ctx context.Context, userID string) ([]*project.Project, error)
ListByUser retrieves all projects a user has access to
type RefreshTokenRepository ¶
type RefreshTokenRepository struct {
// contains filtered or unexported fields
}
RefreshTokenRepository implements client.RefreshTokenRepository
func NewRefreshTokenRepository ¶
func NewRefreshTokenRepository(db *DB) *RefreshTokenRepository
NewRefreshTokenRepository creates a new refresh token repository
func (*RefreshTokenRepository) Create ¶
func (r *RefreshTokenRepository) Create(t *client.RefreshToken) error
Create creates a new refresh token
func (*RefreshTokenRepository) DeleteExpired ¶
func (r *RefreshTokenRepository) DeleteExpired() error
DeleteExpired deletes all expired refresh tokens
func (*RefreshTokenRepository) GetByTokenHash ¶
func (r *RefreshTokenRepository) GetByTokenHash(tokenHash string) (*client.RefreshToken, error)
GetByTokenHash retrieves a refresh token
func (*RefreshTokenRepository) Revoke ¶
func (r *RefreshTokenRepository) Revoke(tokenHash string) error
Revoke revokes a refresh token
type RoleRepository ¶
type RoleRepository struct {
// contains filtered or unexported fields
}
RoleRepository implements role.RoleRepository and policy.RoleRepository
func NewRoleRepository ¶
func NewRoleRepository(db *DB) *RoleRepository
NewRoleRepository creates a new role repository
func (*RoleRepository) Delete ¶
func (r *RoleRepository) Delete(ctx context.Context, id string) error
Delete deletes a role
func (*RoleRepository) GetByName ¶
func (r *RoleRepository) GetByName(ctx context.Context, name string, scope role.Scope) (*role.Role, error)
GetByName retrieves a role by name and scope
type SessionRepository ¶
type SessionRepository struct {
// contains filtered or unexported fields
}
SessionRepository implements session.Repository
func NewSessionRepository ¶
func NewSessionRepository(db *DB) *SessionRepository
NewSessionRepository creates a new session repository
func (*SessionRepository) Delete ¶
func (r *SessionRepository) Delete(ctx context.Context, sessionID string) error
Delete deletes a session
func (*SessionRepository) DeleteByUserID ¶
func (r *SessionRepository) DeleteByUserID(ctx context.Context, userID string) error
DeleteByUserID deletes all sessions for a user
func (*SessionRepository) DeleteExpired ¶
func (r *SessionRepository) DeleteExpired(ctx context.Context) error
DeleteExpired deletes all expired sessions
type TenantRepository ¶
type TenantRepository struct {
// contains filtered or unexported fields
}
TenantRepository implements tenant.Repository
func NewTenantRepository ¶
func NewTenantRepository(db *DB) *TenantRepository
NewTenantRepository creates a new tenant repository
func (*TenantRepository) Delete ¶
func (r *TenantRepository) Delete(ctx context.Context, id string) error
Delete soft-deletes a tenant
type TenantRoleRepository ¶
type TenantRoleRepository struct {
// contains filtered or unexported fields
}
TenantRoleRepository implements tenant.RoleRepository
func NewTenantRoleRepository ¶
func NewTenantRoleRepository(db *DB) *TenantRoleRepository
NewTenantRoleRepository creates a new tenant role repository
func (*TenantRoleRepository) AssignRole ¶
func (r *TenantRoleRepository) AssignRole(ctx context.Context, tenantID, userID, roleName, grantedBy string) error
AssignRole assigns a role to a user in a tenant
func (*TenantRoleRepository) DeleteByTenantID ¶
func (r *TenantRoleRepository) DeleteByTenantID(ctx context.Context, tenantID string) error
DeleteByTenantID removes all role assignments for a specific tenant
func (*TenantRoleRepository) GetTenantUsers ¶
func (r *TenantRoleRepository) GetTenantUsers(ctx context.Context, tenantID string) ([]*tenant.TenantUserRole, error)
GetTenantUsers retrieves all users with roles in a tenant
func (*TenantRoleRepository) GetUserRoles ¶
func (r *TenantRoleRepository) GetUserRoles(ctx context.Context, tenantID, userID string) ([]*tenant.TenantUserRole, error)
GetUserRoles retrieves all roles a user has in a tenant
func (*TenantRoleRepository) RevokeRole ¶
func (r *TenantRoleRepository) RevokeRole(ctx context.Context, tenantID, userID, roleName string) error
RevokeRole revokes a role from a user in a tenant
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository implements user.UserRepository.
Purpose: PostgreSQL implementation of user identity persistence. Domain: Identity (Infrastructure)
func NewUserRepository ¶
func NewUserRepository(db *DB) *UserRepository
NewUserRepository creates a new user repository.
Purpose: Constructor for the user persistence layer. Domain: Identity (Infrastructure) Audited: No Errors: None
func (*UserRepository) AddCredentials ¶
func (r *UserRepository) AddCredentials(ctx context.Context, c *user.Credentials) error
AddCredentials adds credentials for a user
func (*UserRepository) Create ¶
Create creates a new user identity.
Purpose: Persists a new user record to the database. Domain: Identity (Infrastructure) Audited: No Errors: System errors
func (*UserRepository) Delete ¶
func (r *UserRepository) Delete(ctx context.Context, id string) error
Delete soft-deletes a user
func (*UserRepository) GetCredentials ¶
func (r *UserRepository) GetCredentials(ctx context.Context, userID string) (*user.Credentials, error)
GetCredentials retrieves user credentials
func (*UserRepository) UpdateLockout ¶
func (r *UserRepository) UpdateLockout(ctx context.Context, userID string, failedAttempts int, lockedUntil *time.Time) error
UpdateLockout updates user lockout status
func (*UserRepository) UpdatePassword ¶
func (r *UserRepository) UpdatePassword(ctx context.Context, userID string, passwordHash string) error
UpdatePassword updates user password