photoprism/internal/acl/resource.go
Michael Mayer fed1d8ad95 Auth: Accept access token as passwd with fail rate limit #782 #808 #3943
Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-14 18:28:17 +01:00

57 lines
1.6 KiB
Go

package acl
import "strings"
// Resources that Roles can be granted Permission.
const (
ResourceFiles Resource = "files"
ResourceFolders Resource = "folders"
ResourceShares Resource = "shares"
ResourcePhotos Resource = "photos"
ResourceVideos Resource = "videos"
ResourceFavorites Resource = "favorites"
ResourceAlbums Resource = "albums"
ResourceMoments Resource = "moments"
ResourceCalendar Resource = "calendar"
ResourcePeople Resource = "people"
ResourcePlaces Resource = "places"
ResourceLabels Resource = "labels"
ResourceConfig Resource = "config"
ResourceSettings Resource = "settings"
ResourcePassword Resource = "password"
ResourceServices Resource = "services"
ResourceUsers Resource = "users"
ResourceSessions Resource = "sessions"
ResourceLogs Resource = "logs"
ResourceWebDAV Resource = "webdav"
ResourceMetrics Resource = "metrics"
ResourceFeedback Resource = "feedback"
ResourceDefault Resource = "default"
)
// Resource represents a resource for which roles can be granted Permission.
type Resource string
// String returns the type as string.
func (r Resource) String() string {
if r == "" {
return "default"
}
return string(r)
}
// LogId returns an identifier string for use in log messages.
func (r Resource) LogId() string {
return r.String()
}
// Equal checks if the type matches.
func (r Resource) Equal(s string) bool {
return strings.EqualFold(s, r.String())
}
// NotEqual checks if the type is different.
func (r Resource) NotEqual(s string) bool {
return !r.Equal(s)
}