forked from mirrors/homebox
feat: auth-roles, image-gallery, click-to-open (#166)
* schema changes * db generate * db migration * add role based middleware * implement attachment token access * generate docs * implement role based auth * replace attachment specific tokens with gen token * run linter * cleanup temporary token implementation
This commit is contained in:
parent
974d6914a2
commit
de419dc37d
48 changed files with 3127 additions and 244 deletions
34
backend/internal/data/ent/schema/auth_roles.go
Normal file
34
backend/internal/data/ent/schema/auth_roles.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// AuthRoles holds the schema definition for the AuthRoles entity.
|
||||
type AuthRoles struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the AuthRoles.
|
||||
func (AuthRoles) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Enum("role").
|
||||
Default("user").
|
||||
Values(
|
||||
"admin", // can do everything - currently unused
|
||||
"user", // default login role
|
||||
"attachments", // Read Attachments
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the AuthRoles.
|
||||
func (AuthRoles) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("token", AuthTokens.Type).
|
||||
Ref("roles").
|
||||
Unique(),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue