Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(login/config): merge config files into one default.py #584

Merged
merged 6 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ConfigMap
metadata:
name: bk-login-general-envs
data:
DJANGO_SETTINGS_MODULE: "bklogin.config.overlays.prod"
DJANGO_SETTINGS_MODULE: "bklogin.config.prod"
# 登录态 Cookie 写入的域名
BK_DOMAIN: {{ .Values.global.bkDomain }}
BK_LOGIN_HTTP_SCHEMA: {{ .Values.global.bkDomainScheme }}
Expand Down
21 changes: 11 additions & 10 deletions src/login/bklogin/bkaccount/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

from __future__ import unicode_literals

from django.db import models, migrations
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down Expand Up @@ -67,15 +67,16 @@ class Migration(migrations.Migration):
"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,
on_delete=django.db.models.deletion.CASCADE,
),
),
("app_id", models.CharField(max_length=30, null=True, verbose_name="APP_ID", blank=True)),
("user", models.CharField(max_length=128, null=True, blank=True)),
# (
# "user",
# models.ForeignKey(
# verbose_name="\u7528\u6237",
# to=settings.AUTH_USER_MODEL,
# on_delete=django.db.models.deletion.CASCADE,
# ),
# ),
],
options={
"db_table": "login_bklog",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from pathlib import Path

from . import PROJECT_ROOT, env

# logging config
LOG_LEVEL = env("LOG_LEVEL", default="INFO")
LOGGING_DIR = env("LOGGING_DIR", default=Path(PROJECT_ROOT) / "logs")
from django.contrib.auth.models import BaseUserManager
from django.utils import timezone


class BkUserManager(BaseUserManager):
"""BK user manager"""

def create_user(self, username, password=None):
"""
Create and saves a User with the given username and password
"""
if not username:
raise ValueError("'The given username must be set")

now = timezone.now()
user = self.model(username=username, last_login=now)
wklken marked this conversation as resolved.
Show resolved Hide resolved
user.set_password(password)
# user.save(using=self._db)
wklken marked this conversation as resolved.
Show resolved Hide resolved

return user
26 changes: 0 additions & 26 deletions src/login/bklogin/bkauth/migrations/0001_initial.py

This file was deleted.

Empty file.
6 changes: 6 additions & 0 deletions src/login/bklogin/bkauth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from django.db import models as db_models
from django.utils import timezone

from bklogin.bkauth.manager import BkUserManager
from bklogin.bkauth.utils import is_bk_token_valid
from bklogin.components.usermgr_api import upsert_user

Expand All @@ -27,6 +28,8 @@ class User(models.AbstractBaseUser, models.AnonymousUser):
username = db_models.CharField(primary_key=True, max_length=255)
USERNAME_FIELD = "username"

objects = BkUserManager()

def __init__(self, *args, **kwargs):
self.init_fields()

Expand Down Expand Up @@ -115,5 +118,8 @@ def is_authenticated(self):
def is_anonymous(self):
return not self.is_authenticated

def save(self, *args, **kwargs):
pass

class Meta(object):
app_label = "bkauth"
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ DATABASE_USER=fake-user
DATABASE_HOST=fake-db-host
DATABASE_PORT=3306
DATABASE_NAME=bk-login
DATABASE_PASSWORD=fake-password

EDITION=ce
DATABASE_PASSWORD=fake-password
25 changes: 0 additions & 25 deletions src/login/bklogin/config/common/__init__.py

This file was deleted.

73 changes: 0 additions & 73 deletions src/login/bklogin/config/common/platform.py

This file was deleted.

43 changes: 0 additions & 43 deletions src/login/bklogin/config/common/plugin.py

This file was deleted.

32 changes: 0 additions & 32 deletions src/login/bklogin/config/common/storage.py

This file was deleted.

23 changes: 0 additions & 23 deletions src/login/bklogin/config/common/system.py

This file was deleted.

Loading