Skip to content

Commit be7ca64

Browse files
committed
Fix oidc_paths_prefix documentation and usage
1 parent 8668230 commit be7ca64

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

django_pyoidc/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ def _fix_settings(self, op_definition: Dict[str, Any]) -> Dict[str, Any]:
165165
# is a better way to define callback path.
166166
# here this will only work when no route prefix is used.
167167

168+
op_definition["oidc_paths_prefix"] = op_definition[
169+
"oidc_paths_prefix"
170+
].lstrip("/")
171+
168172
if "oidc_callback_path" not in op_definition:
169-
op_definition["oidc_callback_path"] = reverse_lazy(
173+
op_definition["oidc_callback_path"] = (
170174
f"{op_definition['oidc_paths_prefix']}-callback"
171175
)
172176

docs/settings.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ oidc_paths_prefix
7373

7474
**Default** : dynamically computed using the name of your identity provider.
7575

76-
This is the prefix of the various url names created by the OIDCHelper when using get_urlpatterns. If not set it defaults to the op_name.
76+
This is the prefix of the various url names created *automagically* by the OIDCHelper (when using get_urlpatterns). If not set it defaults to the op_name.
7777

7878
.. note::
79-
One of the created paths is the one referenced by the setting ``oidc_callback_path``.
79+
One of the URL is the one referenced by the setting ``oidc_callback_path``.
8080

81-
You can use this setting to change how the OIDC views are named. By default they are named ``<op_name>_[login|callback]``.
81+
.. warning::
82+
If your prefix starts with a ``/`` it will be removed.
83+
84+
You can use this setting to change the prefix used to name the URLs generated by this library. By default the URLS are named ``<op_name>-[login|callback|logout|etc.]``.
8285

8386
Configuring this setting allows you to swap ``<op_name>`` with an other value.
8487

run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.test.utils import get_runner
88

99
if __name__ == "__main__":
10-
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.test_settings"
10+
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
1111
django.setup()
1212
TestRunner = get_runner(settings)
1313
test_runner = TestRunner()

0 commit comments

Comments
 (0)