MaxKey: Open-Source SSO with Multi-Protocol Support & Bcrypt Password Security
MaxKey is an open-source single sign-on system supporting OAuth 2.x, OpenID Connect, SAML 2.0, JWT, CAS, and SCIM, featuring multi-tenancy, user lifecycle management, MFA, session timeout design, brute-force protection, and bcrypt password storage, built on Java EE with Spring, MySQL, Redis, and MQ.
Reading font

Project Overview
MaxKey (a pun on "Marx's Key" meaning "Maximum Key") is an enterprise-grade single sign-on (SSO) authentication system. It supports standard protocols including OAuth 2.x/OpenID Connect, SAML 2.0, JWT, CAS, and SCIM, providing user identity management (IDM), authentication management (AM), SSO, RBAC permission management, and resource management. The system emphasizes performance, security, and usability in enterprise scenarios across healthcare, finance, government, and manufacturing.
Core SSO Concepts
Single Sign-On (SSO) allows users to log in once at an authentication center and access all trusted applications without re-authentication. Two key requirements: all applications share one identity authentication system, and all applications can recognize and extract ticket information.
Key Features
Standard Authentication Protocols: OAuth 2.x, OpenID Connect, SAML 2.0, JWT, CAS, SCIM 2.0.
Login & Integration: Standard authentication interfaces for SSO integration, secure mobile access, API security, third-party authentication, and internet identity consolidation.
User Lifecycle Management: SCIM 2.0 support with out-of-the-box connectors for identity provisioning and synchronization.
Directory Integration: Simplifies Microsoft Active Directory and standard LDAP server organization/account management, including password self-service reset.
Multi-tenancy (IDaaS): Supports independent management for multiple enterprises under a group or data isolation for departments within an enterprise, reducing operational costs.
Cross-platform Authentication: Platform-agnostic, covering web, mobile (iOS, Android), and other devices.
Configurable Policies: Password policies, access policies; IP geolocation via Ip2region or GeoLite2; comprehensive security auditing (full lifecycle, access behavior, compliance, risk alerts).
Architecture: Java EE, microservices, Spring, MySQL, Tomcat, Redis, MQ — highly extensible.
Open Source & Self-controlled: Open-source, secure, and independently controllable.
System Security Mechanisms
Second Password Authentication
After initial SSO login, specific users or applications (e.g., financial systems, payroll) can require a second password verification. This protects sensitive applications even if the primary SSO password is compromised, which is useful in work-delegation scenarios.
Single Logout (SLO)
When a user logs out from one system, all SSO-enabled applications log out simultaneously. Implementation: first log out the SSO application, then redirect each application to MaxKey's logout page, which destroys the user's session. This prevents information leakage from forgotten logouts.
Session Timeout Design
To save server resources and enhance security, inactive sessions are terminated. MaxKey centrally controls timeouts: its session timeout is set slightly longer than integrated applications. Example: for a 30-minute inactivity timeout, set MaxKey to 30 minutes and applications to 40 minutes. If an application session expires while the user is active elsewhere, the app redirects to the login page; MaxKey performs SSO again and returns the user to the original URL.
Brute-Force Protection
Two mechanisms:
CAPTCHA: Adds a distorted character field (Completely Automated Public Turing test to tell Computers and Humans Apart) to the login form, preventing automated password guessing.
Consecutive Failure Lockout: Locks an account for a period after repeated failures (e.g., 6 failed attempts → 2-hour lockout).
Static Password Policies
Six configurable rules:
Password must meet complexity requirements
Minimum password length
Maximum password age
Minimum password age
Enforce password history (prevent reuse)
Store passwords using reversible encryption (though the system defaults to irreversible hashing)
Multi-Factor Authentication (MFA)
MFA combines "something you know" (password) with "something you have" (e.g., a hardware token or authenticator app). Time-synchronized one-time passwords (OTP) are generated using a shared secret key, current time/event, and a cryptographic algorithm. Both client and server compute the same OTP, ensuring consistency. This layered defense makes unauthorized access significantly harder.
Password Storage with Bcrypt
MaxKey uses Spring Security for password encoding. The default strategy is Bcrypt, storing passwords in the userinfo table's password field as {type}ciphertext.
Bcrypt Algorithm Details
Bcrypt is based on Bruce Schneier's 1993 Blowfish cipher. It automatically generates a random salt and embeds it in the resulting hash, eliminating separate salt storage. The hash format:
$2a$10$/bTVvqqlH9UiE0ZJZ7N2Me3RIgUCdgMheyTgV0B4cMCSokPa.6oCaBreakdown: $ – delimiter 2a – Bcrypt version identifier 10 – cost factor (work factor)
Next 22 characters – salt value
Remaining characters – password hash
Bcrypt Characteristics
Intentionally slow (thousands of times slower than MD5), making rainbow-table attacks impractical.
Each encryption produces a unique hash even for the same password, preventing cross-site credential leakage.
Developers must ensure the computational cost stays within acceptable system limits.
Why Not MD5
MD5 is a hash function, not an encryption algorithm. Rainbow tables have rendered MD5 and SHA-1 insecure for password storage. Public decryption sites (e.g., cmd5) can easily reverse common MD5/SHA-1 hashes.
Project Repository
Source code: https://gitee.com/dromara/MaxKey