A mock IDP and SP using the OpenSAML library
| / | ()() | . . | _ _ _ _ _ __ __ _ | |/| || | | || || || '_ \ / ` | | | | || || || || || | | || (| | _| |/ _,|| ||||| || _,_| _/ | |__/
Configurable Identity and Service Provider built with OpenSAML & Java Spring Boot
Mujina is a SAML2 Identity and Service Provider (IdP & SP).
Note that backward incompatibilities were introduced in version 5.0.0. If you want to migrate from pre-5 versions to the post-5 versions then the following has changed:
As of version 10.0.0 we run with Spring Boot 4, spring-security-saml2-service-provider and the custom IdP library https://github.com/OpenConext/openconext-saml-java
As of version 9.0.0 we run with Java 21.
Characteristics of both the IdP or SP can be runtime changed with the REST API.
Mujina is used to test the SURFconext middleware which enables Dutch educational services to use cloud based SAAS-services.
Mujina is a test tool, not a production identity provider, and its defaults reflect that:
/api/** REST endpoints on both the IdP and SP are intentionally unauthenticated. Anyone who can reach them can replace the signing key/certificate, change the entity ID, add or modify users and attributes, and redirect the SP's SSO endpoint or the IdP's ACS endpoint. Only run Mujina on a trusted/private network — never expose it to the open internet or a shared multi-tenant host.secret) in application.yml are fixed, publicly-known test fixtures shared between the IdP and SP. Rotate them (via PUT /api/signing-credential or environment/property overrides) if an instance is ever reachable outside a throwaway test environment.secure_cookie: false is the default for local/dev convenience (so two localhost instances don't clash on cookie name). Set it to true when running behind TLS.DEBUG logging of Mujina/Spring Security internals (which can include full authentication details) is off by default. Enable it only when needed with -Dlogging.level.mujina=DEBUG -Dlogging.level.org.springframework.security=DEBUG or the equivalent LOGGING_LEVEL_* environment variables.A SAML2-compliant Identity Provider. The IdP will authenticate known users, providing known attributes to the SP. The REST api allows for the manipulation of:
A SAML2-compliant Service Provider. The SP displays the attributes as these were received from an IdP. The REST api allows for the manipulation of:
The default Identity Provider configuration is as follows:
The default Service Provider configuration is as follows:
In this document you will find some examples for overriding the default configuration. After you override configuration you can go back to the default using the reset API.
Maven 3 in combination with Java 21 is needed to build and run Mujina.
git clone [email protected]:OpenConext/Mujina.git
cd Mujina
mvn clean installThe build dependencies are hosted on https://build.openconext.org/repository/public/releases and https://build.shibboleth.net/maven/releases/ (and will be fetched automatically by Maven).
cd mujina-idp
mvn spring-boot:runThen, go to http://localhost:8080/. If you want the application to run over https, please refer to the spring boots docs.
cd mujina-sp
mvn spring-boot:runThen, go to http://localhost:9090/. You can access the secure page and will be redirected to the IdP, where you can login with username admin and password secret.
The e2e directory contains Playwright browser tests (Node/TypeScript) that drive a real SP-initiated SAML
login flow across both running applications.
Requirements: Node 22+ and a mvn install -DskipTests of the reactor (so mujina-sp/mujina-idp can resolve
mujina-common when started via spring-boot:run).
mvn clean install -DskipTests
cd e2e
npm ci
npx playwright install --with-deps chromium
npx playwright testPlaywright automatically starts both mujina-idp (:8080) and mujina-sp (:9090) before the tests run and shuts
them down afterwards, so you don't need to start them manually first. Useful variants for local debugging:
npx playwright test --headed # watch the tests run in a real browser window
npx playwright test --ui # interactive UI modeThe SAML Spring Security library needs a private DSA key / public certificate pair for the IdP / SP which can be re-generated if you want to use new key pairs.
openssl req -subj '/O=Organization, CN=Mujina/' -newkey rsa:2048 -new -x509 -days 3652 -nodes -out mujina.crt -keyout mujina.pemThe Java KeyStore expects a pkcs8 DER format for RSA private keys so we have to re-format that key:
openssl pkcs8 -nocrypt -in mujina.pem -topk8 -out mujina.derRemove the whitespace, heading and footer from the mujina.crt and mujina.der:
cat mujina.der |head -n -1 |tail -n +2 | tr -d '\n'; echo
cat mujina.crt |head -n -1 |tail -n +2 | tr -d '\n'; echoAbove commands work on linux distributions. On mac you can issue the same command with ghead after you install coreutils:
brew install coreutils
cat mujina.der |ghead -n -1 |tail -n +2 | tr -d '\n'; echo
cat mujina.crt |ghead -n -1 |tail -n +2 | tr -d '\n'; echoAdd the mujina key pair to the application.yml file:
idp:
private_key: ${output from cleaning the der file}
certificate: ${output from cleaning the crt file}
sp:
private_key: ${output from cleaning the der file}
certificate: ${output from cleaning the crt file}This API is available on both the IDP and the SP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X POST \
http://localhost:8080/api/resetThis API is available on both the IDP and the SP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d "myEntityId" \
http://localhost:8080/api/entityidThis API is available on both the IDP and the SP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d "http://www.w3.org/2000/09/xmldsig#rsa-sha1" \
http://localhost:9090/api/signatureAlgorithmThis API is available on both the IDP and the SP. The certificate should be in PEM format. The key should be in base64 encoded pkcs6 DER format.
…This API is available on both the IDP and the SP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d "true" \
http://localhost:8080/api/needs-signingThis API is only available on the IDP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d '{"name": "hacker", "password": "iamgod", "authorities": ["ROLE_USER", "ROLE_ADMIN"]}' \
http://localhost:8080/api/usersThis API is only available on the IDP. Note: An attribute is always a list.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d '["bar"]' \
http://localhost:8080/api/attributes/urn:mace:dir:attribute-def:fooOr to test the UTF-8 encoding:
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d '["髙橋 大輔"]' https://mujina-idp.test2.surfconext.nl/api/attributes/urn:mace:dir:attribute-def:cnThis API is only available on the IDP. Note: This replaces the entire attribute map, not just one attribute.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d '{"urn:mace:dir:attribute-def:cn": ["bar"]}' \
http://localhost:8080/api/attributesThe call to set an attribute is global for all users. With this call you set an attribute for a specific user. This API is only available on the IDP. Note: The user must exists and will NOT be provisioned on the fly.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X PUT -d '["bar"]' \
http://localhost:8080/api/attributes/urn:mace:dir:attribute-def:foo/userThis API is only available on the IDP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X DELETE \
http://localhost:8080/api/attributes/urn:mace:dir:attribute-def:fooThis API is only available on the IDP.
curl -v -H "Accept: application/json" \
-H "Content-type: application/json" \
-X DELETE \
http://localhost:8080/api/attributes/urn:mace:dir:attribute-def:foo/userNo open issues yet, or sync has not completed.