Repository navigation
Conversation
With `LABELBURG_PASSWORD` set, every page and API route asks for it. Unset, nothing changes. 1. Browsers sign in once on a page with one field and stay signed in for a year through a signed cookie. A new password signs everyone out, and "Sign out" is in the Settings, About. 2. Programs send it as `Authorization: Bearer <password>` or as HTTP Basic with any user name. `/mcp` takes it where `MCP_TOKEN` is unset. 3. Five wrong passwords from one address within a minute refuse that address for the minute, answered at once. 4. The webhook keeps `WEBHOOK_PASSWORD`. All three secrets ignore spaces around them. Signed-off-by: DL6ER <dl6er@dl6er.de>
How to set `LABELBURG_PASSWORD`, and how Home Assistant, Grocy, Homebox, Paperless and MCP clients send it. Signed-off-by: DL6ER <dl6er@dl6er.de>
…assword Signed-off-by: DL6ER <dl6er@dl6er.de>
|
|
||
|
|
||
| def _digest(key: bytes, purpose: bytes, word: str) -> bytes: | ||
| return hmac.new(key, purpose + b'\0' + _bytes(word), hashlib.sha256).digest() |
| def _hashed(value: bytes, longest: int) -> bytes | None: | ||
| """The hash value is compared by, None for one longer than longest, | ||
| which is wrong without hashing it.""" | ||
| return hashlib.sha256(value).digest() if len(value) <= longest else None |
| kept = state.secrets.get(of) | ||
| if kept is None or kept[0] != secret: | ||
| raw = _bytes(secret) | ||
| kept = state.secrets[of] = (secret, hashlib.sha256(raw).digest(), max(MAX_SENT, len(raw))) |
| def same(given: bytes, secret: str) -> bool: | ||
| """Whether given is secret, compared as the password is but not counted.""" | ||
| raw = _bytes(secret) | ||
| return _matches(_hashed(given, max(MAX_SENT, len(raw))), hashlib.sha256(raw).digest()) |
| target = local_target(request.values.get('next')) | ||
| if request.method == 'GET': | ||
| if _signed_in(worked): | ||
| return redirect(target or url_for('labeldesigner.index'), 303) |
| return render_template('signin.html', target=target or '', told=None) | ||
| right = attempt(current_app, request.remote_addr, request.form.get('password', '').encode('utf-8'), word) | ||
| if right: | ||
| response = redirect(target or url_for('labeldesigner.index'), 303) |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
LABELBURG_PASSWORDset, every page and API route asks for it. Unset, nothing changes.Browsers sign in once and stay signed in for a year, and "Sign out" is in the Settings under About. Programs send the password as a Bearer token or by HTTP Basic, so Home Assistant, Grocy, Homebox and Paperless keep printing, see the docs. Five wrong passwords from one address within a minute refuse it for that minute. The webhook keeps
WEBHOOK_PASSWORD.