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

Optimize login form & fix nginx issue & fix oidc issue #2325

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions common/static/dist/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
justify-content: center;
align-items: center;
height: 90vh;
margin: 0;
}

.mypanalbox {
.login-form-wrapper {
background-color: #FFF;
border-radius: 8px;
box-shadow: 3px 3px 3px;
border-radius: 4px;
box-shadow: rgba(0,0,0,0.1) 0 3px 5px;
padding: 30px 10px;
border-top: 5px solid #337ab7;
}

.login-form {
Expand Down
2 changes: 1 addition & 1 deletion common/templates/2fa.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</head>
<body onload="document.getElementById('otpCode').focus()" style="background-color:#edeff1;">
<div class="row lsb-login">
<div class="col-sm-3 mypanalbox">
<div class="col-sm-3 login-form-wrapper">
<form class="login-form fade-in-effect" id="auth" method="post" role="form">
{% csrf_token %}
{% if verify_mode == 'verify_config' %}
Expand Down
153 changes: 86 additions & 67 deletions common/templates/config.html

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions common/templates/login.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Archery</title>
<title>Login To Archery</title>
{% load static %}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 Bootstrap -->
Expand All @@ -17,9 +17,8 @@
</head>
<body style="background-color:#edeff1;">
<div class="row lsb-login">
<div class="col-sm-4 mypanalbox">
<h3 class="text-center">用户登录
</h3>
<div class="col-sm-4 login-form-wrapper">
<h3 class="text-center">Login To Archery</h3>
<form class="login-form fade-in-effect" id="login" method="post" role="form">
{% csrf_token %}
{% if dingding_enabled %}
Expand All @@ -28,7 +27,7 @@ <h3 class="text-center">用户登录
</div>
{% elif oidc_enabled %}
<div class="form-group">
<a class="btn btn-primary btn-block" role="button" href="/oidc/authenticate/">以OIDC登录</a>
<a class="btn btn-primary btn-block" role="button" href="/oidc/authenticate/">{{ oidc_btn_name }}</a>
</div>
{% endif %}
{% if dingding_enabled or oidc_enabled %}
Expand Down
1 change: 1 addition & 0 deletions sql/templates/legacy_login_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<input class="form-control ng-valid ng-dirty ng-touched" id="inputPassword" name="password"
type="password" required>
</div>
<br/>
<div class="form-group">
<button class="btn btn-primary btn-block" id="btnLogin" type="button"><i class="fa-lock"></i>登录</button>
</div>
1 change: 1 addition & 0 deletions sql/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def login(request):
"sign_up_enabled": SysConfig().get("sign_up_enabled"),
"oidc_enabled": settings.ENABLE_OIDC,
"dingding_enabled": settings.ENABLE_DINGDING,
"oidc_btn_name": SysConfig().get("oidc_btn_name", "以OIDC登录"),
},
)

Expand Down
3 changes: 3 additions & 0 deletions src/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ services:
container_name: archery
restart: always
ports:
- "443:443"
- "9123:9123"
volumes:
- "./archery/settings.py:/opt/archery/local_settings.py"
Expand All @@ -45,6 +46,8 @@ services:
- "./archery/sql/migrations:/opt/archery/sql/migrations"
- "./archery/logs:/opt/archery/logs"
- "./archery/keys:/opt/archery/keys"
- "./nginx/https.conf:/etc/nginx/conf.d/https.conf"
- "./nginx/ssl:/etc/nginx/ssl"
entrypoint: "dockerize -wait tcp://mysql:3306 -wait tcp://redis:6379 -timeout 60s /opt/archery/src/docker/startup.sh"
env_file:
- .env
31 changes: 31 additions & 0 deletions src/docker-compose/nginx/https.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
server {
listen 443 ssl;
server_name archery.your-project.com;
ssl_certificate /etc/nginx/ssl/STAR_internal-project_com.crt;
ssl_certificate_key /etc/nginx/ssl/STAR_internal-project_com.key;
ssl_session_timeout 5m;
client_max_body_size 20M;
proxy_read_timeout 600s;

location / {
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /static {
alias /opt/archery/static;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

}
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN cd /opt \
&& pip3 install -r /opt/archery/requirements.txt \
&& pip3 install "redis>=4.1.0" \
&& cp -f /opt/archery/src/docker/nginx.conf /etc/nginx/ \
&& cp -f /opt/archery/src/docker/http.conf /etc/nginx/conf.d/ \
&& cp -f /opt/archery/src/docker/supervisord.conf /etc/ \
&& mv /opt/sqladvisor /opt/archery/src/plugins/ \
&& mv /opt/soar /opt/archery/src/plugins/ \
Expand All @@ -21,7 +22,7 @@ RUN cd /opt \
&& rm -rf ~/.cache

#port
EXPOSE 9123
EXPOSE 443 9123 8888

#start service
ENTRYPOINT bash /opt/archery/src/docker/startup.sh && bash
Expand Down
27 changes: 27 additions & 0 deletions src/docker/http.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server{
listen 9123; #监听的端口
server_name archery;
client_max_body_size 20M;
proxy_read_timeout 600s;

location / {
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /static {
alias /opt/archery/static;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
28 changes: 0 additions & 28 deletions src/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,6 @@ http {
# for more information.
include /etc/nginx/conf.d/*.conf;

server{
listen 9123; #监听的端口
server_name archery;
client_max_body_size 20M;
proxy_read_timeout 600s;

location / {
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host:nginx_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /static {
alias /opt/archery/static;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

# Settings for a TLS enabled server.
#
# server {
Expand Down