-
Notifications
You must be signed in to change notification settings - Fork 673
chore: add authentication type to GitlabAuthenticationError #1793
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -52,7 +52,24 @@ def __str__(self) -> str: | |
|
||
|
||
class GitlabAuthenticationError(GitlabError): | ||
pass | ||
def __init__( | ||
self, | ||
error_message: Union[str, bytes] = "", | ||
response_code: Optional[int] = None, | ||
response_body: Optional[bytes] = None, | ||
auth_type: str = "", | ||
) -> None: | ||
super().__init__( | ||
error_message=error_message, | ||
response_code=response_code, | ||
response_body=response_body, | ||
) | ||
self.auth_type = auth_type | ||
Comment on lines
+55
to
+67
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. Maybe we could add |
||
|
||
def __str__(self) -> str: | ||
if self.auth_type: | ||
return f"{super().__str__()}: authentication_type: {self.auth_type}" | ||
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. If we decide to infer the auth type automatically I'd maybe reformulate this a bit. Not sure exactly how, just |
||
return super().__str__() | ||
|
||
|
||
class RedirectError(GitlabError): | ||
|
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.
I think we could actually reuse
self.headers
and pass it (or just the dict keys) to the exception to infer the auth type, without adding custom variables here.http_username
/http_password
is basically dead code as HTTP Basic auth has been out of GitLab since version 10 so we don't need to worry about that (I actually have a local draft that performs password-based OAuth login from that). So we're left withPrivate-Token
,Job-Token
, andAuthorization
(OAuth bearer) from headers. We could probably just pass the keys from the headers dict to not leak stuff accidentally.