Skip to content

[Improvement] Standardize authentication field schemas #35

Description

@MaryamZi

Problem

The AFM spec recognizes several authentication types (bearer, basic, api-key, jwt, oauth2) but does not define the required or optional fields for any of them. The spec states that "additional fields are authentication-type specific," leaving it to runtimes and users to figure out what each type needs.

Of these, only bearer, basic, and api-key are implemented in runtimes today. jwt and oauth2 are recognized by the spec but have no runtime support — their field schemas need to be defined before they can be implemented.

This creates problems:

  1. No validation: Runtimes can't validate auth configs against a schema — a missing token field on a bearer type is only caught at request time.
  2. Inconsistency across runtimes: Different implementations may expect different field names or structures for the same auth type.
  3. Poor authoring experience: Users writing .afm.md files have no spec-defined reference for what fields to provide. They rely on runtime-specific docs or trial and error.
  4. Blocked implementations: jwt and oauth2 can't be implemented without first agreeing on what fields they require.

Proposal

Define the required and optional fields for each authentication type in the spec.

Proposed field schemas

bearer

Field Required Description
token yes The bearer token value
authentication:
  type: bearer
  token: "${env:API_TOKEN}"

basic

Field Required Description
username yes The username
password yes The password
authentication:
  type: basic
  username: "${env:SERVICE_USER}"
  password: "${env:SERVICE_PASS}"

api-key

Field Required Description
api_key yes The API key value
authentication:
  type: api-key
  api_key: "${env:API_KEY}"

jwt

TBD

oauth2

TBD

Where authentication appears

Authentication is used across multiple contexts in the spec:

  • tools.mcp[].transport.authentication — MCP server connections
  • model.authentication — model/provider connections
  • interfaces[].subscription.authentication — webhook subscriptions

The field schema should apply uniformly regardless of where the authentication object appears.

Open questions

  • JWT generation: Should the spec support runtime-side JWT signing (providing a key and claims), or only accept pre-signed tokens? If generation is supported, what fields are needed (signing_key, algorithm, claims, expiry)?
  • Custom headers for API keys: Some APIs expect the key in a specific header (e.g., X-API-Key vs Authorization). Should api-key support an optional header_name field?
  • Extensibility: Should runtimes be allowed to support additional auth types beyond the spec-defined set, or should unknown types be rejected?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions