Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
H
Hydra Node Http
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Hydra Node Http
Commits
8e6f7268
Commit
8e6f7268
authored
Aug 26, 2022
by
kurumuz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
verify token clean
parent
4e346860
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
27 deletions
+0
-27
main.py
main.py
+0
-27
No files found.
main.py
View file @
8e6f7268
...
...
@@ -37,33 +37,6 @@ mainpid = config.mainpid
hostname
=
socket
.
gethostname
()
sent_first_message
=
False
def
auth_required
(
handler
):
async
def
wrapper
(
raw_request
:
Request
,
*
args
,
**
kwargs
):
if
TOKEN
:
print
(
"got here"
)
authorization
=
raw_request
.
headers
.
get
(
"authorization"
)
if
authorization
is
None
or
authorization
!=
"Bearer "
+
TOKEN
:
return
ErrorOutput
(
error
=
"invalid token"
)
return
await
handler
(
*
args
,
**
kwargs
)
# Fix signature of wrapper
import
inspect
wrapper
.
__signature__
=
inspect
.
Signature
(
parameters
=
[
# Use all parameters from handler
*
inspect
.
signature
(
handler
)
.
parameters
.
values
(),
# Skip *args and **kwargs from wrapper parameters:
*
filter
(
lambda
p
:
p
.
kind
not
in
(
inspect
.
Parameter
.
VAR_POSITIONAL
,
inspect
.
Parameter
.
VAR_KEYWORD
),
inspect
.
signature
(
wrapper
)
.
parameters
.
values
()
)
],
return_annotation
=
inspect
.
signature
(
handler
)
.
return_annotation
,
)
return
wrapper
def
verify_token
(
req
:
Request
):
valid
=
"Authorization"
in
req
.
headers
and
req
.
headers
[
"Authorization"
]
==
"Bearer "
+
TOKEN
if
not
valid
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment