Skip to content

Commit

Permalink
Be able to call logout on the OIDC provider
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 9, 2024
1 parent 89dd35e commit e6b72ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/integrator/authentication_oidc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Other options

``client_secret``: The secret of the client.

``logout``: If ``true``, the logout is called on the OIDC provider, default is ``false``.

``trusted_audiences``: The list of trusted audiences, if the audience provided by the id-token is not in
this list, the ``ID token`` will be rejected.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ mapping:
type: seq
sequence:
- type: str
logout:
type: bool
default: false
provide_roles:
type: bool
default: false
Expand Down
10 changes: 10 additions & 0 deletions geoportal/c2cgeoportal_geoportal/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import pyotp
import pyramid.request
import pyramid.response
import requests
from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPForbidden,
Expand Down Expand Up @@ -298,6 +299,15 @@ def logout(self) -> pyramid.response.Response:
client.revoke_token(user_info["access_token"])
if user_info.get("refresh_token") is not None:
client.revoke_token(user_info["refresh_token"])
if self.authentication_settings.get("openid_connect", {}).get("logout", False):
response = requests.get(client.initiate_logout(), auth=client.client_auth)
if not response.ok:
_LOG.error(
"Error during logout from OpenID Connect, code %s %s:\n%s",
response.status_code,
response.reason,
response.text,
)

headers = forget(self.request)

Expand Down

0 comments on commit e6b72ad

Please sign in to comment.