Class BSV::Auth::AuthMiddleware ¶
Inherits: Object
Rack middleware providing BRC-104 server-side authentication.
Intercepts three categories of request:
-
+POST /.well-known/auth+ — BRC-31 handshake (initialRequest, certificateRequest, etc.). Delegates to an internal {Peer} instance via {BridgeTransport}.
-
Requests carrying
x-bsv-auth-*headers — general authenticated messages. Verifies the signature, calls the downstream app, and signs the response. -
Everything else — passed through to the downstream app unchanged.
@example Mounting in a Rack application
Constants¶
AUTH_ENDPOINT ¶
Well-known path for BRC-31 handshake messages.
HTTP_PREFIX ¶
Rack env prefix for HTTP headers.
PATH_INFO ¶
Rack env key for the URL path.
QUERY_STRING ¶
Rack env key for the query string.
RACK_INPUT ¶
Rack env key for the request input IO.
REQUEST_METHOD ¶
Rack env key for the HTTP method.
Public Instance Methods¶
call(env) ¶
Processes a Rack request. - @param env [Hash] Rack environment - @return [Array] Rack response triplet [status, headers, body]
initialize(app, wallet:, session_manager: = nil, certificates_to_request: = nil) ¶
- @param
app[#call] downstream Rack application - @param
wallet[BSV::Wallet::Interface] server wallet for signing and verification - @param
session_manager[SessionManager, nil] optional; defaults to a new SessionManager - @param
certificates_to_request[Hash, nil] optional certificate requirements - @return [AuthMiddleware] a new instance of AuthMiddleware