forked from docat-org/docat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): Allow project auto-claim with pre-defined token
By declaring the environment variable(s) `DOCAT_GLOBAL_CLAIM_TOKEN` (and optionally `DOCAT_GLOBAL_CLAIM_SALT`), all projects can be automatically claimed with a previously defined token (and salt). This resolves docat-org#618.
- Loading branch information
Showing
6 changed files
with
115 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from typing import Optional | ||
|
||
ENV_GLOBAL_CLAIM_TOKEN = "DOCAT_GLOBAL_CLAIM_TOKEN" | ||
ENV_GLOBAL_CLAIM_SALT = "DOCAT_GLOBAL_CLAIM_SALT" | ||
|
||
|
||
def get_global_claim_token() -> Optional[str]: | ||
"""Returns the global claim token which can be defined by an environment variable. | ||
Returns: | ||
The optional global claim token or None. | ||
""" | ||
return os.environ.get(ENV_GLOBAL_CLAIM_TOKEN, None) | ||
|
||
|
||
def get_global_claim_salt() -> Optional[bytes]: | ||
"""Returns the global claim salt which can be defined by an environment variable. | ||
Returns: | ||
The optional global claim salt or None. | ||
""" | ||
global_claim_salt = os.environ.get(ENV_GLOBAL_CLAIM_SALT, None) | ||
if global_claim_salt is not None: | ||
return global_claim_salt.encode() | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters