admin login modify
Showing
5 changed files
with
28 additions
and
5 deletions
... | @@ -203,5 +203,6 @@ class UserAdmin(admin.ModelAdmin): | ... | @@ -203,5 +203,6 @@ class UserAdmin(admin.ModelAdmin): |
203 | request.POST['_continue'] = 1 | 203 | request.POST['_continue'] = 1 |
204 | return super().response_add(request, obj, post_url_continue) | 204 | return super().response_add(request, obj, post_url_continue) |
205 | 205 | ||
206 | |||
206 | admin_site.register(Group, GroupAdmin) | 207 | admin_site.register(Group, GroupAdmin) |
207 | admin_site.register(User, UserAdmin) | 208 | admin_site.register(User, UserAdmin) | ... | ... |
... | @@ -9,7 +9,7 @@ from settings import conf | ... | @@ -9,7 +9,7 @@ from settings import conf |
9 | 9 | ||
10 | # Create your views here. | 10 | # Create your views here. |
11 | 11 | ||
12 | # https://auth-i.bmwgroup.net/auth/oauth2/intranetb2x/ | 12 | # https://auth-i.bmwgroup.net/auth/oauth2/ |
13 | iwa_url_params = { | 13 | iwa_url_params = { |
14 | 'scope': 'openid', | 14 | 'scope': 'openid', |
15 | 'response_type': 'code', | 15 | 'response_type': 'code', |
... | @@ -17,7 +17,7 @@ iwa_url_params = { | ... | @@ -17,7 +17,7 @@ iwa_url_params = { |
17 | 'client_id': conf.IWA_CLIENT_ID | 17 | 'client_id': conf.IWA_CLIENT_ID |
18 | } | 18 | } |
19 | iwa_url_params_str = '&'.join(['{0}={1}'.format(k, v) for k, v in iwa_url_params.items()]) | 19 | iwa_url_params_str = '&'.join(['{0}={1}'.format(k, v) for k, v in iwa_url_params.items()]) |
20 | iwa_url = '{0}authorize?{1}'.format(conf.IWA_URL, iwa_url_params_str) | 20 | iwa_url = '{0}intranetb2x/authorize?{1}'.format(conf.IWA_URL, iwa_url_params_str) |
21 | client_id_base64 = base64.b64encode('{0}:{1}'.format( | 21 | client_id_base64 = base64.b64encode('{0}:{1}'.format( |
22 | conf.IWA_CLIENT_ID, conf.IWA_CLIENT_SECRET).encode('utf-8')).decode('utf-8') | 22 | conf.IWA_CLIENT_ID, conf.IWA_CLIENT_SECRET).encode('utf-8')).decode('utf-8') |
23 | 23 | ... | ... |
1 | from django.contrib import admin | 1 | from django.contrib import admin |
2 | from django.views.decorators.cache import never_cache | ||
3 | from django.http import HttpResponseRedirect | ||
4 | from settings import conf | ||
5 | |||
6 | |||
7 | iwa_admin_url_params = { | ||
8 | 'scope': 'openid', | ||
9 | 'response_type': 'code', | ||
10 | 'redirect_uri': conf.IWA_REDIRECT_URI, | ||
11 | 'client_id': conf.IWA_CLIENT_ID, | ||
12 | 'acr_values': 'strongAuth4000Service' | ||
13 | } | ||
14 | iwa_admin_url_params_str = '&'.join(['{0}={1}'.format(k, v) for k, v in iwa_admin_url_params.items()]) | ||
15 | iwa_admin_url = '{0}realms/root/realms/intranetb2x/authorize?{1}'.format(conf.IWA_URL, iwa_admin_url_params_str) | ||
16 | |||
2 | 17 | ||
3 | class MyAdminSite(admin.AdminSite): | 18 | class MyAdminSite(admin.AdminSite): |
4 | site_header = 'Monty Python administration' | 19 | site_header = 'BMW OCR' |
20 | site_title = 'BMW OCR' | ||
21 | |||
22 | @never_cache | ||
23 | def login(self, request, extra_context=None): | ||
24 | return HttpResponseRedirect(iwa_admin_url) | ||
25 | |||
5 | 26 | ||
6 | admin_site = MyAdminSite(name='myadmin') | 27 | admin_site = MyAdminSite() | ... | ... |
... | @@ -35,7 +35,7 @@ ALLOWED_HOSTS = conf.ALLOWED_HOSTS | ... | @@ -35,7 +35,7 @@ ALLOWED_HOSTS = conf.ALLOWED_HOSTS |
35 | # Application definition | 35 | # Application definition |
36 | 36 | ||
37 | INSTALLED_APPS = [ | 37 | INSTALLED_APPS = [ |
38 | # 'django.contrib.admin', | 38 | # 'django.contrib.admin', |
39 | 'apps.myadmin.apps.MyAdminConfig', | 39 | 'apps.myadmin.apps.MyAdminConfig', |
40 | 'django.contrib.auth', | 40 | 'django.contrib.auth', |
41 | 'django.contrib.contenttypes', | 41 | 'django.contrib.contenttypes', | ... | ... |
-
Please register or sign in to post a comment