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

FlagArgumentsDescription
--version | -vnonePrint lmsaml 0.1.0 and exit 0.
--help | -hnonePrint command-line usage summary and exit 0.
--lmcode-schema[--json]Write the embedded lmsaml schema JSON to stdout and exit 0.
--lmcode-signaturesnonePrint all canonical host and standard library (lmcode_std_v3) signatures.
--host-signaturesnonePrint 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-authnoneRequire HTTP Basic or Bearer authentication on administrative REST endpoints (/users, /services, /assertion).

SAML 2.0 protocol and REST HTTP endpoints

Method and pathContent typeDescription
GET / | GET /pingapplication/jsonHealth check returning {"ok":true,"result":"PONG","service":"lmsaml","version":"0.1.0"}.
GET /idp/metadata | GET /metadataapplication/samlmetadata+xmlReturn the SAML 2.0 IdP EntityDescriptor XML with IDPSSODescriptor and X.509 signing certificate.
GET|POST /idp/sso | /ssotext/html / SAML bindingSAML 2.0 Single Sign-On endpoint supporting HTTP-Redirect and HTTP-POST bindings.
GET|POST /idp/slo | /slotext/html / SAML bindingSAML 2.0 Single Logout endpoint.
GET|POST /idp/login | /logintext/htmlInteractive IdP HTML login form handler.
GET|POST /idp/logout | /logouttext/htmlInteractive IdP logout handler.
GET /sp/metadataapplication/samlmetadata+xmlReturn the built-in SAML 2.0 Service Provider EntityDescriptor XML.
POST /sp/acsapplication/x-www-form-urlencodedBuilt-in Service Provider Assertion Consumer Service (ACS) endpoint.
GET /sp/helloapplication/json / 302 redirectProtected SP endpoint that initiates an AuthnRequest redirect to /idp/sso when unauthenticated.
GET /usersapplication/jsonList all user IDs in the directory as {"ok":true,"users":[...]}.
GET /users/{id}application/jsonFetch user profile attributes (name, email, common_name, surname, given_name, scoped_affiliation, groups).
PUT|POST /users/{id}application/jsonCreate or update a user from JSON attributes and bcrypt-hash any supplied password.
DELETE /users/{id}application/jsonDelete a user by ID and return {"ok":true,"result":"DELETED"}.
GET|PUT|POST|DELETE /services[/id]application/json / application/xmlList, fetch, register, or remove SAML Service Provider EntityDescriptor metadata documents.
POST /authn | POST /bindapplication/jsonVerify username and password against bcrypt store and return {"ok":true,"authenticated":true,"result":"BOUND"}.
POST /assertionapplication/jsonIssue a signed SAML 2.0 Response + Assertion for {"user":...,"audience":...,"acs_url":...,"request_id":...}.
POST /verifyapplication/json / application/xmlCryptographically 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 / contextMethod or function signatureDescription
context saml: Samlsaml.ping() -> stringCheck health of the target REST server or in-process engine and return "PONG".
Samlsaml.metadata() -> string | saml.sp_metadata() -> stringReturn the IdP EntityDescriptor XML string or built-in SP EntityDescriptor XML string.
Samlsaml.add_user(string, string) -> boolCreate or update user (name, user_json) and return true on success.
Samlsaml.get_user(string) -> string | saml.list_users() -> stringReturn user profile JSON ("null" if not found) or a JSON array of username strings.
Samlsaml.del_user(string) -> intDelete a user by username and return 1 if deleted or 0 if not found.
Samlsaml.authenticate(string, string) -> boolVerify (username, password) against the bcrypt store and return true if valid.
Samlsaml.issue_assertion(string, string) -> stringIssue an RSA-SHA256 signed SAML 2.0 Response for (user, audience) and return the IssuedAssertion JSON string.
Samlsaml.verify_assertion(string) -> stringCryptographically verify a base64 or raw XML SAML 2.0 Response and return VerifiedAssertion JSON ({ok,valid,subject,attributes,...}).
Saml / functionsaml.batch() -> Batch | print(string) -> voidCreate a fluent Batch operation queue or print a line to stdout.
Batchb.ping() | b.list_users() -> BatchAppend a ping or list_users operation to the batch queue.
Batchb.add_user(string, string) | b.get_user(string) | b.del_user(string) -> BatchAppend a user upsert, lookup, or deletion operation to the batch queue.
Batchb.issue_assertion(string, string) -> BatchAppend a signed assertion issuance operation for (user, audience) to the batch queue.
Batchb.len() -> int | b.clear() -> void | b.exec() -> stringReturn 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 functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_configrest_config(key: string, value: string) -> voidConfigure server or CLI settings such as host, port, and session (ephemeral or global).
rest_routerest_route(method: string, path: string, handler: string) -> voidDynamically register an HTTP method and route pattern to a handler function name.
rest_serve / rest_stoprest_serve() -> void | rest_stop() -> voidStart or stop the embedded standard HTTP server loop.
rest_clirest_cli(args: StrList) -> stringDispatch CLI options, commands, or path requests in-process without opening a socket.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> stringRead request method, path, body, :param segment, query parameter, or header.
RestExchangex.has_query(string) | x.has_header(string) -> boolCheck whether a query parameter or request header is present.
RestExchangex.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> voidSet response status code and headers, and emit plain text or application/json bodies.
RestExchangex.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> intRead, write, or atomically increment session state keys across global or ephemeral exchanges.

Exit codes

Exit codeCategoryMeaning
0SuccessServer exited cleanly on SIGINT/SIGTERM, or _lmcode_ program succeeded and all assertions passed.
1Server / bind errorSamlEngine initialization failed or TCP listener failed to bind --port or --rest-port.
2Usage errorMissing bytecode file after --lmcode, invalid CLI flag, or retired --dsl* option.
3Host / load errorBytecode read/load error, schema mismatch, or unhandled host runtime error.
4Contract failureAn assertion (assert, assert_eq) or result schema contract failed during script execution.