Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Question] PRESET_ADMIN options - Is the email still required? + PRESET_CONFIGS example JSON \n issue #2911

@nicpenning

Description

@nicpenning

Questions:

  • Is email still required even when using the PRESET_ADMIN_* settings in the config.ini file?
  • Does the JSON sample provided in the config.ini supposed to work for the PRESET_CONFIGS?

Question 1 (Context)

Greetings! It seems like I am not able to login with the preset admin account using the config.ini unless I configured an email address, is that by design and still a requirement?

I git clone (latest code) then I do: docker compose up

I am running the latest release (3.8.1) and using the PRESET options like the following in the config.ini:

# PRESET_ADMIN_NAME
# A preset admin will be created by CTFd when the credentials provided below are used to login.
# Preset admins are only created. An existing user with the same credentials are not promoted to admins.
# This setting specifies the username for login
PRESET_ADMIN_NAME = ctfd_admin

# PRESET_ADMIN_EMAIL
# This setting specifies the email address for the preset admin credentials
PRESET_ADMIN_EMAIL = 

# PRESET_ADMIN_PASSWORD
# This setting specifies the password for the preset admin credentials
PRESET_ADMIN_PASSWORD = super_secret_password

# PRESET_ADMIN_TOKEN
# This setting specifies an optional API token that will be assigned to the preset admin user. 
# If the preset admin token is provided to the API, CTFd will create the associated admin user as if it was a standard login attempt
PRESET_ADMIN_TOKEN = ctfd_super_secret_access_token

It seems like I couldn't not log in and I was presented with not a valid username/password.

However, once populating the PRESET_ADMIN_EMAIL like so:

PRESET_ADMIN_EMAIL = [email protected]

Then I can log in and manage the CTF.

If it is required, then maybe it is a simple update in the comment that it is required.

I am unsure of the behavior of the config.ini and if the docker compose up method requires that I need to do more than docker compose down and docker compose up to take in new config.ini changes. So I have been doing docker compose down prune etc.. then deleting the entire CTFd directory then re-downloading the project and then updating the config (using automation/powershell) then docker compose up. I have found success fully populating the ADMIN_EMAIL alongside other options for it to be successful.


Question 2 (Context)

The second question is in regards to the new preset options as well and that is in regards to this sample:

 PRESET_CONFIGS = {
         "setup": true,
         "ctf_name": "ExampleCTF"
}

This seems to error during the docker compose up command getting this error:

ctfd-1   | Traceback (most recent call last):
ctfd-1   |   File "/opt/CTFd/ping.py", line 10, in <module>
ctfd-1   |     from CTFd.config import Config
ctfd-1   |   File "/opt/CTFd/CTFd/config.py", line 94, in <module>
ctfd-1   |     config_ini.read(path)
ctfd-1   |   File "/usr/local/lib/python3.11/configparser.py", line 713, in read
ctfd-1   |     self._read(fp, filename)
ctfd-1   |   File "/usr/local/lib/python3.11/configparser.py", line 1134, in _read
ctfd-1   |     raise e
ctfd-1   | configparser.ParsingError: Source contains parsing errors: '/opt/CTFd/CTFd/config.ini'
ctfd-1   |      [line 352]: '}\n'
ctfd-1 exited with code 1 (restarting)

What I found is that the new line character for the last } character, was causing it. Simply removing the new line allow the config to work:

PRESET_CONFIGS = {
         "setup": true,
         "ctf_name": "ExampleCTF"}

But for simplicity I went ahead and use something like this instead which also works:

PRESET_CONFIGS = {"setup": "true","ctf_name": "Kibana CTF"}

So the question is: Should the config support the example code as is or is my environment for handling this code wonky? If that is not proper syntax then may it could be a simple update to the comment in the config as well.

Please advise! I am not sure if these are bugs or me lacking additional information to use these features accordingly.


Lastly, I enjoy these new enhancements, and they are allowing me to fully be automated the deployment of my CTF - I can reference the open sources CTF when this feature has been implemented!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions