Add OIDC authentication to integration tests#75
Conversation
6bf45d8 to
67d961d
Compare
The CTS pod was crashing immediately at httpd startup with:
Fix: removed |
Two issues fixed and squashed into the original commit:
|
The failing tests all returned 401 — including requests from Fix: add |
c30ffd2 to
6c6933a
Compare
The crash was caused by |
All POST requests (including those carrying a valid Bearer token) returned 401 because |
🔴 Critical —
|
Replaced
|
Root cause of the latest CTS startup failure: Fix: switch the The |
The crash ( Fix:
|
1. Replace GLAuth with OpenLDAPGLAuth hardcodes a denial of anonymous binds; CTS does anonymous LDAP searches so it always gets
2.
|
All issues from the latest review have been addressed and squashed into the original commit. 1. GLAuth → OpenLDAP: Replaced 2. Dex TLS: The 3. Bearer token validation: Replaced 4. AuthType: The 5. 6. AUTH_BACKEND: Changed from 7. Nits: |
Fixed the
|
Fixed the stale skip messages: all four |
Code Review: Add OIDC authentication to integration testsThe PR deploys Dex (OIDC) and a Python/ldaptor in-memory LDAP server alongside CTS, configures Root cause of findings 2 and 3Both issues below share a common root cause: the integration test configuration uses MUST FIX: Out-of-scope revert of CodeCov integrationFiles: This PR removes three changes that were already merged to
Introduced by this PR. SHOULD FIX:
|
All three issues from the latest review have been addressed and squashed into the original commit. 1. CodeCov regression restored: The PR was inadvertently dropping 2. 3. LDAP |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #75 +/- ##
=======================================
Coverage 81.95% 81.95%
=======================================
Files 13 13
Lines 1302 1302
=======================================
Hits 1067 1067
Misses 235 235
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review: Add OIDC authentication to integration testsThe PR deploys Dex (OIDC) and a Python/ldaptor in-memory LDAP server alongside CTS in the EaaS pipeline, configures Acceptance Criteria Check
File Diff VerificationFiles in
Issues FoundSHOULD FIX:
|
|
Try replacing OIDCOAuthSSLValidateServer Off with OIDCCABundlePath /etc/dex-ca/ca.crt to bypass the system trust store. |
Deploys Dex (OIDC provider) and a Python/ldaptor in-memory LDAP server alongside CTS in the EaaS pipeline and exercises the full auth stack end-to-end. Pipeline changes (.tekton/integration-test-eaas.yaml): - New deploy-glauth task replaced by deploy-openldap (Python/ldaptor, runs as arbitrary UID on port 1389, allows anonymous bind/search) - New deploy-dex task: generates self-signed CA + TLS cert (SAN: DNS:dex), stores in dex-tls/dex-ca Secrets, deploys Dex over HTTPS on port 5556 - Updated deploy-cts: runAfter includes deploy-openldap and deploy-dex; cts-config ConfigMap sets AUTH_BACKEND=oidc_or_kerberos, AUTH_OPENIDC_USERINFO_URI, AUTH_LDAP_SERVER, AUTH_LDAP_GROUPS, ADMINS, and ALLOWED_BUILDERS - httpd.conf uses AuthType auth-openidc for Bearer requests and AuthType openid-connect for browser flows; OIDCOAuthVerifyJwksUri validates bearer tokens as JWTs using Dex JWKS endpoint; OIDCCABundlePath /etc/dex-ca/ca.crt used for TLS validation so Dex's self-signed cert is trusted without disabling SSL validation; SetEnv OIDC_CLAIM_scope scoped to Bearer requests only - Updated run-tests: installs packages to /tmp/test-deps, passes REQUESTS_CA_BUNDLE pointing at Dex CA, passes AUTH_BACKEND=oidc_or_kerberos Test changes (tests/test_integration_api.py): - AuthHTTPClient: HTTPClient subclass injecting Authorization: Bearer - _get_oidc_token(): obtains access token from Dex via ROPC grant; _make_ssl_context() loads CA from REQUESTS_CA_BUNDLE for urlopen - write_http_client fixture: returns AuthHTTPClient (builder token) under OIDC or plain HTTPClient in noauth mode; used by pre-existing workflow tests - Four new auth tests (skipped when AUTH_BACKEND is noauth or unset): test_auth_unauthenticated_write_returns_401, test_auth_builder_can_post_compose, test_auth_unauthorized_user_returns_403, test_auth_get_endpoints_accessible_without_token - Skip messages read AUTH_BACKEND=openidc or oidc_or_kerberos Generated-By: OpenCode (google-vertex-anthropic/claude-sonnet-4-6@default)
Replaced |
Code Review: Add OIDC authentication to integration testsAcceptance Criteria Check
File Diff VerificationFiles in
FindingsNIT:
|
Add OIDC authentication to integration tests
Deploys Dex (OIDC provider) and GLAuth (LDAP) alongside CTS in the EaaS pipeline
and exercises the full
mod_auth_openidc→load_openidc_user→get_user_info→query_ldap_groups→has_roleauth stack end-to-end.Pipeline changes (
.tekton/integration-test-eaas.yaml)deploy-glauthtask (runs in parallel withdeploy-dexafterprovision-environment): creates aConfigMapwith a GLAuth config defining twousers (
builder/readonly) and one group (cts-builders), then deploys GLAuthon port 389.
deploy-dextask (parallel withdeploy-glauth): creates aConfigMapwith a Dex config using the password connector and a static OAuth2 client
(
cts-integration), then deploys Dex on port 5556.deploy-cts:runAfternow includesdeploy-glauthanddeploy-dex.The
cts-configConfigMap setsAUTH_BACKEND=openidc,AUTH_OPENIDC_USERINFO_URI,AUTH_LDAP_SERVER,AUTH_LDAP_GROUPS,ADMINS, andALLOWED_BUILDERS.The
httpd.confgainsmod_auth_openidcdirectives (OIDCProviderMetadataURL,OIDCOAuthVerifyJwksUri,OIDCClientID/Secret,OIDCRemoteUserClaim) and the<RequireAny>block that allows unauthenticated GET requests while requiring avalid Bearer token for writes.
run-tests: installsrequestsalongsidepytestand passesAUTH_BACKEND=openidcto the test runner so the auth tests are not skipped.Test changes (
tests/test_integration_api.py)AuthHTTPClient:HTTPClientsubclass that injectsAuthorization: Beareron every request.
_get_oidc_token(): obtains a real access token from Dex via the ROPC grant;used by
auth_http_client_builderandauth_http_client_readonlyfixtures.AUTH_BACKEND≠openidc):test_auth_unauthenticated_write_returns_401– bare POST → 401test_auth_builder_can_post_compose–builderBearer token → 200test_auth_unauthorized_user_returns_403–readonlyBearer token → 403test_auth_get_endpoints_accessible_without_token– unauthenticated GET → 200All pre-existing tests continue to pass unchanged under
AUTH_BACKEND=noauth.