# ether-pms Ether Project Management System ## 快速开始 ### 前置要求 - Java 17+ - Maven 3.8+ - PostgreSQL 14+ - Node.js 18+ (用于前端开发) ### 安装与配置 #### 1. 克隆项目 ```bash git clone cd ether-pms ``` #### 2. 配置环境变量(重要!) **必须配置 JWT Secret,否则应用无法启动:** ```bash # 复制环境变量模板 cp .env.example .env # 编辑 .env 文件,设置 JWT Secret # 生成安全的 JWT 密钥: openssl rand -base64 64 # 将生成的密钥填入 .env 文件的 JWT_SECRET= 后面 ``` #### 3. 配置数据库 编辑 `pms-starter/src/main/resources/application.yml` 或通过环境变量配置数据库连接: ```bash # 在 .env 文件中添加 SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/ether_pms SPRING_DATASOURCE_USERNAME=your_db_user SPRING_DATASOURCE_PASSWORD=your_password ``` #### 4. 启动后端服务 ```bash # 编译项目 mvn clean install -DskipTests # 启动应用(确保已设置环境变量) export $(cat .env | xargs) mvn spring-boot:run -pl pms-starter ``` 应用将在 http://localhost:8080 启动。 --- ## 安全配置指南 (重要) ### JWT Secret 配置 JWT Secret 是系统安全的核心配置,**必须在生产环境中正确配置**: #### 为什么这很重要? - JWT Secret 用于签名和验证用户 Token - 如果 Secret 被泄露或使用弱密钥,攻击者可以伪造任意用户身份(包括管理员) - **这是 P0 级别的安全问题** #### 如何生成安全的 Secret? ```bash # 推荐方式:使用 OpenSSL 生成 64 字节 Base64 编码的随机密钥 openssl rand -base64 64 # 输出示例: # x7K9mP2vQ4wR8tY1uI5oA0sD3fG6hJ9kL2nB4cV7bX0zQ1wE5rT8yU3iO6pA1sD== ``` #### 配置验证规则 应用启动时会自动进行以下安全检查: | 检查项 | 要求 | 行为 | |--------|------|------| | Secret 是否为空 | 不能为空 | **阻止启动**,显示详细错误信息 | | 是否使用默认值 | 不能使用已知弱密钥 | **阻止启动**,列出检测到的值 | | Secret 长度 | 建议 >= 32 字符 | 显示警告(不阻止启动) | #### 常见错误及解决方案 **错误 1: JWT Secret 未配置** ``` ============================================ 致命错误: JWT Secret 未配置! ============================================ ``` **解决方法**: ```bash # 生成密钥 openssl rand -base64 64 > /tmp/jwt_secret.txt # 设置环境变量 export JWT_SECRET=$(cat /tmp/jwt_secret.txt) # 删除临时文件(安全起见) rm /tmp/jwt_secret.txt ``` **错误 2: 使用了不安全的默认值** ``` 安全警告: 检测到不安全的 JWT Secret! 当前值: my-secret-key-2024 ``` **解决方法**: 重新生成新的随机密钥并更新配置(参考上述步骤)。 #### 生产环境最佳实践 1. **使用密码管理器**: 推荐 HashiCorp Vault、AWS Secrets Manager 等 2. **定期轮换**: 建议每 90 天更换一次 JWT Secret 3. **权限控制**: 确保 `.env` 文件权限为 `600` ```bash chmod 600 .env ``` 4. **不要提交到 Git**: 确保 `.gitignore` 包含 `.env` 5. **监控日志**: 关注应用启动时的安全警告信息 --- ## 项目结构 ## Add your files * [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files * [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command: ``` cd existing_repo git remote add origin http://8.153.107.96/ether/ether-pms.git git branch -M main git push -uf origin main ``` ## Integrate with your tools * [Set up project integrations](http://8.153.107.96/ether/ether-pms/-/settings/integrations) ## Collaborate with your team * [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/) * [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/) * [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically) * [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/) * [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/) ## Test and Deploy Use the built-in continuous integration in GitLab. * [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/) * [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/) * [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/) * [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/) * [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/) *** # Editing this README When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. ## Suggestions for a good README Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. ## Name Choose a self-explaining name for your project. ## Description Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. ## Badges On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. ## Visuals Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. ## Installation Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. ## Usage Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. ## Support Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. ## Roadmap If you have ideas for releases in the future, it is a good idea to list them in the README. ## Contributing State if you are open to contributions and what your requirements are for accepting them. For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. ## Authors and acknowledgment Show your appreciation to those who have contributed to the project. ## License For open source projects, say how it is licensed. ## Project status If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.