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

feature: 登录时,支持密码明文进行加密处理 #532

Merged
merged 7 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -24,3 +24,7 @@ data:
SENTRY_DSN: "{{ .Values.global.sentryDsn }}"
# Login API Auth Enabled 登录是否开启了 API 认证
BK_LOGIN_API_AUTH_ENABLED: "{{ .Values.bkLoginApiAuthEnabled }}"
# Rsa 登录密码加密
ENABLE_PASSWORD_RSA_ENCRYPTED: "{{ .Values.EnablePasswordRSAEncrypted }}"
PASSWORD_RSA_PUBLIC_KEY: "{{ .Values.PasswordRSAPublicKey }}"
PASSWORD_RSA_PRIVATE_KEY: "{{ .Values.PasswordRSAPrivateKey }}"
5 changes: 5 additions & 0 deletions deploy/helm/bk-user/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ global:
## sentry dsn
sentryDsn: ""

# rsa 登录密码明文加密
enablePasswordRSAEncrypted: false
passwordRSAPublicKey: ""
passwordRSAPrivateKey: ""

hostAliases: []
# - ip: ""
# hostnames:
Expand Down
8 changes: 4 additions & 4 deletions src/login/bklogin/config/common/django_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@
# RSA
# ==============================================================================

ENABLE_PASSWORD_RSA_ENCRYPTED = os.getenv("ENABLE_PASSWORD_RSA_ENCRYPTED", "True").lower() == "true"
PASSWORD_RSA_PUBLIC_KEY = os.getenv("BK_PASSWORD_RSA_PUBLIC_KEY", "")
PASSWORD_RSA_PRIVATE_KEY = os.getenv("BK_PASSWORD_RSA_PRIVATE_KEY", "")
ENABLE_PASSWORD_RSA_ENCRYPTED = env.bool("ENABLE_PASSWORD_RSA_ENCRYPTED", False)
PASSWORD_RSA_PUBLIC_KEY = env.str("BK_PASSWORD_RSA_PUBLIC_KEY", "")
PASSWORD_RSA_PRIVATE_KEY = env.str("BK_PASSWORD_RSA_PRIVATE_KEY", "")

if ENABLE_PASSWORD_RSA_ENCRYPTED:
message = "enable password rsa encrypted"
Expand All @@ -154,4 +154,4 @@
)
message = f"password rsa encrypted is enabled, but b64decode fail, {rsa_key_info}"
logger.error(message)
raise Exception
raise e
2 changes: 1 addition & 1 deletion src/login/bklogin/templates/account/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
{% endif %}
</script>

<script src="{{STATIC_URL}}assets/jsencrypt-3.2.1.min.js"></script>
<script src="{{STATIC_URL}}assets/jsencrypt-3.2.1.min.js?v={{STATIC_VERSION}}"></script>
<script type="text/javascript">
PASSWORD_RSA_PUBLIC_KEY = "{{ PASSWORD_RSA_PUBLIC_KEY }}"
ENABLE_PASSWORD_RSA_ENCRYPTED = "{{ ENABLE_PASSWORD_RSA_ENCRYPTED }}" === "true"
Expand Down
2 changes: 1 addition & 1 deletion src/login/bklogin/templates/account/login_ce.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
{% endif %}
</script>

<script src="{{STATIC_URL}}assets/jsencrypt-3.2.1.min.js"></script>
<script src="{{STATIC_URL}}assets/jsencrypt-3.2.1.min.js?v={{STATIC_VERSION}}"></script>
<script type="text/javascript">
PASSWORD_RSA_PUBLIC_KEY = "{{ PASSWORD_RSA_PUBLIC_KEY }}"
ENABLE_PASSWORD_RSA_ENCRYPTED = "{{ ENABLE_PASSWORD_RSA_ENCRYPTED }}" === "true"
Expand Down