This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a lightweight and easy-to-use SAML proxy written in Go. This is NOT a simple request/response proxy that just forwards SAML messages. Instead, it's an intelligent intermediary that enables multi-tenant SSO capabilities for applications that only support single-tenant SSO.
The proxy follows a dual-role pattern:
- To Service Providers (SPs): Acts as an Identity Provider (IdP)
- To Identity Providers (IdPs): Acts as a Service Provider (SP)
-
Zero External Infrastructure Dependencies:
- No database required
- No persistent cache or storage
- No configuration files
- Single binary deployment
- All configuration via environment variables
-
Multi-IDP Support:
- Supports multiple Identity Providers simultaneously
- Enables single-tenant SPs to work with multiple IDPs
- Provides IDP selection interface during authentication
-
Identity Federation Approach:
- Acts as an IDP to SPs but does not store user accounts or identity information
- Does not perform identity federation or user data mapping
- Simply relays authentication assertions between IDPs and SPs
- Maintains session state only during the authentication flow
This proxy is designed for organizations that need to:
- Connect applications that only support single-tenant SSO to multiple Identity Providers
- Avoid complex identity federation systems when simple authentication relay is sufficient
- Deploy quickly without database setup or complex configuration management
make run # Run the application
make run ARGS="..." # Run with argumentsmake test # Run unit tests with race detection
make cover # Generate test coverage report
go test -v -run TestName ./... # Run a specific testmake lint # Run golangci-lint
make lint-fix # Run golangci-lint with auto-fixmake tidy # Clean up go.mod dependenciesThe application is structured as a stateless HTTP server with modular SAML handling components.
-
/cmd/simple-saml-proxy/: Main application entry point- Initializes configuration from environment variables
- Creates SAML providers and starts HTTP server
-
/proxy/: Core proxy implementation- HTTP handlers and routing logic
- Error handling and response utilities
- SAML request/response processing
-
/proxy/saml/: SAML-specific implementationidp.go: Identity Provider configuration and setupstorage.go: In-memory storage for auth requests and logout contexts- Certificate and metadata management
-
/config/: Configuration management- Environment-based configuration structures
- Configuration validation and loading
- SP-Initiated Flow:
- SP sends auth request to proxy's SSO endpoint
- Proxy stores request and shows IdP selection page
- User selects IdP, proxy redirects to chosen IdP
- After IdP auth, proxy receives response at ACS endpoint
- Proxy creates new assertion and sends to original SP
Configuration is loaded from environment variables:
PROXY_*: Proxy settings (entity ID, URLs, certificates)IDP_*: Multiple IdP configurations (supports array)SERVER_*: Server settings (listen address)PROXY_ALLOWED_SP_*: Allowed service providers
PROXY_ENTITY_ID: Proxy's SAML entity IDPROXY_PRIVATE_KEY_PATH: Path to private keyPROXY_CERTIFICATE_PATH: Path to certificateIDP_0_ID,IDP_1_ID, etc.: IdP configurationsMETADATA_MAX_RETRIES: Max retry attempts for metadata fetching (default: 5)METADATA_INITIAL_DELAY: Initial retry delay (default: 1s)METADATA_MAX_DELAY: Maximum retry delay (default: 30s)PROXY_REQUIRE_SIGNED_LOGOUT_REQUESTS: Global setting for SLO signature validation (default: false)PROXY_ALLOWED_SP_X_REQUIRE_SIGNED_LOGOUT_REQUESTS: Per-SP SLO signature requirement
- Unit tests use
testingpackage with table-driven tests - E2E tests simulate full SAML flows with test certificates
- Integration tests and certificates are in
/example/directory - Use
httptestfor HTTP handler testing - Mock SAML responses for IdP testing
The project uses golangci-lint with all linters enabled except those listed in .golangci.yml. Common exclusions for test files include dupl, funlen, and paralleltest.
The codebase is maintained with no TODO, FIXME, XXX, or HACK comments. All tasks and improvements are tracked through GitHub issues rather than inline comments.