-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎉 Source Github: Add MultipleTokenAuthenticator #5223
Changes from 9 commits
86018f1
6a9beb8
d8a7437
db9609c
278e0af
a57965d
66e7be7
439301c
f5cc341
035f665
b0c0683
9f50c4e
d3e2235
c215314
0a8979e
626e615
26fc9a5
8e0aaf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# Changelog | ||
|
||
## 0.1.9 | ||
Add multiple token support | ||
|
||
## 0.1.8 | ||
Allow to fetch primary key info from singer catalog | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# Initialize Auth Package | ||
from .core import HttpAuthenticator, NoAuth | ||
from .oauth import Oauth2Authenticator | ||
from .token import TokenAuthenticator | ||
from .token import MultipleTokenAuthenticator, TokenAuthenticator | ||
|
||
__all__ = [ | ||
"HttpAuthenticator", | ||
"NoAuth", | ||
"Oauth2Authenticator", | ||
"TokenAuthenticator", | ||
"MultipleTokenAuthenticator", | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,16 @@ | |
# | ||
|
||
|
||
from itertools import cycle | ||
from typing import Any, Mapping | ||
|
||
from .core import HttpAuthenticator | ||
|
||
TOKEN_SEPARATOR = "," | ||
|
||
|
||
TOKEN_SEPARATOR = "," | ||
|
||
|
||
class TokenAuthenticator(HttpAuthenticator): | ||
def __init__(self, token: str, auth_method: str = "Bearer", auth_header: str = "Authorization"): | ||
|
@@ -36,3 +42,14 @@ def __init__(self, token: str, auth_method: str = "Bearer", auth_header: str = " | |
|
||
def get_auth_header(self) -> Mapping[str, Any]: | ||
return {self.auth_header: f"{self.auth_method} {self._token}"} | ||
|
||
|
||
class MultipleTokenAuthenticator(HttpAuthenticator): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you add a doc string explaining what this does e.g:
|
||
def __init__(self, tokens: str, auth_method: str = "Bearer", auth_header: str = "Authorization"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should take a list of strings rather than a comma separated string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, updated |
||
self.auth_method = auth_method | ||
self.auth_header = auth_header | ||
self._tokens = [line.strip() for line in tokens.split(TOKEN_SEPARATOR)] | ||
self._tokens_iter = cycle(self._tokens) | ||
|
||
def get_auth_header(self) -> Mapping[str, Any]: | ||
return {self.auth_header: f"{self.auth_method} {next(self._tokens_iter)}"} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"properties": { | ||
"access_token": { | ||
"type": "string", | ||
gaart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"description": "Log into Github and then generate a <a href=\"https://github.com/settings/tokens\"> personal access token</a>.", | ||
"description": "Log into Github and then generate a <a href=\"https://github.com/settings/tokens\"> personal access token</a>. Separate multiple tokens with \",\"", | ||
gaart marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, Could you create an issue to update this to a list of strings once #5396 is resolved? |
||
"airbyte_secret": true | ||
}, | ||
"organization": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need two versions for the same release? can we just make it a single version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not. But both are released already