Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Peios

Authentication Clients

Single-page view · as markdown

Authentication Conversations

Peios / Developing for Peios / Authentication Clients

The authentication client library, libauth.so.1, connects applications to the Peios authentication authority. It carries credential conversations, identity queries, self-account changes, and requests to end logon sessions. The authority checks the connected caller and decides what it can do.

Authentication and logon #

Both operations use the same credential conversation. Authenticate returns an established identity and the requested groups and claims. It creates no OS token, session, home directory, or user registry. Logon additionally checks local logon policy and returns a token and session for the caller to install. An Authenticate result cannot be exchanged for a token later.

Use Authenticate for a service that needs to check identity before applying its own access policy. Authd does not need to understand a Wi-Fi network or the meaning of a department claim. The service interprets the identity data.

The shared authentication request supplies the identifier, supported credential types, an optional required type and any method binding. A password-based consumer sets Password as required: advertising support alone also permits an account whose source intentionally requires no credential.

Authenticate separately requests full source group membership and selects None, Named or AllPermitted claim disclosure. AuthenticationSecurity checks group and named-claim permissions before credential collection. Forbidden named disclosure fails the request. An authorized named claim absent from the source is listed explicitly; unrequested groups differ from an empty membership set. Group results exclude locally synthesized token groups.

Claim names use KACS's per-character Unicode lowercase mapping, without normalization or full case folding. Équipe and équipe name the same claim; ß and ss do not. This applies to lookup, duplicate detection, known absence, and claim-specific permission GUIDs. Results retain the source's spelling; claim-value matching is unchanged. A Named absence can therefore supply partial KACS claim knowledge using the same name rule. Other sources must establish matching semantics before their absence assertions are adapted.

This replaces the unpublished ASCII-only development rule. Before upgrading, regenerate affected non-ASCII claim permission GUIDs using auth-policy's claim_guid helper while preserving grants and denies. ASCII identifiers stay unchanged. Resolve source records containing newly equivalent duplicate names; authd refuses their assertions rather than choosing one. Rebuild named-disclosure clients with matching auth-core and libauth revisions. An older authority's ASCII-only absence result cannot be accepted safely. Use the current framing and ABI versions described below.

AllPermitted returns readable claims and a coverage marker. Complete means the result is the whole claim set and omitted names are absent. Filtered means some names might be restricted; omitted names remain unknown. Authd determines coverage from policy rather than the presence of hidden claims, and never reports restricted names or counts. A consumer must deny a policy decision that needs unknown information. Conditions using returned values or complete group membership can still be evaluated normally.

In C, begin with peios_auth_authenticate_begin, read AuthenticationView and the existing identity getters at record index zero, and enumerate absent claims with peios_auth_authentication_absent_claim. The operation owns the result until destroyed. The Rust Client::authenticate wrapper returns an owned Authenticated result through Operation::authenticated. No token accessor succeeds for this operation. AuthenticationView.claim_coverage preserves this knowledge through the C ABI; the owned Rust result exposes ClaimCoverage. The coordinated unpublished C ABI and public PGSS framing versions are 6. Rebuild clients with the matching library; the source protocol is version 4.

An MSCHAPv2 originator advertises Capabilities::MSCHAPV2 and requires credential type 3. The source's single typed prompt supplies a 16-byte authenticator challenge in parameters. The answer contains the peer challenge (16 bytes) followed by the NT response (24 bytes). The source owns challenge freshness, account eligibility, and credential-version checks. The completed result includes a 20-byte authenticator response for this exchange, exposed as mschapv2_authenticator_response through the C view and owned Rust result. Other proof types carry no MSCHAPv2 output. This uses the existing Authenticate and disclosure grants and creates no token.

An NTLMv2 originator, such as a file server, names nobody: it sends an empty identifier, advertises only Capabilities::NTLMV2, and requires credential type 4. The authority, not a source, sends the single prompt, whose parameters are the 8-byte server challenge to put in the NTLM CHALLENGE message. Answer with three length-prefixed spans copied from the client's AUTHENTICATE message: UserName and DomainName as UTF-16LE, then NtChallengeResponse. The authority routes on the user in the answer and the owning source verifies it. A logon then returns a token with the 16-byte SessionBaseKey as ntlmv2_session_key in the grant; general authentication returns it in the authenticated result instead. The key is for NTLM key exchange and signing in this one protocol session, and cannot be used to sign in again. Key exchange, the message integrity code and the client's AvPairs remain the originator's to process.

Credential collection #

A logon begins with a proposed identity, logon type, and the credential types the application can collect. The authority can request several rounds of answers. Each round contains messages to display and prompts to answer. The application controls its interface; the library does not read a terminal or create a window.

stateDiagram-v2
    [*] --> Waiting: Begin
    Waiting --> Prompt: Credential request
    Prompt --> Waiting: Answer round
    Waiting --> Complete: Successful reply
    Waiting --> Denied: Authority refusal
    Waiting --> Failed: Transport or protocol error
    Waiting --> Cancelled: Cancel
    Prompt --> Cancelled: Cancel

Prompt labels are display text. Credential types and parameters determine how to collect an answer. Applications advertise supported types and reject requests they cannot handle. Passwords must not be echoed. Secure Shell (SSH) credentials retain the binding to the authorized originator's live transport.

The supported credential list describes what the client can collect. It does not force the source to request a password. An empty list permits only a conversation that needs no collection; it does not bypass account policy.

The authority reads the connected caller's token from the kernel. A proposed logon type is checked against that caller's originator policy. Fields such as the remote host remain claims supplied by the client, not independently verified identity.

Credential verification establishes identity. Token derivation combines that identity with this machine's grants. A source does not send a finished token or choose the machine's privilege set and integrity level.

An unknown account and an incorrect credential share the authentication failure response. The local source performs a decoy password verification for unknown accounts instead of taking a cheap early-return path. This does not make account existence secret: the separate identity interface can report that a principal does not exist. For diagnosis, compare the authority and source authentication events, without recording credential values.

Tokens and sessions #

Successful logon returns a token descriptor, session ID, and profile. The profile supplies a home directory, shell, and display name; these fields are session-start preferences, not proof of identity.

The operation owns the token until the caller takes it. Taking the token transfers responsibility for closing its descriptor. Installing it and starting a process are separate, explicit actions through the Peios software development kit (SDK). Destroying an operation closes any token it still owns.

The shared protocol transport accepts at most one descriptor per message. It rejects extra descriptors and truncated ancillary data, closing received descriptors if it cannot accept the complete message.

A service manager requests a service token through a distinct attestation operation. Self-service credential changes identify the caller from the connection; they do not accept a target username.

Completion and uncertainty #

An authority refusal differs from a lost connection. If a connection fails after a change was submitted, the change could have taken effect. The error reports this as outcome_unknown. Cancellation stops communication but cannot roll back a submitted change. The library never retries a mutation on the application's behalf.

Ending a session can terminate the program requesting the action. For that case, authd replies before termination and reports prospective process counts. A permission query is advisory: the later action is checked again.

Identity results #

Identity queries retain the difference between a missing identity, an unavailable source, and a refused request. A field can have an empty value or be withheld for a stated reason. These are different results.

Enumeration returns an opaque continuation cursor and a list of sources that did not contribute. A page with no records can still have a cursor. Continue until the cursor is empty, and preserve the incomplete-source information when presenting the result.

Read Using the Authentication Client for the operation loop and resource ownership.

Self-Service Operations

Peios / Developing for Peios / Authentication Clients

The authentication client library supports operations on the caller's own account without granting local account-administration rights. The daemon identifies the caller from the connected process's token.

Account details and display names #

Use Client::own_account() or the corresponding C operation to read the caller's local account. The result includes its display name, credential policy, whether a password exists, and enrolled public-key information. It never contains a plaintext password or its verifier.

Use Client::set_display_name() to change the caller's presentation name. The request does not accept a target account name, and a display name does not change the account's security identifier (SID) or sign-in name.

These operations use lpsd's self-service socket. A caller whose account is not held by the local source cannot use that socket to administer a different source's account.

Credential changes need proof #

Password and key changes use credential conversations through authd. The local source asks the caller to prove an accepted current password. Opening the socket or possessing a session token alone is insufficient.

Follow the same prompt handling as a logon: display messages, collect only supported credential types, and answer the current round. An account without a usable password for this proof needs an administrator's help.

Self-service key removal selects a key by its SHA-256 fingerprint. The administrative lps key remove command selects by key ID instead. Use the identifier required by the interface you are calling.

Session actions are checked separately #

Client::may_end_session() queries whether the caller can request an action. Client::end_session() requests the action and checks permission again. A successful query does not guarantee a later request will succeed.

Warn the person before ending a session because running programs can lose unsaved work. The requesting program can be among the processes stopped. Read Sessions and Account Changes for the result's limitations.

Submitted changes can have uncertain outcomes #

A transport error after submission can leave a change's outcome unknown. The public error exposes outcome_unknown; preserve that distinction in the user interface and inspect state before offering a retry.

Canceling or destroying the operation releases client resources. It does not undo a request the daemon has already received. The library does not automatically retry mutations.

For full signatures and ownership rules, use <peios/auth.h>. Local administrator operations are a separate interface; they are not part of the public self-service library.

Using the Authentication Client

Peios / Developing for Peios / Authentication Clients

Use libauth to communicate with the authentication authority from your application. C callers use <peios/auth.h>; Rust callers use peios-auth, which wraps the same shared library.

Before you start #

Prepare the client dependencies:

  • Install the dev.peios.libauth runtime and the dev.peios.libauth-devel software development kit (SDK).
  • Use an account or service identity permitted to perform the operation.
  • For Rust, add the peios-auth crate from the matching authd source revision.

Link the application #

For a C application with a client.c source file:

  1. Include the public header in C:

    #include <peios/auth.h>
    
  2. Obtain compiler and linker flags through pkg-config:

    cc client.c -o client $(pkg-config --cflags --libs auth)
    

For Rust applications built with Cargo, make auth.pc discoverable through PKG_CONFIG_PATH. For an explicit development build, set PEIOS_AUTH_LIB_DIR to the directory containing libauth.so. At runtime, the loader must also find libauth.so.1. A development shell can set LD_LIBRARY_PATH to that directory.

Drive an operation #

Use this sequence for each operation:

  1. Create a client. Default options use the system sockets. Supply explicit socket paths only when selecting a trusted authority or a test server.

  2. Begin the operation. Input strings and buffers are copied before the call returns. A null C handle means the arguments were invalid. A connection failure instead produces an operation with an error result.

  3. Call peios_auth_operation_step(). When it returns PEIOS_AUTH_WAIT, obtain the descriptor, event mask, and maximum wait from peios_auth_operation_poll_info(). Wait, then call step() again, including after a timeout. Never read, write, or close that descriptor.

  4. At PEIOS_AUTH_PROMPT, display the round's messages before collecting answers. Submit answers in prompt order, with their original references and the current round ID. Answer a message-only round with an empty answer array. Clear caller-owned secret buffers after submission.

  5. At a terminal state, inspect the typed result or error. If the operation granted a token, take it only when your program is ready to own the descriptor. Check outcome_unknown before offering to repeat a change.

  6. Destroy the operation and client. Returned C views borrow the operation; copy any data needed after its next mutable call or destruction.

For blocking programs, peios_auth_operation_wait() performs the wait loop until a prompt or terminal state. The Rust wrapper provides the same choice through Operation::step() and Operation::wait(). Its result methods return owned Rust data.

Check the result #

For Authenticate and Logon, peios_auth_operation_guid() returns a borrowed authority operation identifier after a reply supplies it. The Rust accessor is Operation::operation_guid(). An empty C span or Rust None means that the identifier is unavailable. Copy the C span before mutating the operation.

The identifier links to object.authentication.operation.guid in authority events. It is not proof of identity or permission. Older authorities can omit the optional metadata. Malformed or inconsistent metadata removes the correlation link without changing the credential or token result.

The getter is an additive symbol with unchanged ABI 6 layouts. A program using it needs a libauth build exporting the symbol. Existing clients remain compatible with that library, and the public framing remains PGSS version 6.

A completed permission query means that authd permitted the proposed action at the time of the query. A completed logon provides a token and session profile. Neither result changes the calling process's identity.

Use the public header for function signatures, constants, ownership rules, and the application binary interface (ABI) contract. Keep each operation under one caller's control; different operations can run concurrently.

Reading Identities

Peios / Developing for Peios / Authentication Clients

Use the identity operations in libauth when an application needs account or group information. Native results retain details that a simple name string or libc account record cannot express.

Before you start #

Prepare the client:

  • Link the runtime and matching headers or Rust wrapper as described in Using the Authentication Client.
  • Use the system authority or an explicitly trusted endpoint.

Look up an identity #

Follow these steps:

  1. Choose a name, binary security identifier (SID), or Unix identifier as the query key. Use the SID when your application already knows the identity and needs its display name.
  2. Request the identity kind and fields the application needs. Avoid requesting every field for a name-only display.
  3. Begin the lookup and drive its operation to completion using step and polling, or the blocking wait helper.
  4. Inspect the identity outcome as well as the operation state. A completed exchange can still report no matching identity or an unavailable source.
  5. Interpret each returned field's state. An empty value, a withheld value, and an absent field are not interchangeable.

In C, the begin function is peios_auth_identity_lookup_begin(). In Rust, use Client::lookup() and read Operation::identity() after completion. The public header documents the corresponding request and result types.

Enumerate a list #

Follow these steps:

  1. Start an enumeration for principals or groups with an empty cursor. Select a group only when requesting that group's members.
  2. Present or collect the returned records while preserving their SIDs.
  3. Retain the response's incomplete-source information. A partial list must not be presented as proof that omitted identities do not exist.
  4. If the next cursor is nonempty, pass its bytes back unchanged with the same query parameters. Continue even when a page contains no records.
  5. Stop only when the next cursor is empty or an error prevents progress.

Do not parse the cursor, derive one from the last name, or assume that every source supports complete enumeration.

Check the result #

Exercise the application's handling of an unknown identity, an unavailable authority, a withheld field, and an incomplete enumeration. The interface must preserve those differences instead of collapsing them into an empty list or an anonymous account.

C result views borrow the operation. Copy data needed after its next mutable call or destruction. The Rust wrapper returns owned result data.

Detect credential replacement #

CREDENTIAL_BINDINGS requests opaque reference and revision pairs owned by the source. Disclosure requires the existing Authenticate right. A missing, restricted, or unreported field means unknown; it does not establish deletion. References are scoped to the authoritative principal SID. Neither part is a credential, token, or proof of possession.

Local queries list eligible password bindings. Disabling the password credential policy omits that binding from a present list without destroying its stored revision. An explicitly empty list is authoritative; an unreported or restricted list is unknown. NT-storage policy alone does not remove the underlying password binding.

A successful Authenticate result can disclose the binding that actually verified. Retain it with the verified SID. Later SID lookups can detect a replacement; they cannot advance the revision that a session proved. Only fresh successful authentication can do that. Password, MSCHAPv2, and NTLMv2 refer to the same local password binding. Older sources can omit it.

C uses peios_auth_record_credential_binding_count() and peios_auth_record_credential_binding() with reference or revision parts; each borrowed part is 16 bytes. Rust exposes Field::CredentialBindings. These additive exports require matching libauth headers and runtime. Existing ABI 6 layouts are unchanged.

Peios Learn — documentation for Peios software.

Built with Trail.