Add initial implementation of grants
This commit is contained in:
parent
b8f1281f78
commit
69b6579de7
15 changed files with 308 additions and 73 deletions
30
internal/dis/component/auth/policy/purge.go
Normal file
30
internal/dis/component/auth/policy/purge.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
)
|
||||
|
||||
func (*Policy) Provision(ctx context.Context, instance models.Instance, domain string) error {
|
||||
// component is purge-only
|
||||
return nil
|
||||
}
|
||||
|
||||
// Purge purges every policy for the given slug form the database
|
||||
func (pol *Policy) Purge(ctx context.Context, instance models.Instance, domain string) error {
|
||||
table, err := pol.table(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return table.Delete(&models.Grant{}, &models.Grant{Slug: instance.Slug}).Error
|
||||
}
|
||||
|
||||
// OnUserDelete is called when a user is deleted
|
||||
func (pol *Policy) OnUserDelete(ctx context.Context, user *models.User) error {
|
||||
table, err := pol.table(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return table.Delete(&models.Grant{}, &models.Grant{User: user.User}).Error
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue