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:
Hayden 2022-12-03 10:55:00 -09:00 committed by GitHub
parent 974d6914a2
commit de419dc37d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 3127 additions and 244 deletions

View file

@ -37,6 +37,26 @@ var (
},
},
}
// AuthRolesColumns holds the columns for the "auth_roles" table.
AuthRolesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "role", Type: field.TypeEnum, Enums: []string{"admin", "user", "attachments"}, Default: "user"},
{Name: "auth_tokens_roles", Type: field.TypeUUID, Unique: true, Nullable: true},
}
// AuthRolesTable holds the schema information for the "auth_roles" table.
AuthRolesTable = &schema.Table{
Name: "auth_roles",
Columns: AuthRolesColumns,
PrimaryKey: []*schema.Column{AuthRolesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "auth_roles_auth_tokens_roles",
Columns: []*schema.Column{AuthRolesColumns[2]},
RefColumns: []*schema.Column{AuthTokensColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// AuthTokensColumns holds the columns for the "auth_tokens" table.
AuthTokensColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@ -385,6 +405,7 @@ var (
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
AttachmentsTable,
AuthRolesTable,
AuthTokensTable,
DocumentsTable,
DocumentTokensTable,
@ -402,6 +423,7 @@ var (
func init() {
AttachmentsTable.ForeignKeys[0].RefTable = DocumentsTable
AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable
AuthRolesTable.ForeignKeys[0].RefTable = AuthTokensTable
AuthTokensTable.ForeignKeys[0].RefTable = UsersTable
DocumentsTable.ForeignKeys[0].RefTable = GroupsTable
DocumentTokensTable.ForeignKeys[0].RefTable = DocumentsTable