lmsaml guide

Overview

lmsaml packages a complete SAML 2.0 Identity Provider (IdP), a built-in Service Provider (SP), a JSON REST management and assertion API, a hardened Go SAML 2.0 and XML-DSig/XML-Enc engine, and the lmcode-go bytecode virtual machine with the 226-signature lmcode_std_v3 standard library inside a single zero-dependency executable (CGO_ENABLED=0).

Turnkey SAML 2.0 IdP and SP architecture

Setting up a traditional SAML 2.0 test environment requires generating OpenSSL keypairs, authoring IdP and SP EntityDescriptor XML documents, exchanging metadata files, and configuring an LDAP or SQL backing store. lmsaml automates the entire federation loop at startup:

XML-DSig, XML-Enc, and SAML 2.0 security hardening

Both the lmsaml executable and its underlying Go packages implement strict cryptographic defenses against common SAML and XML vulnerabilities:

In-process and remote LMScript host execution

When executing compiled _lmcode_ bytecode via lmsaml --lmcode, the host initializes context saml: Saml and a fluent Batch builder:

Standard lmcode_std_v3 REST and CLI interfaces

lmsaml embeds the full 226-signature lmcode_std_v3 catalog from lmcode-go. Any _lmcode_ script can define custom REST routes and stateless CLI commands that orchestrate SAML user provisioning and assertion verification:

p = _lmcode_ cli="lmsaml" install="github:lmctl-ai/lmsaml@latest";
@"--audience"
fn opt_aud(x: RestExchange) -> void implements CliOption {
  x.set("aud", x.query("audience"));
}

@"mint"
fn cmd_mint(x: RestExchange) -> void implements CliCommand {
  let u = x.query("user");
  saml.add_user(u, "{\"email\":\"" + u + "@example.com\",\"password\":\"pass123\"}");
  let issued = json_parse(saml.issue_assertion(u, x.get("aud")));
  let verified = json_parse(saml.verify_assertion(issued.get("xml").as_string()));
  x.send(verified.get("subject").as_string() + ":" + str(verified.get("valid").as_bool()));
}

@"/directory/:user"
fn get_dir_user(x: RestExchange) -> void implements RestGet {
  x.json(saml.get_user(x.param("user")));
}

rest_config("session", "global");
assert_eq(rest_cli(str_split("--audience=http://127.0.0.1:8080/sp/metadata mint --user=dave", " ")), "dave@example.com:true");
end _lmcode_