feat(integrations): CTFd plugin for Dploy environments - #43
Open
AYDEV-FR wants to merge 1 commit into
Open
Conversation
Add a CTFd plugin that lets players start/stop/extend/check an on-demand Dploy environment directly from the challenge view. Rather than a custom challenge type, any standard challenge becomes a Dploy challenge when its Connection Info is a Dploy run URL (e.g. https://dploy.example.com/run/<template>); the plugin parses the API base + template from it server-side and injects a Start/Refresh/Extend/Stop panel into the challenge modal. Auth uses a BFF model: the browser only calls same-origin proxy routes; the plugin obtains a CTFd-issued id_token for the player via a trusted, auto-approved OIDC auth-code+PKCE bounce against CTFd's own provider (the companion ctfd-oidc-provider plugin), caches it server-side, and forwards it to Dploy as a Bearer token. Aligning the client id with Dploy's JWT_AUDIENCE (dploy) and requesting the profile scope (name claim) means no auth problem appears. Also includes a docker-compose test stack: CTFd with both plugins plus a mock Dploy API that validates tokens against CTFd's JWKS exactly like real Dploy, exercising the full auth + proxy + UI path without a Kubernetes cluster. Claude-Session: https://claude.ai/code/session_01M4Dd5oASBGHwr6ts6wTnYn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a CTFd plugin (
integrations/ctfd_dploy/) that lets players start / stop / extend / check an on-demand Dploy environment directly from the challenge view.It pairs with the companion
ctfd-oidc-providerplugin: CTFd is the OIDC Provider of Dploy, so a CTFd-issued token is exactly what Dploy's API trusts.How it works
No custom challenge type. Any standard challenge becomes a Dploy challenge when its Connection Info is a Dploy run URL, e.g.
https://dploy.example.com/run/podinfo. The plugin parses the API base + template server-side and injects a Start/Refresh/Extend/Stop panel into the challenge modal. The detection pattern is configurable (DPLOY_URL_PATTERN).Auth (BFF / Backend-For-Frontend):
/plugins/ctfd_dploy/challenges/<id>/{start,status,extend,stop}), gated by CTFd session + CSRF.id_tokenfor the player via a trusted, auto-approved OIDC auth-code+PKCE bounce against CTFd's own provider, caches it in the Flask session, and forwards it to Dploy as aBearertoken. The token never reaches JavaScript.connection_info, never a client value (SSRF-safe).Why "no auth problems": the OAuth client id is
dploy(matches Dploy'sJWT_AUDIENCE=dploy) and theprofilescope is requested (Dploy'sJWT_USERNAME_CLAIM=name), all against the same CTFd issuer + JWKS. No changes to Dploy itself.Test stack
integrations/testing/adds adocker compose up --buildstack: CTFd with both plugins + a mock Dploy API that validates tokens against CTFd's JWKS exactly like real Dploy (RS256,iss/aud,nameclaim). Exercises the full auth + proxy + UI path without a Kubernetes cluster. Seeintegrations/testing/README.md.Notes / not yet verified
coretheme; the panel is injected by observing the challenge modal (findModalBodyselectors are defensive). A heavily customized theme may need a tweak.connection_infofield.dploy.jspassesnode --check.https://claude.ai/code/session_01M4Dd5oASBGHwr6ts6wTnYn