最新文檔:https://elsfs.gitee.io/
elsfs 框架:https://gitee.com/elsfs/elsfs-cloud
環(huán)境準(zhǔn)備
①后端開發(fā)環(huán)境
-
必要環(huán)境
- Java17+
- Maven 3.8+
- MySQL 8.0+
- Redis 5.0+
- nacos 2.2.x
-
常用工具
- idea 2022+
- navicat
- switchHosts
- Git
②配置本地hosts
注意:必須配置 hosts ,禁止修改代碼中配置成IP | 梯子、VPN 等軟件會(huì)導(dǎo)致 hosts 配置失效,請(qǐng)關(guān)閉!!
127.0.0.1 nacos
127.0.0.1 mysql
127.0.0.1 redis
127.0.0.1 kibana
③項(xiàng)目下載
平臺(tái) | 地址 |
---|---|
gitee | git clone https://gitee.com/elsfs/elsfs-cloud.git |
github | git clone https://github.com/elsfs/elsfs-cloud.git 待開放 |
④初始化數(shù)據(jù)庫(kù)
版本: mysql8.0+ 默認(rèn)字符集: utf8mb4 默認(rèn)排序規(guī)則: utf8mb4_general_ci
-- 核心數(shù)據(jù)庫(kù)
source db/elsfs-mysql.sql;
-- nacos配置
source db/naocs-mysql.sql;
⑤配置文件修改
特別說明: host配置不要改成IP , why?
- 好處是在分布式系統(tǒng)中,會(huì)存在大量的IP 配置,不同模塊鏈接數(shù)據(jù)庫(kù) 、redis、mq 等,使用hosts 可以統(tǒng)一管理,做環(huán)境切換
- 非常適合容器化部署,在現(xiàn)有的docker-compose 、k8s 等中 service的概念和 hosts 設(shè)計(jì)非常吻合,不知道其他service 的ip 但你可以通過的 ping service_name 即可通信。 通過hosts 我們就可以實(shí)現(xiàn)一鍵啟動(dòng) 不需要關(guān)注你的mysql redis 的ip 配置是什么
# elsfs/elsfs-optionl/elsfs-optionl-nacos/src/main/resources/application.yml
db:
num: 1
user: ${MYSQL-USER:root} #修改:用戶名
password: ${MYSQL-PWD:root} #修改:密碼, 特殊字符使用 '包裹'
url:
0: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:nacos}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
⑥啟動(dòng)nacos
找到對(duì)應(yīng)模塊的類,直接右鍵Main 啟動(dòng)即可
elsfs-optional/elsfs-optional-nacos/src/main/java/com/alibaba/nacos/NacosApplication.java
⑦redis、mysql 配置
:::tip
訪問: http://nacos:8848/nacos (默認(rèn)賬號(hào)密碼 nacos/nacos)
:::
修改對(duì)應(yīng)的命名空間elsfs-cloud下的配置文件redis,mysql配置
application-dev.yml文章來源:http://www.zghlxwxcb.cn/news/detail-842040.html
elsfs:
security:
# 配置公鑰和私鑰
key-pairs:
- id: key
created: 2023-11-19T10:00:00.000Z
public-key: publicKey.pem
private-key: privateKey.pem
issuer: http://localhost:7001
spring:
web:
locale-resolver: accept_header
locale: zh_CN
data:
redis:
database: 0
host: redis
port: 6379
elsfs-cloud-starter-dev.yml文章來源地址http://www.zghlxwxcb.cn/news/detail-842040.html
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: ${MYSQL_USER:root}
password: ${MYSQL_PASSWORD:root}
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:elsfs-admin}?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
security:
oauth2:
client:
registration:
github:
provider: github
# App ID: 670371
client-id: xxx
client-secret: xxx
scope: user:email, read:user
gitee:
# 指定oauth登錄提供者,該oauth登錄由provider中的gitee來處理
provider: gitee
# 客戶端名字
client-name: Sign in with Gitee
# 客戶端id,使用自己的gitee的客戶端id
client-id: xxx
# 客戶端秘鑰,使用自己的gitee的客戶端秘鑰
client-secret: xxx
# 認(rèn)證方式
authorization-grant-type: authorization_code
# 回調(diào)地址
redirect-uri: http://127.0.0.1:7001/login/oauth2/code/gitee
# 申請(qǐng)scope列表
scope:
- user_info
- emails
qq:
provider: qq
# appid:應(yīng)用的唯一標(biāo)識(shí)。在OAuth2.0認(rèn)證過程中,appid的值即為oauth_consumer_key的值。
# appid(oauth_consumer_key/client_id)
client-id: your-app-app-id
# appkey:appid對(duì)應(yīng)的密鑰,訪問用戶資源時(shí)用來驗(yàn)證應(yīng)用的合法性。在OAuth2.0認(rèn)證過程中,appkey的值即為oauth_consumer_secret的值。
# appkey(auth_consumer_secret/client_secret);
client-secret: your-app-secret
authorization-grant-type: authorization_code
# 回調(diào)地址
redirect-uri: http://127.0.0.1:7001/login/oauth2/code/qq
scope:
- user_info
- emails
client-name: Sign in with QQ
google:
client-id: your-app-client-id
client-secret: your-app-client-secret
facebook:
client-id: your-app-client-id
client-secret: your-app-client-secret
okta:
client-id: your-app-client-id
client-secret: your-app-client-secret
login-client:
provider: spring
client-id: messaging-client
client-secret: "$2a$10$hVq5XfeMHERLoFo6RBUFieyrZF8ElwvRRgrig/wb/IkXUzz3zCZhG"
client-authentication-method: client_secret_basic
authorization-grant-type: authorization_code
redirect-uri: http://admin.elsfs.test:7001/login/oauth2/code/login-client
scope:
# - openid
- message.read
- message.write
client-name: spring
provider:
github:
user-name-attribute: login
qq:
user-name-attribute: openid
# https://wiki.connect.qq.com/%e4%bd%bf%e7%94%a8authorization_code%e8%8e%b7%e5%8f%96access_token
# 發(fā)起授權(quán)申請(qǐng)的地址
authorization-uri: https://graph.qq.com/oauth2.0/authorize
# 獲取token的地址
token-uri: https://graph.qq.com/oauth2.0/token?fmt=json&need_openid=1
# 獲取用戶信息的地址 使用Access Token來獲取用戶的OpenID
user-info-uri: https://graph.qq.com/oauth2.0/me?fmt=json
gitee:
# 設(shè)置用戶信息響應(yīng)體中賬號(hào)的字段
user-name-attribute: id
# 獲取token的地址
token-uri: https://gitee.com/oauth/token
# 獲取用戶信息的地址
user-info-uri: https://gitee.com/api/v5/user
# 發(fā)起授權(quán)申請(qǐng)的地址
authorization-uri: https://gitee.com/oauth/authorize
spring:
user-name-attribute: sub
token-uri: http://localhost:7002/oauth2/token
user-info-uri: http://localhost:7002/userinfo
authorization-uri: http://localhost:7002/oauth2/authorize
jwk-set-uri: http://localhost:7002/oauth2/jwks
okta:
authorization-uri: https://your-subdomain.oktapreview.com/oauth2/v1/authorize
token-uri: https://your-subdomain.oktapreview.com/oauth2/v1/token
user-info-uri: https://your-subdomain.oktapreview.com/oauth2/v1/userinfo
jwk-set-uri: https://your-subdomain.oktapreview.com/oauth2/v1/keys
⑧啟動(dòng)順序
elsfs-optional/elsfs-optional-nacos/src/main/java/com/alibaba/nacos/NacosApplication.java
starter/elsfs-cloud-oauth2-starter/src/main/java/org/elsfs/cloud/Oauth2ApplicationStarter.java
starter/elsfs-cloud-starter/src/main/java/org/elsfs/cloud/AdminApplicationStarter.java
到了這里,關(guān)于Enterprise level safety function system 企業(yè)級(jí)安全功能系統(tǒng)快速開始 elsfs的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!