Skip to content

Commit

Permalink
fix(migration): bugfix in python3 and django 1.11 migration fail
Browse files Browse the repository at this point in the history
remove the oauth2 from login

BREAKING CHANGE: remove /login/oauth/ from login, not support oauth2.0 anymore
  • Loading branch information
wklken committed Sep 26, 2021
1 parent fe41cd6 commit 3c75c26
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 42 deletions.
2 changes: 1 addition & 1 deletion paas2/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.8
2.13.9
61 changes: 42 additions & 19 deletions paas2/login/bkaccount/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,61 @@
class Migration(migrations.Migration):

dependencies = [
('auth', '0006_require_contenttypes_0002'),
("auth", "0006_require_contenttypes_0002"),
]

operations = [
migrations.CreateModel(
name='BkToken',
name="BkToken",
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('token', models.CharField(unique=True, max_length=255, verbose_name='\u767b\u5f55\u7968\u636e', db_index=True)),
('is_logout', models.BooleanField(default=False, verbose_name='\u7968\u636e\u662f\u5426\u5df2\u7ecf\u6267\u884c\u8fc7\u9000\u51fa\u767b\u5f55\u64cd\u4f5c')),
("id", models.AutoField(verbose_name="ID", serialize=False, auto_created=True, primary_key=True)),
(
"token",
models.CharField(
unique=True, max_length=255, verbose_name="\u767b\u5f55\u7968\u636e", db_index=True
),
),
(
"is_logout",
models.BooleanField(
default=False,
verbose_name="\u7968\u636e\u662f\u5426\u5df2\u7ecf\u6267\u884c\u8fc7\u9000\u51fa\u767b\u5f55\u64cd\u4f5c",
),
),
],
options={
'db_table': 'login_bktoken',
'verbose_name': '\u767b\u5f55\u7968\u636e',
'verbose_name_plural': '\u767b\u5f55\u7968\u636e',
"db_table": "login_bktoken",
"verbose_name": "\u767b\u5f55\u7968\u636e",
"verbose_name_plural": "\u767b\u5f55\u7968\u636e",
},
),
migrations.CreateModel(
name='Loignlog',
name="Loignlog",
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('login_time', models.DateTimeField(verbose_name='\u767b\u5f55\u65f6\u95f4')),
('login_browser', models.CharField(max_length=200, null=True, verbose_name='\u767b\u5f55\u6d4f\u89c8\u5668', blank=True)),
('login_ip', models.CharField(max_length=50, null=True, verbose_name='\u7528\u6237\u767b\u5f55ip', blank=True)),
('login_host', models.CharField(max_length=100, null=True, verbose_name='\u767b\u5f55HOST', blank=True)),
('app_id', models.CharField(max_length=30, null=True, verbose_name=b'APP_ID', blank=True)),
('user', models.ForeignKey(verbose_name='\u7528\u6237', to=settings.AUTH_USER_MODEL)),
("id", models.AutoField(verbose_name="ID", serialize=False, auto_created=True, primary_key=True)),
("login_time", models.DateTimeField(verbose_name="\u767b\u5f55\u65f6\u95f4")),
(
"login_browser",
models.CharField(
max_length=200, null=True, verbose_name="\u767b\u5f55\u6d4f\u89c8\u5668", blank=True
),
),
(
"login_ip",
models.CharField(max_length=50, null=True, verbose_name="\u7528\u6237\u767b\u5f55ip", blank=True),
),
(
"login_host",
models.CharField(max_length=100, null=True, verbose_name="\u767b\u5f55HOST", blank=True),
),
("app_id", models.CharField(max_length=30, null=True, verbose_name=b"APP_ID", blank=True)),
# ('user', models.ForeignKey(verbose_name='\u7528\u6237', to=settings.AUTH_USER_MODEL)),
("user", models.CharField(max_length=128, null=True, blank=True)),
],
options={
'db_table': 'login_bklog',
'verbose_name': '\u7528\u6237\u767b\u5f55\u65e5\u5fd7',
'verbose_name_plural': '\u7528\u6237\u767b\u5f55\u65e5\u5fd7',
"db_table": "login_bklog",
"verbose_name": "\u7528\u6237\u767b\u5f55\u65e5\u5fd7",
"verbose_name_plural": "\u7528\u6237\u767b\u5f55\u65e5\u5fd7",
},
),
]
24 changes: 12 additions & 12 deletions paas2/login/conf/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"bk_i18n",
# oauth2 login
"app",
"oauth2_provider",
"bk_oauth2",
# "oauth2_provider",
# "bk_oauth2",
)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -185,16 +185,16 @@
# OAUTH2 #
############
# reference: https://django-oauth-toolkit.readthedocs.io/en/latest/settings.html
OAUTH2_PROVIDER = {
"SCOPES": {
"get_user_profile": "获取用户信息",
},
"APPLICATION_MODEL": "bk_oauth2.Application",
# 1 day
"ACCESS_TOKEN_EXPIRE_SECONDS": 86400,
# 10 mins
"AUTHORIZATION_CODE_EXPIRE_SECONDS": 600,
}
# OAUTH2_PROVIDER = {
# "SCOPES": {
# "get_user_profile": "获取用户信息",
# },
# "APPLICATION_MODEL": "bk_oauth2.Application",
# # 1 day
# "ACCESS_TOKEN_EXPIRE_SECONDS": 86400,
# # 10 mins
# "AUTHORIZATION_CODE_EXPIRE_SECONDS": 600,
# }


# Database
Expand Down
2 changes: 1 addition & 1 deletion paas2/login/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ xlwt==1.1.2
gevent==1.5.0
pytz==2016.6.1
python-dateutil==2.8.1
django_oauth_toolkit==0.12.0
# django_oauth_toolkit==0.12.0
django-decorator-include==1.3
cachetools==3.1.1

Expand Down
2 changes: 1 addition & 1 deletion paas2/login/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
url(r"^plain/$", auth_views.LoginView.as_view(is_plain=True)),
url(r"^logout/$", auth_views.LogoutView.as_view()),
# oauth2
url(r"^oauth/", decorator_include(login_exempt, "bk_oauth2.urls", namespace="oauth2_provider")),
# url(r"^oauth/", decorator_include(login_exempt, "bk_oauth2.urls", namespace="oauth2_provider")),
# ========================= the apis =========================
# TODO: 所有get_all_user/get_batch_user api应该直接调用usermgr的esb接口或者后台接口, 不应该走login
# please use api get_all_user/get_batch_user via esb, should not from login
Expand Down
14 changes: 10 additions & 4 deletions paas2/paas/app/migrations/0024_app__visiable_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
class Migration(migrations.Migration):

dependencies = [
('app', '0023_update_cc_job_en'),
("app", "0023_update_cc_job_en"),
]

operations = [
migrations.AddField(
model_name='app',
name='_visiable_labels',
field=models.CharField(max_length=1024, null=True, verbose_name='\u53ef\u89c1\u8303\u56f4\u6807\u7b7e', db_column=b'visiable_labels', blank=True),
model_name="app",
name="_visiable_labels",
field=models.CharField(
max_length=1024,
null=True,
verbose_name="\u53ef\u89c1\u8303\u56f4\u6807\u7b7e",
db_column="visiable_labels",
blank=True,
),
),
]
15 changes: 11 additions & 4 deletions paas2/paas/app/migrations/0029_auto_20201106_1139.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
class Migration(migrations.Migration):

dependencies = [
('app', '0028_merge'),
("app", "0028_merge"),
]

operations = [
migrations.AlterField(
model_name='app',
name='_visiable_labels',
field=models.CharField(db_column=b'visiable_labels', default=b'', max_length=1024, blank=True, null=True, verbose_name='\u53ef\u89c1\u8303\u56f4\u6807\u7b7e'),
model_name="app",
name="_visiable_labels",
field=models.CharField(
db_column="visiable_labels",
default=b"",
max_length=1024,
blank=True,
null=True,
verbose_name="\u53ef\u89c1\u8303\u56f4\u6807\u7b7e",
),
),
]
4 changes: 4 additions & 0 deletions paas2/release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release Log
===============================
# 2.13.9
- bugfix: python3 install migration fail
- breaking changes: remve oauth2 from login

# 2.13.8
- bugfix: smart package size calcuate error in py3

Expand Down

0 comments on commit 3c75c26

Please sign in to comment.