Tahr.RPC.Auth (tahr v0.1.0)

Copy Markdown View Source

ONC RPC authentication flavors — RFC 5531 §8.

This module implements the two flavors needed for NFSv3:

  • AUTH_NONE (flavor 0) — no credentials, no verifier.
  • AUTH_SYS (flavor 1) — Unix-style identity: stamp, hostname, uid, gid, supplementary gid list. Surfaced to handlers as the t:sys/0 struct so downstream code can apply POSIX permission checks.

RPCSEC_GSS / Kerberos is intentionally out of scope.

Each decode_*/1 consumes a <<flavor::32, body_var_opaque>> pair off the wire. encode_* flips the same shape back out. Errors bubble up as {:error, reason} tuples so the dispatcher can return AUTH_BADCRED to the client.

Summary

Types

Decoded credential, per the supported flavors.

Functions

Numeric flavor for AUTH_NONE.

Numeric flavor for AUTH_SYS.

Decode an opaque_auth (flavor + variable opaque body) into a credential struct. Used for both the call's credential and verifier slots.

Encode an opaque_auth slot. The verifier on a successful reply is almost always AUTH_NONE; only RPCSEC_GSS uses anything else.

Types

credential()

@type credential() :: Tahr.RPC.Auth.None.t() | Tahr.RPC.Auth.Sys.t()

Decoded credential, per the supported flavors.

Functions

auth_none()

@spec auth_none() :: 0

Numeric flavor for AUTH_NONE.

auth_sys()

@spec auth_sys() :: 1

Numeric flavor for AUTH_SYS.

decode_opaque_auth(binary)

@spec decode_opaque_auth(binary()) :: {:ok, credential(), binary()} | {:error, term()}

Decode an opaque_auth (flavor + variable opaque body) into a credential struct. Used for both the call's credential and verifier slots.

encode_opaque_auth(sys)

@spec encode_opaque_auth(credential()) :: binary()

Encode an opaque_auth slot. The verifier on a successful reply is almost always AUTH_NONE; only RPCSEC_GSS uses anything else.