-
应用所有的配置文件都放在config目录下
-
app.json
应用相关的配置,内容如下:
{ "server": { "host": "121.42.144.117", "port": 2111 }, "app_keys": [ "hello" ], "middlewares": [ "oauth", "proxy", "logger", "autoload", "render" ] }
其中各个配置项的作用如下:
middlewares: 应用所用到的中间件文件名称,这些中间件放在app/middlewares目录下
-
oauth.json
CS采用grant中间件实现oauth授权功能,相关的配置如下:
{ "server": { "protocol": "https", "host": "{{host}}:{{port}}" }, "adam": { "authorize_url": "{{sso_domain}}/oauth/authorize", "access_url": "{{sso_domain}}/oauth/access_token", "oauth": 2, "key": "{{client_id}}", "secret": "{{client_secret}}", "scope": ["all"], "state": true, "callback": "/handle_adam_callback", "transport": "session" } }
server: 本地应用服务相关的配置
adam: 西邮Linux统一授权服务平台adam相关的配置
adam.authorize_url: 授权地址
adam.access_url: 获取access_token的地址
adam.logout_url: 授权平台登出的地址
adam.key: client id
adam.secret: client secret
adam.scope: oauth scopes
参见 Grant 说明文档
-
proxy.json
西邮Linux兴趣小组统一接口代理配置,采用Purest实现.
{ "adam": { "{{api_domain}}": { "__domain": { "auth": { "auth": {"bearer": "[0]"} } }, "{endpoint}/[subpath]": { "__path": { "alias": "__default", "subpath": "/" } } } } }
详细配置参见 Purest Provider配置文档
-
make dev 开启开发环境下的服务,文件更改时会自动构建静态文件并重启服务
make server 开启生产环境下的服务
make build 构建静态文件
bash server.sh 生产环境下启动后台服务进程
在项目更目录下生成https证书
openssl genrsa -out privatekey.pem 1024
openssl req -new -key privatekey.pem -out certrequest.csr
openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem -days 365 //控制有效期限为365天,默认为30天
复制.env.sample.json到.env.json,配置相关信息
{
"host": "[host]",
"port": "[port]",
"key": "[client id]",
"secret": "[client secret]",
"sso_domain": "[sso domain]",
"api_domain": "[api domain]"
}
bash server.sh