Skip to content

Exempt /zosmf/services/authenticate from the auth gate (AUTH=NONE) so mvsMF owns the login/logout response #114

Description

@mgrossmann

Summary

The deployed httpd gates /zosmf/services/authenticate under the /zosmf/*
AUTH=BASIC route policy, so auth_gate() rejects an unauthenticated
request to the authenticate endpoint with httpd's own 401 before dispatching
to the mvsMF CGI. Per the Auth redesign (docs/auth-redesign.md §2.5, #98) the
authenticate route was meant to "resolve but not reject" — i.e. resolve any
credential but always pass through, so mvsMF owns the login/logout response.

This is a design/config gap, not a functional blocker (see Impact) — filing
it so the httpd team can decide whether to close the gap or accept the current
behavior.

Behavior today (live, mvsdev.lan:1081)

A bad-credential POST /zosmf/services/authenticate gets httpd's generic 401,
never reaching mvsMF:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="MVS"
Server: HTTPD Server            <- httpd's auth_gate, not the CGI
Content-Type: text/plain
401 Unauthorized

mvsMF's handler would instead return the z/OSMF-shaped body:

HTTP/1.1 401 Unauthorized
Content-Type: application/json
{"returnCode":8,"reasonCode":1,"message":"Login failed. ..."}

Same for DELETE without a token (httpd 401 before the CGI).

Impact — mostly cosmetic

  • Valid login is unaffected: the resolver sets httpc->cred from valid
    Basic, the gate passes, mvsMF returns 200 + LtpaToken2. ✔
  • Bad login still returns 401 (correct status); only the body differs
    (httpd text/plain vs. mvsMF's z/OSMF JSON). Zowe/z/OSMF clients act on the
    status code, not the body — so no functional breakage.
  • Logout without a valid token → 401 is actually correct per the z/OSMF
    spec ("request cookie must include a valid token").

What is lost by gating the route:

  1. mvsMF cannot emit the exact z/OSMF wire format (returnCode/reasonCode/
    message) on the login-failure path.
  2. The login endpoint answers with WWW-Authenticate: Basic realm="MVS"
    real z/OSMF's /zosmf/services/authenticate does not send a challenge on
    this endpoint (it hands back a JSON result), and a Basic challenge can trigger
    a browser-native credential dialog for some client types.

Suggested fix

Give /zosmf/services/authenticate a more-specific route with AUTH=NONE
(overriding the broader /zosmf/* AUTH=BASIC). resolve_credential() runs for
every request before auth_gate(), so a valid Basic/token still populates
httpc->cred; AUTH=NONE just stops the gate from rejecting, letting every
request reach mvsMF, which then owns the response (200 + token on success, the
z/OSMF 401 on failure, 204/handled logout). This mirrors how httpd's own
/login and /logout are dispatched before the gate (see the
is_asset_exempt() note in src/httppc.c).

Decision for the team

Is exact z/OSMF wire fidelity (and no Basic challenge) on the authenticate
endpoint worth the extra route, or is httpd's front-gate 401 acceptable? If the
latter, this is wontfix and mvsMF's failure-path handler is effectively dead
code (harmless) — we'd relax the mvsMF tests accordingly.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:lowNice to havequestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions