Exemple #1
0
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)
}
Exemple #2
0
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
}