Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
cb704c3c
authored
2022-05-13 10:37:21 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
admin login modify
1 parent
ed61ee5e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
5 deletions
src/apps/account/admin.py
src/apps/account/views.py
src/apps/myadmin/admin.py
src/apps/myadmin/apps.py
src/settings/__init__.py
src/apps/account/admin.py
View file @
cb704c3
...
...
@@ -203,5 +203,6 @@ class UserAdmin(admin.ModelAdmin):
request
.
POST
[
'_continue'
]
=
1
return
super
()
.
response_add
(
request
,
obj
,
post_url_continue
)
admin_site
.
register
(
Group
,
GroupAdmin
)
admin_site
.
register
(
User
,
UserAdmin
)
...
...
src/apps/account/views.py
View file @
cb704c3
...
...
@@ -9,7 +9,7 @@ from settings import conf
# Create your views here.
# https://auth-i.bmwgroup.net/auth/oauth2/
intranetb2x/
# https://auth-i.bmwgroup.net/auth/oauth2/
iwa_url_params
=
{
'scope'
:
'openid'
,
'response_type'
:
'code'
,
...
...
@@ -17,7 +17,7 @@ iwa_url_params = {
'client_id'
:
conf
.
IWA_CLIENT_ID
}
iwa_url_params_str
=
'&'
.
join
([
'{0}={1}'
.
format
(
k
,
v
)
for
k
,
v
in
iwa_url_params
.
items
()])
iwa_url
=
'{0}authorize?{1}'
.
format
(
conf
.
IWA_URL
,
iwa_url_params_str
)
iwa_url
=
'{0}
intranetb2x/
authorize?{1}'
.
format
(
conf
.
IWA_URL
,
iwa_url_params_str
)
client_id_base64
=
base64
.
b64encode
(
'{0}:{1}'
.
format
(
conf
.
IWA_CLIENT_ID
,
conf
.
IWA_CLIENT_SECRET
)
.
encode
(
'utf-8'
))
.
decode
(
'utf-8'
)
...
...
src/apps/myadmin/admin.py
View file @
cb704c3
from
django.contrib
import
admin
from
django.views.decorators.cache
import
never_cache
from
django.http
import
HttpResponseRedirect
from
settings
import
conf
iwa_admin_url_params
=
{
'scope'
:
'openid'
,
'response_type'
:
'code'
,
'redirect_uri'
:
conf
.
IWA_REDIRECT_URI
,
'client_id'
:
conf
.
IWA_CLIENT_ID
,
'acr_values'
:
'strongAuth4000Service'
}
iwa_admin_url_params_str
=
'&'
.
join
([
'{0}={1}'
.
format
(
k
,
v
)
for
k
,
v
in
iwa_admin_url_params
.
items
()])
iwa_admin_url
=
'{0}realms/root/realms/intranetb2x/authorize?{1}'
.
format
(
conf
.
IWA_URL
,
iwa_admin_url_params_str
)
class
MyAdminSite
(
admin
.
AdminSite
):
site_header
=
'Monty Python administration'
site_header
=
'BMW OCR'
site_title
=
'BMW OCR'
@never_cache
def
login
(
self
,
request
,
extra_context
=
None
):
return
HttpResponseRedirect
(
iwa_admin_url
)
admin_site
=
MyAdminSite
(
name
=
'myadmin'
)
admin_site
=
MyAdminSite
()
...
...
src/apps/myadmin/apps.py
View file @
cb704c3
from
django.contrib.admin.apps
import
AdminConfig
class
MyAdminConfig
(
AdminConfig
):
default_site
=
'apps.myadmin.admin.MyAdminSite'
...
...
src/settings/__init__.py
View file @
cb704c3
...
...
@@ -35,7 +35,7 @@ ALLOWED_HOSTS = conf.ALLOWED_HOSTS
# Application definition
INSTALLED_APPS
=
[
#
'django.contrib.admin',
#
'django.contrib.admin',
'apps.myadmin.apps.MyAdminConfig'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment