fix oauth
This commit is contained in:
parent
7f54db8939
commit
e84133364b
|
@ -1,10 +1,12 @@
|
||||||
from authlib.integrations.starlette_client import OAuth
|
from authlib.integrations.starlette_client import OAuth
|
||||||
from starlette.responses import PlainTextResponse
|
from starlette.responses import RedirectResponse
|
||||||
|
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from auth.authorize import Authorize
|
from auth.authorize import Authorize
|
||||||
from auth.identity import Identity
|
from auth.identity import Identity
|
||||||
|
|
||||||
from settings import OAUTH_CLIENTS
|
from settings import OAUTH_CLIENTS, OAUTH_CALLBACK_URL
|
||||||
|
|
||||||
oauth = OAuth()
|
oauth = OAuth()
|
||||||
|
|
||||||
|
@ -81,4 +83,5 @@ async def oauth_authorize(request):
|
||||||
}
|
}
|
||||||
user = Identity.identity_oauth(user_input)
|
user = Identity.identity_oauth(user_input)
|
||||||
token = await Authorize.authorize(user, device="pc")
|
token = await Authorize.authorize(user, device="pc")
|
||||||
return PlainTextResponse(token)
|
redirect_uri = "%s?token=%s" % (OAUTH_CALLBACK_URL, quote_plus(token))
|
||||||
|
return RedirectResponse(url = redirect_uri)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
openssl req -newkey rsa:4096 \
|
openssl req -newkey rsa:4096 \
|
||||||
-x509 \
|
-x509 \
|
||||||
-sha256 \
|
-sha256 \
|
||||||
-days 3650 \
|
-days 3650 \
|
||||||
-nodes \
|
-nodes \
|
||||||
-out discours.crt \
|
-out discours.crt \
|
||||||
-keyout discours.key \
|
-keyout discours.key \
|
||||||
-subj "/C=RU/ST=Moscow/L=Moscow/O=Discours/OU=Site/CN=build.discours.io"
|
-subj "/C=RU/ST=Moscow/L=Moscow/O=Discours/OU=Site/CN=build.discours.io"
|
||||||
|
|
||||||
openssl x509 -in discours.crt -out discours.pem -outform PEM
|
openssl x509 -in discours.crt -out discours.pem -outform PEM
|
||||||
|
|
|
@ -3,7 +3,8 @@ from os import environ
|
||||||
|
|
||||||
PORT = 8080
|
PORT = 8080
|
||||||
|
|
||||||
BACKEND_URL = "https://localhost:8080"
|
BACKEND_URL = environ.get("BACKEND_URL") or "https://localhost:8080"
|
||||||
|
OAUTH_CALLBACK_URL = environ.get("OAUTH_CALLBACK_URL") or "https://localhost:8080/authorized"
|
||||||
|
|
||||||
DB_URL = environ.get("DATABASE_URL") or environ.get("DB_URL") or "sqlite:///db.sqlite3"
|
DB_URL = environ.get("DATABASE_URL") or environ.get("DB_URL") or "sqlite:///db.sqlite3"
|
||||||
JWT_ALGORITHM = "HS256"
|
JWT_ALGORITHM = "HS256"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user