Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preconfigure or automate installations of ctfd #2457

Open
jonakarl opened this issue Jan 25, 2024 · 6 comments
Open

Preconfigure or automate installations of ctfd #2457

jonakarl opened this issue Jan 25, 2024 · 6 comments
Milestone

Comments

@jonakarl
Copy link

I am not sure if it is possible (at least I have not seen it documented) to automate installations of ctfd.

My goal is to automatically deploy ctfd as docker services that is ready to run and to achieve this I need to automate:

  1. Disabling of the setup wizard
  2. Configuration of a admin user and set or acquire a admin token (via api calls or environment variables to the docker container)

Alternatively:

  1. Be able to pre-configure the values of the setup wizard and "admin token".
    • Either via environment variables or by hard coding them in the build phase of the docker image.

Is this in anyway possible ?

@pve
Copy link

pve commented Jan 25, 2024

Kind of. We made some progress, though it is not entirely finished. Have a look at https://gitlab.com/jointcyberrange.nl/ctfd-docker-with-plugins/-/tree/main/initial_setup?ref_type=heads and the files around it. It is a plugin.

@jonakarl
Copy link
Author

@pve Thanks this looks like what I want to do.

If I can ask a question, I am not very familiar with ctfd design but I saw a Tokens model, so I guess I need to create a separate token and then link it with the user?
somethineg like :

token  = Tokens(
            user_id=user.id,
            type='admin',
            value=os.getenv("SETUP_EVENT_ADMIN_TOKEN")
        )
db.session.add(token)
db.session.commit()
``

@pve
Copy link

pve commented Jan 26, 2024

I think if you look in our code (link above) for SETUP_EVENT_ADMIN you will find what you need.
There is still work to do on this, so let's work together.

@jonakarl
Copy link
Author

I will not have that much time to look into this in the short term (1-2 weeks) but I did find this :

def setup_ctfd(

Looks like in the main integrations tests they do a post to /setup to initiate the instance. Should do more or less what you do in your code afaik but maybe a alternative to look into. Not sure how to call this at docker start but maybe worth looking into.

@pve
Copy link

pve commented Jan 26, 2024

The general idea is to do this through environment variables and/or the config.ini file. In our Kubernetes setup we feed the environment variables through a configmap.

@pve
Copy link

pve commented Jan 26, 2024

In our repo there is a Docker file that integrates the plugins. You can build and run https://gitlab.com/jointcyberrange.nl/ctfd-docker-with-plugins/-/blob/main/Dockerfile?ref_type=heads for an immediate local demo.

@ColdHeat ColdHeat added this to the 3.8 milestone May 13, 2024
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

No branches or pull requests

3 participants