Skip to content

Commit

Permalink
Add possibility to add additional parameters to login end-point
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 13, 2024
1 parent 80b00ce commit 7471022
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions doc/integrator/authentication_oidc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Other options
``create_user``: If ``true``, a user will be create in the geomapfish database if not exists,
default is ``false``.

``login_extra_params``: Extra parameters to add to the login request.
See `Zitadel additional parameters <https://zitadel.com/docs/apis/openidoauth/endpoints#additional-parameters>`_.
Default is ``{}``.

``match_field``: The field to use to match the user in the database, can be ``username`` (default) or ``email``.

``update_fields``: The fields to update in the database, default is: ``[]``, allowed values are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ mapping:
create_user:
type: bool
default: false
login_extra_params:
type: map
mapping:
regex;(.+):
type: str
match_field:
type: str
enum:
Expand Down
13 changes: 9 additions & 4 deletions geoportal/c2cgeoportal_geoportal/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from pyramid.view import forbidden_view_config, view_config
from sqlalchemy.orm.exc import NoResultFound # type: ignore[attr-defined]

import c2cgeoportal_commons.lib.url
from c2cgeoportal_commons import models
from c2cgeoportal_commons.lib.email_ import send_email_config
from c2cgeoportal_commons.models import static
Expand Down Expand Up @@ -618,13 +619,17 @@ def oidc_login(self) -> pyramid.response.Response:
)

try:
return HTTPFound(
location=client.authorization_code_flow.start_authentication(

url = c2cgeoportal_commons.lib.url.Url(
client.authorization_code_flow.start_authentication(
code_challenge=code_challenge,
code_challenge_method="S256",
),
headers=self.request.response.headers,
)
)
url.add_query(
self.authentication_settings.get("openid_connect", {}).get("login_extra_params", {})
)
return HTTPFound(location=url.url(), headers=self.request.response.headers)
finally:
client.authorization_code_flow.code_challenge = ""

Expand Down

0 comments on commit 7471022

Please sign in to comment.