Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
naifu
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
naifu
Commits
9f24db3c
Commit
9f24db3c
authored
Oct 17, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add TOKEN_SERVER
parent
f3550054
Pipeline
#17219
passed with stages
in 16 minutes and 14 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
README.md
README.md
+1
-0
docker-compose.yml
docker-compose.yml
+3
-0
main.py
main.py
+19
-1
No files found.
README.md
View file @
9f24db3c
...
...
@@ -13,6 +13,7 @@
```
dockerfile
#ENV TOKEN
#ENV TOKEN_SERVER
#ENV SAVE_FILES="1"
ENV
DTYPE="float32"
...
...
docker-compose.yml
View file @
9f24db3c
...
...
@@ -8,3 +8,6 @@ services:
-
./models:/app/models
-
./main.py:/app/main.py:ro
-
./hydra_node:/app/hydra_node:ro
environment
:
# TOKEN_SERVER: https://api.moecube.com/accounts/authUser
TOKEN
:
mycard
main.py
View file @
9f24db3c
...
...
@@ -26,11 +26,14 @@ import threading
from
PIL
import
Image
from
PIL.PngImagePlugin
import
PngInfo
import
json
import
requests
genlock
=
threading
.
Lock
()
TOKEN
=
os
.
getenv
(
"TOKEN"
,
None
)
print
(
f
"Starting Hydra Node HTTP TOKEN={TOKEN}"
)
TOKEN_SERVER
=
os
.
getenv
(
"TOKEN_SERVER"
,
None
)
print
(
f
"Starting Hydra Node HTTP"
)
#Initialize model and config
model
,
config
,
model_hash
=
init_config_model
()
...
...
@@ -56,6 +59,21 @@ def verify_token(req: Request):
status_code
=
401
,
detail
=
"Unauthorized"
)
if
TOKEN_SERVER
:
if
"Authorization"
not
in
req
.
headers
:
raise
HTTPException
(
status_code
=
401
,
detail
=
"Unauthorized"
)
token
=
req
.
headers
[
"Authorization"
]
if
token
.
startswith
(
"Bearer "
):
token
=
token
[
7
:]
tokenAuthResult
=
requests
.
get
(
TOKEN_SERVER
,
headers
=
{
"Authorization"
:
"Bearer "
+
token
})
if
tokenAuthResult
.
status_code
>=
400
:
raise
HTTPException
(
status_code
=
tokenAuthResult
.
status_code
,
detail
=
"Unauthorized"
)
return
True
#Initialize fastapi
app
=
FastAPI
()
...
...
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