Skip to content

Commit

Permalink
chore: identity-server app global prefix in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
hubert committed Oct 18, 2024
1 parent d7670ba commit 703809a
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion clients/vue-web/env/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
env.identityGraphqlBase = baseUrl + '/action/identity/graphql';

env.oidc = {
authority: baseUrl + '/oauth2',
authority: baseUrl + '/identity/oauth2',
client_id: clientId,
redirect_uri: baseUrl + globalPrefix + '/signin.html',
post_logout_redirect_uri: baseUrl + globalPrefix,
Expand Down
1 change: 1 addition & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
autorestart: true,
env_production: {
PORT: 3003,
GLOBAL_PREFIX_URI: '/identity',
OIDC_PATH: '/oauth2',
INFRASTRUCTURE_SERVICE_PORT: 3000,
},
Expand Down
9 changes: 5 additions & 4 deletions servers/conf/apisix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ routes:
_meta:
disable: true
bearer_only: false
client_id: CLIENT_ID
client_secret: CLIENT_SECRET
discovery: http://pomelo-server:3003/oauth2/.well-known/openid-configuration
# set client metadata
# client_id: CLIENT_ID
# client_secret: CLIENT_SECRET
discovery: http://pomelo-server:3003/identity/oauth2/.well-known/openid-configuration
unauth_action: pass
use_jwks: true
proxy-rewrite:
Expand Down Expand Up @@ -61,7 +62,7 @@ routes:
proxy-rewrite:
regex_uri:
- ^/action/identity(/?)(.*)
- /$2
- /identity/$2
upstream:
nodes:
- host: pomelo-server
Expand Down
16 changes: 15 additions & 1 deletion servers/conf/config.fly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,24 @@ graphql:
# path: "/graphql"
# server configuration
server:
origin: "https://pomelo-server.fly.dev"
origin: "https://pomelo-server.fly.dev:3003"
# redis connection, from fly secrets
# REDIS_URL: "redis://host:port/db"
# infrastructure database connection, from fly secrets
# INFRASTRUCTURE_DATABASE_CONNECTION: "mysql://user:password@host:port/database"
# identity database connection, from fly secrets
# IDENTITY_DATABASE_CONNECTION: "mysql://user:password@host:port/database"
# table prefix
TABLE_PREFIX: "po_"
# oidc redirect uri, default: ${server.origin}
WEB_URL: "https://pomelo-client.fly.dev:3011"
# openid-client authentication configuration
OIDC_CONFIG:
# openid-connect issuer
issuer: "${server.origin}/oauth2"
# use jwks to verify jwt
useJWKS: true
# http options
# https://github.com/panva/node-openid-client/blob/main/docs/README.md#customizing-http-requests
httpOptions:
timeout: 60000
11 changes: 6 additions & 5 deletions servers/conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ PUBLIC_KEY: "private_key"
# openid-client authentication configuration
OIDC_CONFIG:
# openid-connect issuer
issuer: "${server.origin}/oauth2"
issuer: "${server.origin}/identity/oauth2"
# use jwks to verify jwt
useJWKS: true
# client metadata
# https://github.com/panva/node-openid-client/blob/main/docs/README.md#new-clientmetadata-jwks-options
client_id: "client_id"
client_secret: "client_secret"
# http options
# https://github.com/panva/node-openid-client/blob/main/docs/README.md#customizing-http-requests
httpOptions:
timeout: 1000
# bff client metadata
# https://github.com/panva/node-openid-client/blob/main/docs/README.md#new-clientmetadata-jwks-options
# INFRASTRUCTURE_BFF_CLIENT_METADATA:
# client_id: "client_id"
# client_secret: "client_secret"
2 changes: 1 addition & 1 deletion servers/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ upstream pomelo_identity_server {
client_max_body_size 100M;
}

location /oauth2/ {
location /identity/ {
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
Expand Down
9 changes: 0 additions & 9 deletions servers/identity-server/.env

This file was deleted.

1 change: 1 addition & 0 deletions servers/identity-server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ const logger = new Logger('AppModule', { timestamp: true });
useFactory: async (config: ConfigService, storageOptions: StorageOptions) => ({
debug: config.get('debug', false),
issuer: 'http://fakeissuer.com',
// update issuer in each request
// `${config.getOrThrow('server.origin')}${normalizeRoutePath(
// config.get<string>('server.globalPrefixUri', ''),
// )}`,
Expand Down
5 changes: 0 additions & 5 deletions servers/infrastructure-bff/.env

This file was deleted.

16 changes: 9 additions & 7 deletions servers/infrastructure-bff/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ const logger = new Logger('AppModule', { timestamp: true });
AuthorizationModule.forRootAsync({
isGlobal: true,
useFactory: async (config: ConfigService) => {
const {
issuer,
useJWKS = true,
httpOptions = {},
...clientMetadata
} = config.get<Record<string, any>>('OIDC_CONFIG', {});
const { issuer, useJWKS = true, httpOptions = {} } = config.get<Record<string, any>>('OIDC_CONFIG', {});
const clientMetadata = config.get<{ client_id: string; [key: string]: any }>(
'INFRASTRUCTURE_BFF_CLIENT_METADATA',
{
client_id: '75a9c633-cfde-4954-b35c-9344ed9b781a',
client_secret: 'NzVhOWM2MzMtY2ZkZS00OTU0LWIzNWMtOTM0NGVkOWI3ODFhLlhDeTZLU19xVEc',
},
);
return {
issuer,
clientMetadata: clientMetadata as any,
clientMetadata,
useJWKS,
publicKey: await getPublicKey(config.get('PUBLIC_KEY')),
httpOptions: {
Expand Down
5 changes: 0 additions & 5 deletions servers/infrastructure-service/.env

This file was deleted.

0 comments on commit 703809a

Please sign in to comment.