Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Not prepending 'API-Key' string in front of token of auth-header. #47

Merged
merged 4 commits into from
Jan 5, 2022

Conversation

mmzx
Copy link

@mmzx mmzx commented Dec 20, 2021

This is a piece of a set of modifications that would allow the front-end to use a bearer token to be passed.

The reason for this change

In particular, one cannot assume, in general, that the Authorization header always gets created using an API-Key. This updates puts the caller (client/user) to be responsible regarding the type of token to be used (API-key or Bearer) when performing authentication against the mining backend.

The change is required to be in effect, potentially, by the time when API-Key will not be supported any more. This also includes the potential change when the mining frontend will stop using API-Key as a means of authentication for custom dashboards.

Future task(s)

  • Release a new version PyLana which is potentially backward compatible (otherwise use version constraints on the end-user side)
  • Have PyLana package creation part of CI pipeline
  • Uploading the created package to PiPy, so pip can install it.
  • In case we want to avoid creating a package, PyLana shall be incorporated in some ways into the dashboard_components repository.
  • Use a sum-type to distinguish parsed authorization header values.

@mmzx mmzx self-assigned this Dec 20, 2021
@mmzx mmzx added enhancement New feature or request bug Something isn't working labels Dec 20, 2021
mmzx added a commit to lanalabs/dashboard_components that referenced this pull request Dec 21, 2021
Check PyLana updates for further info: PR-47
lanalabs/PyLana#47
mmzx added a commit to lanalabs/dashboard_components that referenced this pull request Dec 21, 2021
Check PyLana updates for further info: PR-47
lanalabs/PyLana#47
Copy link
Contributor

@jon-ber jon-ber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The edited function would now return {'Authorization': ''} if there is a token passed without "API" or "Bearer" at the start.
Shouldn’t the unmodified token be returned?

pylana/api.py Outdated Show resolved Hide resolved
@mmzx mmzx changed the base branch from master to development January 5, 2022 16:40
@mmzx mmzx requested a review from jon-ber January 5, 2022 16:48
Copy link
Contributor

@jon-ber jon-ber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the additions of the check for the string length and the removal of the f-string it looks good to me.

@mmzx mmzx merged commit 3790185 into development Jan 5, 2022
@mmzx mmzx deleted the fix-client_must_prepare_token branch January 5, 2022 16:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants