Skip to content

Commit 76a8357

Browse files
authored
Merge pull request #114 from BUAA-SE-coders007/fix/109
[fix]: 修改密钥并进行隐藏
2 parents 64b1e75 + 18eeb27 commit 76a8357

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

.env

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/check.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ jobs:
5050
pip install -r requirements.txt
5151
5252
- name: Check FastAPI Server
53+
env:
54+
ALGORITHM: ${{ secrets.ALGORITHM }}
55+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
56+
FERNET_SECRET_KEY: ${{ secrets.FERNET_SECRET_KEY }}
57+
KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }}
58+
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
59+
REMOTE_PATH: ${{ secrets.REMOTE_PATH }}
60+
REMOTE_USER: ${{ secrets.REMOTE_USER }}
61+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
62+
SENDER_PASSWORD: ${{ secrets.SENDER_PASSWORD }}
63+
SERVER_SSH_KEY: ${{ secrets.SERVER_SSH_KEY }}
64+
SQLALCHEMY_DATABASE_URL: ${{ secrets.SQLALCHEMY_DATABASE_URL }}
5365
run: |
5466
uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-level warning &
55-
sleep 5
56-
curl -f http://localhost:8000/docs
67+
sleep 5

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
env
22
__pycache__
33
articles
4-
app.log
4+
app.log
5+
.env

alembic.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ version_path_separator = os
6363
# are written from script.py.mako
6464
# output_encoding = utf-8
6565

66-
sqlalchemy.url = mysql+pymysql://root:[email protected]:3306/JieNote
6766

6867

6968
[post_write_hooks]

alembic/env.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
# this is the Alembic Config object, which provides
1010
# access to the values within the .ini file in use.
1111
config = context.config
12+
import os
13+
from dotenv import load_dotenv
1214

15+
# 加载.env文件
16+
load_dotenv()
1317
# Interpret the config file for Python logging.
1418
# This line sets up loggers basically.
1519
if config.config_file_name is not None:
1620
fileConfig(config.config_file_name)
17-
21+
sqlalchemy_url = os.environ.get("DATABASE_URL")
22+
config.set_main_option("sqlalchemy.url", sqlalchemy_url)
1823
# add your model's MetaData object here
1924
# for 'autogenerate' support
2025
# from myapp import mymodel

app/core/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
class Settings:
77
PROJECT_NAME: str = "JieNote Backend" # 项目名称
88
VERSION: str = "1.0.0" # 项目版本
9-
SQLALCHEMY_DATABASE_URL = "mysql+asyncmy://root:[email protected]:3306/JieNote" # 替换为实际的用户名、密码和数据库名称
9+
SQLALCHEMY_DATABASE_URL = os.getenv("SQLALCHEMY_DATABASE_URL", "default") # 替换为实际的用户名、密码和数据库名称
1010
SECRET_KEY: str = os.getenv("SECRET_KEY", "default_secret_key") # JWT密钥
11-
ALGORITHM: str = "HS256" # JWT算法
12-
ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440 # token过期时间
11+
ALGORITHM: str = os.getenv("ALGORITHM", "default") # JWT算法
12+
ACCESS_TOKEN_EXPIRE_MINUTES: int = 5 # token过期时间
1313
REFRESH_TOKEN_EXPIRE_DAYS: int = 7 # 刷新token过期时间7天
1414
SMTP_SERVER: str = "smtp.163.com" # SMTP服务器
1515
SMTP_PORT: int = 465 # SMTP端口

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from fastapi.staticfiles import StaticFiles
77
import os
88

9-
app = FastAPI()
9+
app = FastAPI(docs_url=None, redoc_url=None)
1010

1111
@app.get("/")
1212
def read_root():

0 commit comments

Comments
 (0)