lmsaml reference
Complete command-line flags, SAML 2.0 and REST HTTP endpoints, Saml and Batch host methods, standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmsaml v0.1.0.
Host and server CLI flags
| Flag | Arguments | Description |
|---|---|---|
| --version | -v | none | Print lmsaml 0.1.0 and exit 0. |
| --help | -h | none | Print command-line usage summary and exit 0. |
| --lmcode-schema | [--json] | Write the embedded lmsaml schema JSON to stdout and exit 0. |
| --lmcode-signatures | none | Print all canonical host and standard library (lmcode_std_v3) signatures. |
| --host-signatures | none | Print only the lmsaml host-specific signatures (excluding lmcode_std_v3). |
| --lmcode | [--dry-run] <file.dslb>... | Execute (or dry-validate) compiled LMScript bytecode files against the embedded lmsaml schema. |
| --port | -p | <port> | Primary HTTP port for SAML 2.0 IdP, SP, and REST endpoints (default 8080). |
| --rest-port | <port> | Optional dedicated HTTP port for the JSON REST API. |
| --host | <address> | Listen IP address or hostname (default 127.0.0.1). |
| --entity-id | <url> | Override the base EntityID URL for the SAML 2.0 IdP and SP. |
| --admin-user | <username> | Initial administrator username seeded at startup (default admin). |
| --admin-password | <password> | Initial administrator password seeded at startup (default admin). |
| --require-auth | none | Require HTTP Basic or Bearer authentication on administrative REST endpoints (/users, /services, /assertion). |
SAML 2.0 protocol and REST HTTP endpoints
| Method and path | Content type | Description |
|---|---|---|
| GET / | GET /ping | application/json | Health check returning {"ok":true,"result":"PONG","service":"lmsaml","version":"0.1.0"}. |
| GET /idp/metadata | GET /metadata | application/samlmetadata+xml | Return the SAML 2.0 IdP EntityDescriptor XML with IDPSSODescriptor and X.509 signing certificate. |
| GET|POST /idp/sso | /sso | text/html / SAML binding | SAML 2.0 Single Sign-On endpoint supporting HTTP-Redirect and HTTP-POST bindings. |
| GET|POST /idp/slo | /slo | text/html / SAML binding | SAML 2.0 Single Logout endpoint. |
| GET|POST /idp/login | /login | text/html | Interactive IdP HTML login form handler. |
| GET|POST /idp/logout | /logout | text/html | Interactive IdP logout handler. |
| GET /sp/metadata | application/samlmetadata+xml | Return the built-in SAML 2.0 Service Provider EntityDescriptor XML. |
| POST /sp/acs | application/x-www-form-urlencoded | Built-in Service Provider Assertion Consumer Service (ACS) endpoint. |
| GET /sp/hello | application/json / 302 redirect | Protected SP endpoint that initiates an AuthnRequest redirect to /idp/sso when unauthenticated. |
| GET /users | application/json | List all user IDs in the directory as {"ok":true,"users":[...]}. |
| GET /users/{id} | application/json | Fetch user profile attributes (name, email, common_name, surname, given_name, scoped_affiliation, groups). |
| PUT|POST /users/{id} | application/json | Create or update a user from JSON attributes and bcrypt-hash any supplied password. |
| DELETE /users/{id} | application/json | Delete a user by ID and return {"ok":true,"result":"DELETED"}. |
| GET|PUT|POST|DELETE /services[/id] | application/json / application/xml | List, fetch, register, or remove SAML Service Provider EntityDescriptor metadata documents. |
| POST /authn | POST /bind | application/json | Verify username and password against bcrypt store and return {"ok":true,"authenticated":true,"result":"BOUND"}. |
| POST /assertion | application/json | Issue a signed SAML 2.0 Response + Assertion for {"user":...,"audience":...,"acs_url":...,"request_id":...}. |
| POST /verify | application/json / application/xml | Cryptographically verify a SAML 2.0 Response (saml_response_b64 or raw XML) and return extracted subject and attributes. |
Host context saml: Saml and Batch methods
| Type / context | Method or function signature | Description |
|---|---|---|
| context saml: Saml | saml.ping() -> string | Check health of the target REST server or in-process engine and return "PONG". |
| Saml | saml.metadata() -> string | saml.sp_metadata() -> string | Return the IdP EntityDescriptor XML string or built-in SP EntityDescriptor XML string. |
| Saml | saml.add_user(string, string) -> bool | Create or update user (name, user_json) and return true on success. |
| Saml | saml.get_user(string) -> string | saml.list_users() -> string | Return user profile JSON ("null" if not found) or a JSON array of username strings. |
| Saml | saml.del_user(string) -> int | Delete a user by username and return 1 if deleted or 0 if not found. |
| Saml | saml.authenticate(string, string) -> bool | Verify (username, password) against the bcrypt store and return true if valid. |
| Saml | saml.issue_assertion(string, string) -> string | Issue an RSA-SHA256 signed SAML 2.0 Response for (user, audience) and return the IssuedAssertion JSON string. |
| Saml | saml.verify_assertion(string) -> string | Cryptographically verify a base64 or raw XML SAML 2.0 Response and return VerifiedAssertion JSON ({ok,valid,subject,attributes,...}). |
| Saml / function | saml.batch() -> Batch | print(string) -> void | Create a fluent Batch operation queue or print a line to stdout. |
| Batch | b.ping() | b.list_users() -> Batch | Append a ping or list_users operation to the batch queue. |
| Batch | b.add_user(string, string) | b.get_user(string) | b.del_user(string) -> Batch | Append a user upsert, lookup, or deletion operation to the batch queue. |
| Batch | b.issue_assertion(string, string) -> Batch | Append a signed assertion issuance operation for (user, audience) to the batch queue. |
| Batch | b.len() -> int | b.clear() -> void | b.exec() -> string | Return queued operation count, clear the queue, or execute all queued operations and return a JSON array string. |
Standard lmcode_std_v3 REST and CLI interfaces
| Interface or function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config | rest_config(key: string, value: string) -> void | Configure server or CLI settings such as host, port, and session (ephemeral or global). |
| rest_route | rest_route(method: string, path: string, handler: string) -> void | Dynamically register an HTTP method and route pattern to a handler function name. |
| rest_serve / rest_stop | rest_serve() -> void | rest_stop() -> void | Start or stop the embedded standard HTTP server loop. |
| rest_cli | rest_cli(args: StrList) -> string | Dispatch CLI options, commands, or path requests in-process without opening a socket. |
| RestExchange | x.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> string | Read request method, path, body, :param segment, query parameter, or header. |
| RestExchange | x.has_query(string) | x.has_header(string) -> bool | Check whether a query parameter or request header is present. |
| RestExchange | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> void | Set response status code and headers, and emit plain text or application/json bodies. |
| RestExchange | x.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> int | Read, write, or atomically increment session state keys across global or ephemeral exchanges. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | Server exited cleanly on SIGINT/SIGTERM, or _lmcode_ program succeeded and all assertions passed. |
| 1 | Server / bind error | SamlEngine initialization failed or TCP listener failed to bind --port or --rest-port. |
| 2 | Usage error | Missing bytecode file after --lmcode, invalid CLI flag, or retired --dsl* option. |
| 3 | Host / load error | Bytecode read/load error, schema mismatch, or unhandled host runtime error. |
| 4 | Contract failure | An assertion (assert, assert_eq) or result schema contract failed during script execution. |