Exemplo n.º 1
0
Arquivo: grants.go Projeto: 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)
}
Exemplo n.º 2
0
Arquivo: grants.go Projeto: 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
}