Compare commits
3 Commits
011b68c179
...
0aaf99da97
Author | SHA1 | Date | |
---|---|---|---|
0aaf99da97
|
|||
f2593e209e
|
|||
65475912c1
|
@ -26,6 +26,7 @@ oauth.register(
|
||||
client_secret=KEYCLOAK_CLIENT_SECRET,
|
||||
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",
|
||||
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")
|
||||
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)
|
||||
|
||||
|
||||
@app.get("/auth")
|
||||
async def auth(request: Request):
|
||||
@app.get("/auth/keycloak")
|
||||
async def auth_keycloak(request: Request):
|
||||
try:
|
||||
token = await oauth.keycloak.authorize_access_token(request)
|
||||
user = await oauth.keycloak.parse_id_token(request, token)
|
||||
|
@ -3,6 +3,6 @@
|
||||
<title>Home</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello, {{ user }}</p>
|
||||
<p>Hello, {{ user.preferred_username }}</p>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user