Skip to content

Commit b2655a3

Browse files
committed
feat(dev): comments;
- TODO disable redirects for logged in users.
1 parent 80cc908 commit b2655a3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ckanext/language_domains/config_declaration.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ groups:
1919
description: |
2020
Secret key for JWT encoding.
2121
required: true
22+
- key: ckanext.language_domains.redirect_user_sessions
23+
example: true
24+
default: false
25+
description: >
26+
Controls whether or not domains will be redirected for
27+
logged in users. E.g. if logged in on the English domain,
28+
you will not be redirected to the French domain - and vice versa.
29+
This helps with sticky sessions when not using the
30+
ckanext.language_domains.enable_jwt_login option.
31+
required: false
32+
validators: ignore_missing boolean_validator
2233
- key: ckanext.language_domains.enable_jwt_login
2334
example: true
2435
default: false

ckanext/language_domains/plugin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def __init__(self, app: Any, config: 'CKANConfig'):
7272
self.default_domain = uri_parts.netloc
7373
self.domain_scheme = uri_parts.scheme
7474
self.root_paths = config.get('ckanext.language_domains.root_paths')
75+
self.redirect_user_sessions = config.get(
76+
'ckanext.language_domains.redirect_user_sessions', False)
77+
self.enable_jwt_login = config.get(
78+
'ckanext.language_domains.enable_jwt_login', False)
7579

7680
def __call__(self, environ: Any, start_response: Any) -> Any:
7781
extra_response_headers = []
@@ -114,6 +118,7 @@ def __call__(self, environ: Any, start_response: Any) -> Any:
114118
def _start_response(status: str,
115119
response_headers: List[Tuple[str, str]],
116120
exc_info: Optional[Any] = None):
121+
# TODO: check if there is a user and don't do domain redirects??
117122
return start_response(
118123
# browser requires non 200 response for Location header
119124
status if not extra_response_headers else '301',

0 commit comments

Comments
 (0)