Skip to content

Conversation

@leifj
Copy link
Contributor

@leifj leifj commented Nov 25, 2025

Move SAML Service Provider implementation from internal/issuer to internal/apigw to align with architectural separation of concerns.

Why This Change

The APIGW component handles all user authentication flows (OAuth2, OIDC). SAML authentication should follow the same pattern rather than being in the issuer, which should focus solely on credential creation and signing.

Changes

APIGW (new SAML location):

  • Add SAML endpoints to internal/apigw/httpserver/endpoints_saml.go
  • Add SAML service integration and initialization
  • Update httpserver.Service to include SAMLService
  • Add SAML route registration (build tag conditional)
  • Add SAML configuration to model.APIGW struct
  • Move integration tests to internal/apigw/integration/

Issuer (SAML removed):

  • Remove SAML endpoints from internal/issuer/httpserver/
  • Remove SAMLService from issuer httpserver.Service
  • Remove SAML initialization from cmd/issuer/main.go
  • Update httpserver.New() signature (no longer takes SAMLService)

Implementation Details:

  • SAML endpoints now call issuer via gRPC (same pattern as OAuth flows)
  • Maintains build tag support (-tags=saml) for conditional compilation
  • Both enabled and disabled paths tested and working
  • All SAML integration tests passing (0.346s)

Testing

✅ go build -tags=saml ./cmd/apigw/ # SAML enabled
✅ go build -tags=saml ./cmd/issuer/ # No SAML in issuer
✅ go build ./cmd/apigw/ # SAML disabled
✅ go build ./cmd/issuer/ # No SAML references
✅ go test -tags=saml ./internal/apigw/integration/ # All tests pass

Benefits

  1. Architectural Consistency: APIGW now handles all authentication (OAuth, OIDC, SAML)
  2. Service Independence: Issuer is pure credential creation service
  3. Future-Proofing: Sets pattern for additional auth methods (e.g., OpenID Connect - Priority 11)
  4. Code Reuse: SAML uses same issuer client interface as OAuth

Related to upstream maintainer feedback and ROADMAP.md Priority 11.

Move SAML Service Provider implementation from internal/issuer to internal/apigw
to align with architectural separation of concerns.

## Why This Change

The APIGW component handles all user authentication flows (OAuth2, OIDC).
SAML authentication should follow the same pattern rather than being in the
issuer, which should focus solely on credential creation and signing.

## Changes

**APIGW (new SAML location):**
- Add SAML endpoints to internal/apigw/httpserver/endpoints_saml.go
- Add SAML service integration and initialization
- Update httpserver.Service to include SAMLService
- Add SAML route registration (build tag conditional)
- Add SAML configuration to model.APIGW struct
- Move integration tests to internal/apigw/integration/

**Issuer (SAML removed):**
- Remove SAML endpoints from internal/issuer/httpserver/
- Remove SAMLService from issuer httpserver.Service
- Remove SAML initialization from cmd/issuer/main.go
- Update httpserver.New() signature (no longer takes SAMLService)

**Implementation Details:**
- SAML endpoints now call issuer via gRPC (same pattern as OAuth flows)
- Maintains build tag support (-tags=saml) for conditional compilation
- Both enabled and disabled paths tested and working
- All SAML integration tests passing (0.346s)

## Testing

✅ go build -tags=saml ./cmd/apigw/     # SAML enabled
✅ go build -tags=saml ./cmd/issuer/    # No SAML in issuer
✅ go build ./cmd/apigw/                # SAML disabled
✅ go build ./cmd/issuer/               # No SAML references
✅ go test -tags=saml ./internal/apigw/integration/  # All tests pass

## Benefits

1. **Architectural Consistency**: APIGW now handles all authentication
   (OAuth, OIDC, SAML)
2. **Service Independence**: Issuer is pure credential creation service
3. **Future-Proofing**: Sets pattern for additional auth methods
   (e.g., OpenID Connect - Priority 11)
4. **Code Reuse**: SAML uses same issuer client interface as OAuth

Related to upstream maintainer feedback and ROADMAP.md Priority 11.
Add support for configuring a single static Identity Provider (IdP)
instead of using an MDQ (Metadata Query Protocol) service. This is
useful for simple deployments with a single IdP, testing environments,
or scenarios where IdP metadata rarely changes.

Changes:
- Add StaticIDPConfig to SAMLConfig with entity_id, metadata_path, and metadata_url
- Add SAMLConfig.Validate() to ensure MDQ and static IdP are mutually exclusive
- Extend MDQClient to support static metadata loading from file or URL
- Update SAML service initialization to support both MDQ and static modes
- Add comprehensive tests for static IdP functionality
- Add configuration validation tests
- Update route registration to use proper gin.RouterGroup types
- Add SAML_STATIC_IDP.md documentation

Configuration example:
  saml:
    enabled: true
    static_idp_metadata:
      entity_id: "https://idp.example.com"
      metadata_path: "/path/to/idp-metadata.xml"

Tests:
- Static metadata loading from file and URL
- Configuration validation (mutual exclusivity, required fields)
- MDQ client behavior in static mode
- Service initialization with static IdP

All tests passing:
- go test -tags=saml ./pkg/saml/... (35/35 passed)
- go test ./pkg/model/... (9/9 passed)
- go build -tags=saml ./cmd/apigw/ (success)
- go build ./cmd/apigw/ (success, without tags)
@leifj
Copy link
Contributor Author

leifj commented Nov 25, 2025

I will add one more fix: we need a simple way to register a single IdP (SAML metadata file or URL) to make it easier to deploy in common cases

SAML has been moved to APIGW, so the SAML configuration should only
exist in the APIGW struct, not in Issuer.

Addresses PR review comment from @masv3971
@masv3971 masv3971 merged commit 3e20997 into dc4eu:main Nov 25, 2025
1 check passed
@leifj leifj deleted the refactor/move-saml-to-apigw branch November 25, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants