20 lines
662 B
Go
20 lines
662 B
Go
package domain
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.cin.su/m/Assistant/contracts/authority"
|
|
"git.cin.su/m/Assistant/contracts/identity"
|
|
)
|
|
|
|
var ErrInvalidGrant = errors.New("authority grant is not currently valid for actor, principal, and scope")
|
|
|
|
func ValidateGrant(binding identity.PrincipalBinding, scope authority.Scope, grant authority.AuthorityGrant) error {
|
|
if binding.ActorID == "" || binding.PrincipalID == "" || !binding.Active ||
|
|
scope.ID == "" || grant.ID == "" || grant.Revision == 0 || !grant.Active ||
|
|
grant.ActorID != binding.ActorID || grant.PrincipalID != binding.PrincipalID || grant.ScopeID != scope.ID {
|
|
return ErrInvalidGrant
|
|
}
|
|
return nil
|
|
}
|