示例#1
0
文件: grants.go 项目: logan/heim
func (gs *GrantManager) RevokeFromPasscode(ctx scope.Context, passcode string) error {
	cid, err := security.SharedSecretCapabilityID(
		security.KeyFromPasscode([]byte(passcode), gs.SubjectNonce, security.AES128),
		gs.SubjectNonce)
	if err != nil {
		return err
	}
	return gs.Capabilities.Remove(ctx, cid)
}
示例#2
0
文件: grants.go 项目: logan/heim
func (gs *GrantManager) PasscodeCapability(
	ctx scope.Context, passcode string) (*security.SharedSecretCapability, error) {

	cid, err := security.SharedSecretCapabilityID(
		security.KeyFromPasscode([]byte(passcode), gs.SubjectNonce, security.AES128),
		gs.SubjectNonce)
	if err != nil {
		return nil, err
	}

	c, err := gs.Capabilities.Get(ctx, cid)
	if err != nil {
		if err == ErrCapabilityNotFound {
			return nil, nil
		}
		return nil, err
	}
	return &security.SharedSecretCapability{Capability: c}, nil
}