first commit

This commit is contained in:
编码猿
2024-09-27 01:14:21 +08:00
commit 5ddcc17391
52 changed files with 1176 additions and 0 deletions

1
gateway/config/.pydio Normal file
View File

@@ -0,0 +1 @@
e7a720b3-b16e-4dc4-b31c-a9c87709ea20

View File

@@ -0,0 +1 @@
da3d4927-dcc5-4dd3-b8e2-42b1cf9b5eaa

View File

@@ -0,0 +1,80 @@
# https://www.express-gateway.io/docs/configuration/gateway.config.yml/
# https://www.cnblogs.com/PLM-Teamcenter/p/16388583.html
http:
port: 8080
admin:
port: 9876
host: localhost
# 指定具体的客户端 - 绑定域名和 被映射的接口地址
apiEndpoints:
api:
host: localhost
paths: '/ip'
user_client:
host: localhost
paths:
- /user
- /user/*
articles_client:
host: localhost
paths:
- /articles
- /articles/*
# 声明网关可以管理的微服务 - 被代理的地址
serviceEndpoints:
userbin:
url: 'http://127.0.0.1:3002'
articlesbin:
url: 'http://127.0.0.1:3003'
httpbin:
url: 'https://httpbin.org'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
# 通过管道把客户端与微服务串联起来
pipelines:
default:
apiEndpoints:
- api
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
# proxy它的作用是代理/转发请求,这里指定了将 apiEndpoints 来的请求转发到前面定义了的微服务
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
pipeline_user:
apiEndpoints:
- user_client
policies:
- proxy:
- action:
serviceEndpoint: userbin
changeOrigin: true
pipeline_articles:
apiEndpoints:
- articles_client
policies:
- proxy:
- action:
serviceEndpoint: articlesbin
changeOrigin: true

View File

@@ -0,0 +1,26 @@
# Core
db:
redis:
emulate: true
namespace: EG
#plugins:
# express-gateway-plugin-example:
# param1: 'param from system.config'
crypto:
cipherKey: sensitiveKey
algorithm: aes256
saltRounds: 10
# OAuth2 Settings
session:
secret: keyboard cat
resave: false
saveUninitialized: false
accessTokens:
timeToExpiry: 7200000
refreshTokens:
timeToExpiry: 7200000
authorizationCodes:
timeToExpiry: 300000

View File

@@ -0,0 +1,103 @@
{
"http": {
"port": 8080
},
"admin": {
"port": 9876,
"host": "localhost"
},
"apiEndpoints": {
"api": {
"host": "localhost",
"paths": "/ip"
},
"user_client": {
"host": "localhost",
"paths": [
"/user",
"/user/*"
]
},
"articles_client": {
"host": "localhost",
"paths": [
"/articles",
"/articles/*"
]
}
},
"serviceEndpoints": {
"userbin": {
"url": "http://127.0.0.1:3002"
},
"articlesbin": {
"url": "http://127.0.0.1:3003"
},
"httpbin": {
"url": "https://httpbin.org"
}
},
"policies": [
"basic-auth",
"cors",
"expression",
"key-auth",
"log",
"oauth2",
"proxy",
"rate-limit"
],
"pipelines": {
"default": {
"apiEndpoints": [
"api"
],
"policies": [
{
"proxy": [
{
"action": {
"serviceEndpoint": "httpbin",
"changeOrigin": true
}
}
]
}
]
},
"pipeline_user": {
"apiEndpoints": [
"user_client"
],
"policies": [
{
"proxy": [
{
"action": {
"serviceEndpoint": "userbin",
"changeOrigin": true
}
}
]
}
]
},
"pipeline_articles": {
"apiEndpoints": [
"articles_client"
],
"policies": [
{
"proxy": [
{
"action": {
"serviceEndpoint": "articlesbin",
"changeOrigin": true
}
}
]
}
]
}
}
}

View File

@@ -0,0 +1 @@
dbd3cf03-e067-4aed-9f60-fbd5cc998830

View File

@@ -0,0 +1,16 @@
{
"$id": "http://express-gateway.io/models/applications.json",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"redirectUri": {
"type": "string",
"format": "uri"
}
},
"required": [
"name"
]
}

View File

@@ -0,0 +1,85 @@
{
"$id": "http://express-gateway.io/models/credentials.json",
"type": "object",
"definitions": {
"credentialBase": {
"type": "object",
"properties": {
"autoGeneratePassword": {
"type": "boolean",
"default": true
},
"scopes": {
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
}
},
"required": [
"autoGeneratePassword"
]
}
},
"properties": {
"basic-auth": {
"allOf": [
{
"$ref": "#/definitions/credentialBase"
},
{
"type": "object",
"properties": {
"passwordKey": {
"type": "string",
"default": "password"
}
},
"required": [
"passwordKey"
]
}
]
},
"key-auth": {
"type": "object",
"properties": {
"scopes": {
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
}
}
},
"jwt": {
"type": "object",
"properties": {}
},
"oauth2": {
"allOf": [
{
"$ref": "#/definitions/credentialBase"
},
{
"type": "object",
"properties": {
"passwordKey": {
"type": "string",
"default": "secret"
}
},
"required": [
"passwordKey"
]
}
]
}
}
}

View File

@@ -0,0 +1,28 @@
{
"$id": "http://express-gateway.io/models/users.json",
"type": "object",
"properties": {
"firstname": {
"type": "string"
},
"lastname": {
"type": "string"
},
"username": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"redirectUri": {
"type": "string",
"format": "uri"
}
},
"required": [
"username",
"firstname",
"lastname"
]
}

View File

@@ -0,0 +1,27 @@
{
"db": {
"redis": {
"emulate": true,
"namespace": "EG"
}
},
"crypto": {
"cipherKey": "sensitiveKey",
"algorithm": "aes256",
"saltRounds": 10
},
"session": {
"secret": "keyboard cat",
"resave": false,
"saveUninitialized": false
},
"accessTokens": {
"timeToExpiry": 7200000
},
"refreshTokens": {
"timeToExpiry": 7200000
},
"authorizationCodes": {
"timeToExpiry": 300000
}
}