v7.2.0: Use new format for new tokens

master v7.2.0
SporeStack 1 month ago
parent d8043414a8
commit 28892e8ff3
  1. 4
      .pre-commit-config.yaml
  2. 6
      .woodpecker.yml
  3. 6
      CHANGELOG.md
  4. 4
      src/sporestack/__init__.py
  5. 7
      src/sporestack/utils.py
  6. 6
      tests/test_utils.py

@ -23,10 +23,6 @@ repos:
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: ce506f9063be3e882d391cdf7b6a3d5f8359add8 # frozen: v1.20.1
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/jackdewinter/pymarkdown
rev: be56696256d5491e8a907b72e5a3852034546adb # frozen: v0.9.5
hooks:

@ -3,7 +3,7 @@ pipeline:
group: test
image: python:3.7-alpine
commands:
- pip install pipenv==2022.9.4
- pip install pipenv==2022.10.25
- pipenv install --dev --deploy
- pipenv run almake test-pytest # We only test with pytest on 3.7
@ -22,7 +22,7 @@ pipeline:
group: test
image: python:3.9-alpine
commands:
- pip install pipenv==2022.9.4 pre-commit==2.22.0
- pip install pipenv==2022.10.25 pre-commit==2.22.0
- pre-commit run --all-files
- pipenv install --dev --deploy
- pipenv run almake test
@ -33,7 +33,7 @@ pipeline:
group: test
image: python:3.10-alpine
commands:
- pip install pipenv==2022.9.4 pre-commit==2.22.0
- pip install pipenv==2022.10.25 pre-commit==2.22.0
- pre-commit run --all-files
- pipenv install --dev --deploy
- pipenv run almake test

@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [7.2.0 - 2022-11-01]
### Changed
- Use new format for new tokens.
## [7.1.2 - 2022-11-01]
### Changed

@ -1,5 +1,5 @@
"""SporeStack API and CLI for launching servers with Bitcoin or Monero"""
"""SporeStack API and CLI for launching servers with Monero or Bitcoin"""
__all__ = ["api", "api_client", "exceptions"]
__version__ = "7.1.2"
__version__ = "7.2.0"

@ -14,7 +14,7 @@ def checksum(to_hash: str) -> str:
def random_machine_id() -> str:
"""
These used to be 64 hex characters. Now they have a new format.
Machine IDs have a 32 character format with a checksum.
"""
to_hash = f"ss_m_{secrets.token_hex(11)}"
return f"{to_hash}_{checksum(to_hash)}"
@ -22,6 +22,7 @@ def random_machine_id() -> str:
def random_token() -> str:
"""
64 hex characters.
Tokens have a 32 character format with a checksum.
"""
return secrets.token_hex(32)
to_hash = f"ss_t_{secrets.token_hex(11)}"
return f"{to_hash}_{checksum(to_hash)}"

@ -7,5 +7,11 @@ def test_random_machine_id() -> None:
assert utils.random_machine_id().startswith("ss_m_")
def test_random_token() -> None:
assert utils.random_token() != utils.random_token()
assert len(utils.random_token()) == 32
assert utils.random_token().startswith("ss_t_")
def test_hash() -> None:
assert utils.checksum("ss_m_1deadbeefcafedeadbeef1") == "0892"

Loading…
Cancel
Save