adminclient

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package adminclient is the client of the admin API: it builds the signed envelope of each mutating call and asks a Signer (a FIDO2 key) to sign it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(target string, cfg *tls.Config) (*grpc.ClientConn, error)

Dial connects over TLS 1.3 only. cfg is cloned; its MinVersion is forced.

func DialUnix

func DialUnix(path string) (*grpc.ClientConn, error)

DialUnix connects to the local enrolment socket. The transport is a Unix socket protected by file permissions, so there is no TLS.

func Enrol

Enrol registers a new credential on the key with the forge behind conn and returns what the server stored.

Types

type Client

type Client struct {
	Conn         *grpc.ClientConn
	Admin        adminv1.AdminServiceClient
	Signer       Signer
	RPID         string
	CredentialID []byte
}

Client talks to the admin API.

func New

func New(conn *grpc.ClientConn, s Signer, rpID string, credentialID []byte) *Client

New returns a client.

func (*Client) AddSSHKey

func (c *Client) AddSSHKey(ctx context.Context, login, publicKey string) (*adminv1.SSHKey, error)

AddSSHKey registers an authorized_keys line for a user.

func (*Client) BindIdentity

func (c *Client) BindIdentity(ctx context.Context, issuer, subject, login string) (*adminv1.Identity, error)

BindIdentity binds (issuer, subject) to a user.

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, login, display string) (*adminv1.User, error)

CreateUser creates a user.

func (*Client) DisableUser

func (c *Client) DisableUser(ctx context.Context, login string) error

DisableUser disables a user.

func (*Client) Nonce

func (c *Client) Nonce(ctx context.Context) (nonce, exporter []byte, err error)

Nonce asks for a nonce and returns it with the connection's exporter value.

func (*Client) OpenSession

func (c *Client) OpenSession(ctx context.Context) ([]byte, error)

OpenSession signs one assertion and returns a read-only session token.

func (*Client) RemoveSSHKey

func (c *Client) RemoveSSHKey(ctx context.Context, fingerprint string) error

RemoveSSHKey removes the key with this fingerprint.

func (*Client) RevokeCredential

func (c *Client) RevokeCredential(ctx context.Context, id []byte) error

RevokeCredential revokes an admin credential.

func (*Client) SetCollaborator

func (c *Client) SetCollaborator(ctx context.Context, owner, repository, login string, member bool) error

SetCollaborator grants (member) or revokes push on owner/repository to login.

func (*Client) SetOIDCClient

func (c *Client) SetOIDCClient(ctx context.Context, issuer, clientID, redirectURI string, secret []byte) error

SetOIDCClient replaces the OIDC registration. The secret goes in the signed request body only.

func (*Client) SetPolicy

func (c *Client) SetPolicy(ctx context.Context, p *adminv1.Policy) error

SetPolicy replaces the forge-wide policy.

func (*Client) SetRefProtection

func (c *Client) SetRefProtection(ctx context.Context, owner, repository, pattern string, protected bool) error

SetRefProtection protects or unprotects a ref pattern of owner/repository.

func (*Client) Sign

func (c *Client) Sign(ctx context.Context, method string, params proto.Message) (*adminv1.Envelope, error)

Sign builds the envelope for method (the full gRPC method name) carrying params. The key is asked for a touch and a verification.

func (*Client) UnbindIdentity

func (c *Client) UnbindIdentity(ctx context.Context, issuer, subject string) error

UnbindIdentity removes a binding.

type FIDOSigner

type FIDOSigner struct{ Key *fido.Key }

FIDOSigner signs with a hardware key through go-authn/fido. It asks for user verification ("uv": true), which on a key with built-in verification (a YubiKey Bio's fingerprint) needs no PIN token. A key that can only verify by PIN is refused by the key itself and the error says so.

func (FIDOSigner) Assert

func (s FIDOSigner) Assert(ctx context.Context, rpID string, credentialID []byte, cdh [32]byte) ([]byte, []byte, error)

Assert implements Signer.

func (FIDOSigner) Make

func (s FIDOSigner) Make(ctx context.Context, rpID string, userHandle []byte, name string, cdh [32]byte) (string, []byte, []byte, error)

Make implements Signer.

type Signer

type Signer interface {
	// Assert returns authenticator data and an ES256 signature, with user
	// verification, over authenticatorData || cdh.
	Assert(ctx context.Context, rpID string, credentialID []byte, cdh [32]byte) (authData, signature []byte, err error)
	// Make creates a credential and returns the attestation object's parts.
	Make(ctx context.Context, rpID string, userHandle []byte, name string, cdh [32]byte) (format string, authData, attStmt []byte, err error)
}

Signer produces FIDO2 assertions and attestations. The hardware implementation is FIDOSigner; tests use a software authenticator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL