Compare commits
3
Commits
011b68c179
...
0aaf99da97
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0aaf99da97
|
||
|
|
f2593e209e
|
||
|
|
65475912c1
|
@@ -26,6 +26,7 @@ oauth.register(
|
|||||||
client_secret=KEYCLOAK_CLIENT_SECRET,
|
client_secret=KEYCLOAK_CLIENT_SECRET,
|
||||||
authorize_url=f"https://{KEYCLOAK_DOMAIN}/auth/realms/{KEYCLOAK_REALM}/protocol/openid-connect/auth",
|
authorize_url=f"https://{KEYCLOAK_DOMAIN}/auth/realms/{KEYCLOAK_REALM}/protocol/openid-connect/auth",
|
||||||
access_token_url=f"https://{KEYCLOAK_DOMAIN}/auth/realms/{KEYCLOAK_REALM}/protocol/openid-connect/token",
|
access_token_url=f"https://{KEYCLOAK_DOMAIN}/auth/realms/{KEYCLOAK_REALM}/protocol/openid-connect/token",
|
||||||
|
jwks_uri=f"https://{KEYCLOAK_DOMAIN}/auth/realms/{KEYCLOAK_REALM}/protocol/openid-connect/certs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -41,12 +42,12 @@ async def home(request: Request):
|
|||||||
|
|
||||||
@app.get("/login/keycloak")
|
@app.get("/login/keycloak")
|
||||||
async def login_keycloak(request: Request):
|
async def login_keycloak(request: Request):
|
||||||
redirect_uri = request.url_for("auth")
|
redirect_uri = request.url_for("auth_keycloak")
|
||||||
return await oauth.keycloak.authorize_redirect(request, redirect_uri)
|
return await oauth.keycloak.authorize_redirect(request, redirect_uri)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/auth")
|
@app.get("/auth/keycloak")
|
||||||
async def auth(request: Request):
|
async def auth_keycloak(request: Request):
|
||||||
try:
|
try:
|
||||||
token = await oauth.keycloak.authorize_access_token(request)
|
token = await oauth.keycloak.authorize_access_token(request)
|
||||||
user = await oauth.keycloak.parse_id_token(request, token)
|
user = await oauth.keycloak.parse_id_token(request, token)
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
<title>Home</title>
|
<title>Home</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Hello, {{ user }}</p>
|
<p>Hello, {{ user.preferred_username }}</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user