Skip to content

fix: generate IDs and tokens with secrets #69

Closed

Description

@uniqueg

Generated identifiers and access tokens should follow standard practice, and their character set settings should be read robustly:

  • Draw characters with secrets.choice (the standard library's module for tokens) instead of random.choice in generate_id().
  • Read the character set settings (endpoints.repository.id_charset, endpoints.user.uid_charset, endpoints.access_token.charset) with a fixed lookup of named character sets (e.g., string.ascii_lowercase, string.digits) plus literal characters, instead of eval. The current forms keep working: lists such as [string.ascii_lowercase, string.digits, '.', '-'] (as in the image's configuration), strings such as string.ascii_lowercase + string.digits + '.' + '-', single names, and literal characters.
  • Check these settings at start, and stop with an error naming the setting if one can't be used (unknown name, wrong type, no character left for the start and end of values).
  • Document the settings in the configuration reference and the upgrade notes.

This also unblocks the ruff rules planned in #38.

Activity

  1. added
    priority: medium
    status: in progress
    type: bug
    workload: hours
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 7, 2026
  3. removed
    status: in progress
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype: bugworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions