misc: fix checking for authentic2 context (#84843)
gitea/hobo/pipeline/head This commit looks good
Details
gitea/hobo/pipeline/head This commit looks good
Details
INSTALLED_APPS in authentic2.settings does not contain the string 'authentic2' anymore, we should not use it as a flag for the authentic2 context.
This commit is contained in:
parent
2052668f72
commit
2de52d9eb2
|
@ -285,7 +285,7 @@ if 'django.middleware.common.CommonMiddleware' in MIDDLEWARE:
|
|||
if PROJECT_NAME != 'wcs':
|
||||
MIDDLEWARE = ('hobo.middleware.RobotsTxtMiddleware',) + MIDDLEWARE
|
||||
|
||||
if PROJECT_NAME != 'wcs' and 'authentic2' not in INSTALLED_APPS:
|
||||
if PROJECT_NAME != 'wcs' and 'authentic' not in PROJECT_NAME:
|
||||
MIDDLEWARE = MIDDLEWARE + (
|
||||
'mellon.middleware.PassiveAuthenticationMiddleware',
|
||||
'hobo.provisionning.middleware.ProvisionningMiddleware',
|
||||
|
@ -293,7 +293,7 @@ if PROJECT_NAME != 'wcs' and 'authentic2' not in INSTALLED_APPS:
|
|||
if PROJECT_NAME != 'wcs':
|
||||
INSTALLED_APPS += ('hobo.user_name.apps.UserNameConfig',)
|
||||
|
||||
if 'authentic2' in INSTALLED_APPS:
|
||||
if 'authentic' in PROJECT_NAME:
|
||||
MIDDLEWARE = MIDDLEWARE + ('hobo.agent.authentic2.middleware.ProvisionningMiddleware',)
|
||||
|
||||
# Allow big provisionning messages
|
||||
|
@ -369,12 +369,12 @@ if PROJECT_NAME != 'wcs':
|
|||
INSTALLED_APPS = ('hobo.multitenant',) + INSTALLED_APPS
|
||||
|
||||
# SAML2: search IdP in <tenant>
|
||||
if 'authentic2' not in INSTALLED_APPS:
|
||||
if 'authentic' not in PROJECT_NAME:
|
||||
MELLON_ADAPTER = ('hobo.multitenant.mellon.MellonAdapter',)
|
||||
|
||||
TEMPLATES[0]['OPTIONS'].setdefault('builtins', []).append('hobo.templatetags.hobo')
|
||||
|
||||
if 'authentic2' not in INSTALLED_APPS:
|
||||
if 'authentic' not in PROJECT_NAME:
|
||||
MELLON_DEFAULT_ASSERTION_CONSUMER_BINDING = 'artifact'
|
||||
MELLON_OPENED_SESSION_COOKIE_NAME = 'A2_OPENED_SESSION'
|
||||
MELLON_ADD_AUTHNREQUEST_NEXT_URL_EXTENSION = True
|
||||
|
@ -405,7 +405,7 @@ STATICS_HASH_COUNTER = '/var/lib/publik/statics-counter'
|
|||
if 'rest_framework' in INSTALLED_APPS:
|
||||
if 'REST_FRAMEWORK' not in globals():
|
||||
REST_FRAMEWORK = {}
|
||||
if 'authentic2' not in INSTALLED_APPS:
|
||||
if 'authentic' not in PROJECT_NAME:
|
||||
REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = (
|
||||
'hobo.rest_authentication.PublikAuthentication',
|
||||
'hobo.rest_authentication.APIClientAuthentication',
|
||||
|
|
|
@ -189,7 +189,7 @@ def theme_base(request):
|
|||
def portal_agent_url(request):
|
||||
def get_portal_agent_url():
|
||||
portal_agents = []
|
||||
if 'authentic2' in settings.INSTALLED_APPS:
|
||||
if 'authentic' in settings.PROJECT_NAME:
|
||||
portal_agents = [
|
||||
x for x in settings.KNOWN_SERVICES.get('combo', {}).values() if x.get('is-portal-agent')
|
||||
]
|
||||
|
@ -235,7 +235,7 @@ def user_urls(request):
|
|||
template_vars = getattr(settings, 'TEMPLATE_VARS', {})
|
||||
logout_url = '/logout/?'
|
||||
full_path = request.get_full_path()
|
||||
if 'authentic2' in settings.INSTALLED_APPS:
|
||||
if 'authentic' in settings.PROJECT_NAME:
|
||||
full_path = _authentic2_get_next_url(request) or full_path
|
||||
query_string = urlencode({'next': full_path})
|
||||
context = {
|
||||
|
@ -255,7 +255,7 @@ def user_urls(request):
|
|||
context['registration_url'] = (
|
||||
template_vars['idp_registration_url'] + '?' + urlencode({'next': absolute_uri})
|
||||
)
|
||||
if 'authentic2' in settings.INSTALLED_APPS:
|
||||
if 'authentic' in settings.PROJECT_NAME:
|
||||
if request.path == '/login/':
|
||||
context['login_url'] = '#'
|
||||
context['registration_url'] = '/register/?' + request.GET.urlencode()
|
||||
|
|
|
@ -2,6 +2,8 @@ import os
|
|||
|
||||
import hobo.test_utils
|
||||
|
||||
PROJECT_NAME = 'hobo'
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
BROKER_URL = 'memory://'
|
||||
LANGUAGES = [('en', 'English')]
|
||||
|
|
|
@ -149,7 +149,7 @@ def test_user_urls(settings, rf):
|
|||
# simulate the real get_next_url of authentic2
|
||||
from django.conf import settings as real_settings
|
||||
|
||||
real_settings.INSTALLED_APPS += ('authentic2',)
|
||||
real_settings.PROJECT_NAME = 'authentic2-multitenant'
|
||||
request = rf.get('/login/?next=coin&nonce=2')
|
||||
assert user_urls(request) == {
|
||||
'login_url': '#',
|
||||
|
|
Loading…
Reference in New Issue