百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

Mujina

> 前端框架
开源

使用 OpenSAML 库的模拟 IDP 和 SP

384 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

使用 OpenSAML 库的模拟 IDP 和 SP


| / | ()() | . . | _ _ _ _ _ __ __ _ | |/| || | | || || || '_ \ / ` | | | | || || || || || | | || (| | _| |/ _,|| ||||| || _,_| _/ | |__/

Configurable Identity and Service Provider built with OpenSAML & Java Spring Boot

Mujina

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:

  • We no longer use Tomcat, but standalone Spring boot applications
  • The API has changed for all end-points requiring a single value (e.g. String or boolean) and only that value is required in the request body. See the API documentation below.

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.

Security

Mujina is a test tool, not a production identity provider, and its defaults reflect that:

  • The /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.
  • The shipped private key, certificate, and keystore passphrase (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.
  • Verbose 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.

Features

  • 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:

    • user credentials (either a specific username & password or allow any username and password)
    • user role
    • any user attributes
    • signing certificate
    • entityID
    • ACS endpoint
    • signature Algorithm
  • 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:

    • entityID
    • signing certificate
    • SSO Service URL
    • signature Algorithm

Defaults

The default Identity Provider configuration is as follows:

  • The Entity ID is "http://mock-idp"
  • The signatureAlgorithm is "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
  • It has a user with login "admin" and password "secret" with roles ROLE_USER and ROLE_ADMIN
  • It has a user with login "user" and password "secret" with role ROLE_USER
  • It has the following attributes. Attributes are always stored as lists. Even when they contain a single value.
    • "urn:mace:dir:attribute-def:uid" is "john.doe"
    • "urn:mace:dir:attribute-def:cn" is "John Doe"
    • "urn:mace:dir:attribute-def:givenName" is "John"
    • "urn:mace:dir:attribute-def:sn" is "Doe"
    • "urn:mace:dir:attribute-def:displayName" is "John Doe"
    • "urn:mace:dir:attribute-def:mail" is "[email protected]"
    • "urn:mace:terena.org:attribute-def:schacHomeOrganization" is "example.com"
    • "urn:mace:dir:attribute-def:eduPersonPrincipalName" is "[email protected]"
    • "urn:oasis:names:tc:SAML:attribute:subject-id" is "[email protected]"
  • There is a default certificate and private key available
  • By default the ACS endpoint should be provided by the SP as an attribute in the AuthnRequest. If the ACS endpoint is set using the IdP api this is not necessary. Use of the api overrides values set in AuthnRequests

The default Service Provider configuration is as follows:

  • The Entity ID is "http://mock-sp"
  • The signatureAlgorithm is "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
  • There is a default certificate and private key available

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.

Build Mujina

Maven 3 in combination with Java 21 is needed to build and run Mujina.

bash
git clone [email protected]:OpenConext/Mujina.git
cd Mujina
mvn clean install

The 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).

Run the IDP

bash
cd mujina-idp
mvn spring-boot:run

Then, go to http://localhost:8080/. If you want the application to run over https, please refer to the spring boots docs.

Run the SP (in a new terminal session)

bash
cd mujina-sp
mvn spring-boot:run

Then, 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.

Run the E2E tests

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).

bash
mvn clean install -DskipTests
cd e2e
npm ci
npx playwright install --with-deps chromium
npx playwright test

Playwright 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:

bash
npx playwright test --headed   # watch the tests run in a real browser window
npx playwright test --ui       # interactive UI mode

Private signing key and public certificate

The 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.

bash
openssl req -subj '/O=Organization, CN=Mujina/' -newkey rsa:2048 -new -x509 -days 3652 -nodes -out mujina.crt -keyout mujina.pem

The Java KeyStore expects a pkcs8 DER format for RSA private keys so we have to re-format that key:

bash
openssl pkcs8 -nocrypt  -in mujina.pem -topk8 -out mujina.der

Remove the whitespace, heading and footer from the mujina.crt and mujina.der:

bash
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'; echo

Above commands work on linux distributions. On mac you can issue the same command with ghead after you install coreutils:

bash
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'; echo

Add the mujina key pair to the application.yml file:

yaml
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}

Resetting the IDP

This API is available on both the IDP and the SP.

bash
curl -v -H "Accept: application/json" \
        -H "Content-type: application/json" \
        -X POST \
        http://localhost:8080/api/reset

Changing the entityID

This API is available on both the IDP and the SP.

bash
curl -v -H "Accept: application/json" \
        -H "Content-type: application/json" \
        -X PUT -d "myEntityId" \
        http://localhost:8080/api/entityid

Setting the Signature Algorithm

This API is available on both the IDP and the SP.

bash
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/signatureAlgorithm

Changing the signing credentials (Both IDP and SP)

This 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.

…

Setting whether the SAMLRequest / SAMLResponse needs to be signed

This API is available on both the IDP and the SP.

bash
curl -v -H "Accept: application/json" \
        -H "Content-type: application/json" \
        -X PUT -d "true" \
        http://localhost:8080/api/needs-signing

Adding a user

This API is only available on the IDP.

bash
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/users

Setting attribute foo to bar (e.g. urn:mace:dir:attribute-def:foo to bar)

This API is only available on the IDP. Note: An attribute is always a list.

bash
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

Or to test the UTF-8 encoding:

bash
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:cn

Replacing all attributes at once

This API is only available on the IDP. Note: This replaces the entire attribute map, not just one attribute.

bash
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/attributes

Setting attribute for specific user

The 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.

bash
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/user

Removing an attribute

This API is only available on the IDP.

bash
curl -v -H "Accept: application/json" \
        -H "Content-type: application/json" \
        -X DELETE \
        http://localhost:8080/api/attributes/urn:mace:dir:attribute-def:foo

Removing an attribute for a user

This API is only available on the IDP.

bash
curl -v -H "Accept: application/json" \
        -H "Content-type: application/json" \
        -X DELETE \
        http://localhost:8080/api/attributes/urn:mace:dir:attribute-def:foo/user

Setting the authentication method

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaidpjavamockopenconext

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架