This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Source

Learn how the Source abstraction is implemented in the plugin.

    Concept

    As explained here, the Source refers to the team or user that initiates a request. This abstraction allows compatibility with CTFd operating in either “users” or “teams” mode, making the plugin versatile and usable in both modes.

    To enable sharing across all users, the sourceId is set to 0. The table below summarizes the different scenarios:

    user_modesharedsourceId
    usersFALSEcurrent_user.id
    teamsFALSEcurrent_user.team_id
    usersTRUE0
    teamsTRUE0

    Example workflow

    Instance creation

    Here an example of sourceId usage in the instance creation process:

    flowchart LR
        A[Launch] --> B{CTFd mode}
        B -->|users| C[sourceId = user.id]
        B -->|teams| D[sourceId = user.team_id]
        D --> E{challenge.shared ?}
        C --> E
        E -->|True| F[sourceId = 0]
        E -->|False| End1
        F --> End1
    
        End1(((1)))

    The rest of the workflows is detailed in mana section.