rdev/internal/auth/scopes.go
jordan bc47e426b0 feat: Add CI pipeline proxy, DNS alias management, and worker executor system
- Add ListPipelines/GetPipeline to CIProvider port with Woodpecker adapter
- Add DNS alias endpoints: GET/POST/DELETE /projects/{id}/domains
- Implement worker executor daemon, build executor, and git operations
- Add build service, worker service, and build audit tracking
- Add worker registry with PostgreSQL adapter and migration
- Add multi-provider code agent interface (Claude Code + OpenCode)
- Add create-and-build combo endpoint
- Update landing-page cookbook to reflect all gaps closed
- Fix tech debt: unified validation, auth scopes, error wrapping, slog patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:05:28 -07:00

72 lines
2.2 KiB
Go

package auth
import "github.com/orchard9/rdev/internal/domain"
// Scope is an alias for domain.Scope.
// All scope constants, helpers, and validation live in domain/apikey.go.
type Scope = domain.Scope
// Re-exported scope constants for backward compatibility.
// Consumers should migrate to domain.ScopeXxx over time.
const (
ScopeProjectsRead = domain.ScopeProjectsRead
ScopeProjectsExecute = domain.ScopeProjectsExecute
ScopeKeysRead = domain.ScopeKeysRead
ScopeKeysWrite = domain.ScopeKeysWrite
ScopeAuditRead = domain.ScopeAuditRead
ScopeQueueRead = domain.ScopeQueueRead
ScopeQueueWrite = domain.ScopeQueueWrite
ScopeWebhookRead = domain.ScopeWebhookRead
ScopeWebhookWrite = domain.ScopeWebhookWrite
ScopeWorkersRead = domain.ScopeWorkersRead
ScopeWorkersWrite = domain.ScopeWorkersWrite
ScopeBuildRead = domain.ScopeBuildRead
ScopeBuildWrite = domain.ScopeBuildWrite
ScopeAdmin = domain.ScopeAdmin
)
// Re-exported scope helpers for backward compatibility.
var (
AllScopes = domain.AllScopes
ScopeDescriptions = domain.ScopeDescriptions
)
// ScopesFromStrings converts string slice to Scope slice.
func ScopesFromStrings(ss []string) []Scope {
return domain.ScopesFromStrings(ss)
}
// ScopesToStrings converts Scope slice to string slice.
func ScopesToStrings(scopes []Scope) []string {
return domain.ScopesToStrings(scopes)
}
// ValidateScopes checks if all scopes are valid.
func ValidateScopes(scopes []Scope) bool {
return domain.ValidateScopes(scopes)
}
// HasScope checks if a scope list contains a required scope.
func HasScope(scopes []Scope, required Scope) bool {
return domain.HasScope(scopes, required)
}
// HasAnyScope checks if a scope list contains any of the required scopes.
func HasAnyScope(scopes []Scope, required ...Scope) bool {
return domain.HasAnyScope(scopes, required...)
}
// HasProjectAccess checks if the key has access to a specific project.
// projectIDs nil means access to all projects.
func HasProjectAccess(allowedProjects []string, projectID string) bool {
if allowedProjects == nil {
return true
}
for _, p := range allowedProjects {
if p == projectID {
return true
}
}
return false
}