Add REST API endpoints for submitting visual verification tasks,
tracking progress via SSE, and retrieving screenshot/video artifacts.
Changes:
- Add ScopeVerifyRead/ScopeVerifyWrite auth scopes
- Create VerifyService for task submission and lifecycle management
- Create VerifyHandler with POST/GET/DELETE/SSE endpoints:
- POST /verify - Submit capture task
- GET /verify/{taskId} - Get task status and artifacts
- GET /verify/{taskId}/stream - SSE progress stream
- DELETE /verify/{taskId} - Cancel pending task
- GET /projects/{id}/verify - List verify tasks
- Wire VerifyExecutor in main.go for Playwright pod execution
- Fix work.go validation to include "verify" task type
- Add comprehensive handler tests
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
74 lines
2.3 KiB
Go
74 lines
2.3 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
|
|
ScopeVerifyRead = domain.ScopeVerifyRead
|
|
ScopeVerifyWrite = domain.ScopeVerifyWrite
|
|
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
|
|
}
|