28 lines
1.1 KiB
Go
28 lines
1.1 KiB
Go
package native
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/tech/sendico/pkg/auth/internal/native/db"
|
|
"github.com/tech/sendico/pkg/auth/internal/native/nstructures"
|
|
"github.com/tech/sendico/pkg/db/template"
|
|
"github.com/tech/sendico/pkg/mlogger"
|
|
"github.com/tech/sendico/pkg/model"
|
|
"go.mongodb.org/mongo-driver/v2/bson"
|
|
"go.mongodb.org/mongo-driver/v2/mongo"
|
|
)
|
|
|
|
type PoliciesDB interface {
|
|
template.DB[*nstructures.PolicyAssignment]
|
|
// plenty of interfaces for performance reasons
|
|
Policies(ctx context.Context, object model.PermissionBoundStorable, action model.Action) ([]nstructures.PolicyAssignment, error)
|
|
PoliciesForPermissionAction(ctx context.Context, roleRef, permissionRef bson.ObjectID, action model.Action) ([]nstructures.PolicyAssignment, error)
|
|
PoliciesForRole(ctx context.Context, roleRef bson.ObjectID) ([]nstructures.PolicyAssignment, error)
|
|
PoliciesForRoles(ctx context.Context, roleRefs []bson.ObjectID, action model.Action) ([]nstructures.PolicyAssignment, error)
|
|
Remove(ctx context.Context, policy *model.RolePolicy) error
|
|
}
|
|
|
|
func NewPoliciesDBDB(logger mlogger.Logger, conn *mongo.Database) (PoliciesDB, error) {
|
|
return db.NewPoliciesDB(logger, conn)
|
|
}
|