Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
requests-http-message-signatures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
requests-http-message-signatures
Commits
bfc19760
Unverified
Commit
bfc19760
authored
3 years ago
by
Georg Krause
Browse files
Options
Downloads
Patches
Plain Diff
Make correct use of class methods
parent
8d962826
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#20030
failed
3 years ago
Stage: lint
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
requests_http_message_signatures/__init__.py
+8
-7
8 additions, 7 deletions
requests_http_message_signatures/__init__.py
with
8 additions
and
7 deletions
requests_http_message_signatures/__init__.py
+
8
−
7
View file @
bfc19760
...
...
@@ -112,7 +112,7 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
@classmethod
def
get_string_to_sign
(
self
,
request
,
headers
,
created_timestamp
,
expires_timestamp
cls
,
request
,
headers
,
created_timestamp
,
expires_timestamp
):
sts
=
[]
for
header
in
headers
:
...
...
@@ -180,7 +180,7 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
return
request
@classmethod
def
get_sig_struct
(
self
,
request
,
scheme
=
"
Authorization
"
):
def
get_sig_struct
(
cls
,
request
,
scheme
=
"
Authorization
"
):
sig_struct
=
request
.
headers
[
scheme
]
if
scheme
==
"
Authorization
"
:
sig_struct
=
sig_struct
.
split
(
"
"
,
1
)[
1
]
...
...
@@ -190,7 +190,7 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
}
@classmethod
def
verify
(
self
,
request
,
key_resolver
,
scheme
=
"
Authorization
"
):
def
verify
(
cls
,
request
,
key_resolver
,
scheme
=
"
Authorization
"
):
if
scheme
==
"
Authorization
"
:
assert
"
Authorization
"
in
request
.
headers
,
"
No Authorization header found
"
msg
=
(
...
...
@@ -204,13 +204,13 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
'
Unknown signature scheme
"
{}
"'
.
format
(
scheme
)
)
sig_struct
=
self
.
get_sig_struct
(
request
,
scheme
=
scheme
)
sig_struct
=
cls
.
get_sig_struct
(
request
,
scheme
=
scheme
)
for
field
in
"
keyId
"
,
"
algorithm
"
,
"
signature
"
:
assert
(
field
in
sig_struct
),
'
Required signature parameter
"
{}
"
not found
'
.
format
(
field
)
assert
(
sig_struct
[
"
algorithm
"
]
in
self
.
known_algorithms
sig_struct
[
"
algorithm
"
]
in
cls
.
known_algorithms
),
"
Unknown signature algorithm
"
created_timestamp
=
(
int
(
sig_struct
[
"
created
"
])
if
"
created
"
in
sig_struct
else
None
...
...
@@ -220,7 +220,7 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
expires_timestamp
=
int
(
expires_timestamp
)
headers
=
sig_struct
.
get
(
"
headers
"
,
"
date
"
).
split
(
"
"
)
sig
=
base64
.
b64decode
(
sig_struct
[
"
signature
"
])
sts
=
self
.
get_string_to_sign
(
sts
=
cls
.
get_string_to_sign
(
request
,
headers
,
created_timestamp
,
expires_timestamp
=
expires_timestamp
)
key
=
key_resolver
(
...
...
@@ -241,5 +241,6 @@ class HTTPSignatureHeaderAuth(HTTPSignatureAuth):
request
.
headers
[
"
Signature
"
]
=
self
.
create_signature_string
(
request
)
return
request
def
verify
(
self
,
request
,
key_resolver
):
@classmethod
def
verify
(
cls
,
request
,
key_resolver
):
return
super
().
verify
(
request
,
key_resolver
,
scheme
=
"
Signature
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment