Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/cleanup gateway #76

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert ":recycle: gateway use same properties as for integrations"
This reverts commit f8cd280.
simonhir committed Aug 16, 2024
commit fe03660dc201476b4f14906d06975abdbaebaaaf
30 changes: 13 additions & 17 deletions refarch-gateway/README.md
Original file line number Diff line number Diff line change
@@ -41,20 +41,16 @@ Beside the default behaviour there are some special route prefixes which are han

## Configuration

Following are the properties to configure the gateway. Some of them are custom defined and others are synonyms
for spring package properties.
Whether a property is an alias can be checked in the [`application.yml`](./src/main/resources/application.yml).

| Var | Description | Example |
|------------------------------------------------------------|----------------------------------------------------|-------------------------------------------------------------------------|
| `refarch.security.sso-issuer-url` | Url of the oAuth2 server used for authentication. | `https://sso.muenchen.de/auth/realms/muenchen.de` |
| `refarch.security.sso-client-id` | OAuth2 client id used for authentication. | |
| `refarch.security.sso-client-secret` | OAuth2 client secret used for authentication. | |
| `spring.cloud.gateway.routes.*.id` | Id of a route definition. | `backend` |
| `spring.cloud.gateway.routes.*.uri` | The uri to route to if this route matches. | `http://backend-service:8080/` |
| `spring.cloud.gateway.routes.*.predicates.*` | Route predicates i.e. matcher. | `Path=/api/backend-service/**` |
| `spring.cloud.gateway.routes.*.filters.*` | List of filters applied to the route. | `RewritePath=/api/backend-service/(?<urlsegments>.*), /$\{urlsegments}` |
| `refarch.security.cors.allowed-origins-public` (optional) | List of urls allowed as origin for public routes. | `https://*.muenchen.de,http://localhost:*` |
| `refarch.security.cors.allowed-origins-clients` (optional) | List of urls allowed as origin for clients routes. | `https://*.muenchen.de,http://localhost:*` |
| `refarch.security.csrf-whitelisted.*` (optional) | List of routes to disable csrf protection for. | `/example/**` |
| `info.appswitcher.url` (optional) | App switcher url for usage in refarch frontend. | `https://appswitcher.muenchen.de` |
| Var | Description | Example |
|----------------------------------------------------------|----------------------------------------------------|-------------------------------------------------------------------------|
| `SSO_ISSUER_URL` | Url of the oAuth2 server used for authentication. | `https://sso.muenchen.de/auth/realms/muenchen.de` |
| `SSO_CLIENT_ID` | OAuth2 client id used for authentication. | |
| `SSO_CLIENT_SECRET` | OAuth2 client secret used for authentication. | |
| `SPRING_CLOUD_GATEWAY_ROUTES_<index>_ID` | Id of a route definition. | `backend` |
| `SPRING_CLOUD_GATEWAY_ROUTES_<index>_URI` | The uri to route to if this route matches. | `http://backend-service:8080/` |
| `SPRING_CLOUD_GATEWAY_ROUTES_<index>_PREDICATES_<index>` | Route predicates i.e. matcher. | `Path=/api/backend-service/**` |
| `SPRING_CLOUD_GATEWAY_ROUTES_<index>_FILTERS_<index>` | List of filters applied to the route. | `RewritePath=/api/backend-service/(?<urlsegments>.*), /$\{urlsegments}` |
| `ALLOWED_ORIGINS_PUBLIC` (optional) | List of urls allowed as origin for public routes. | `https://*.muenchen.de,http://localhost:*` |
| `ALLOWED_ORIGINS_CLIENTS` (optional) | List of urls allowed as origin for clients routes. | `https://*.muenchen.de,http://localhost:*` |
| `REFARCH_SECURITY_CSRFWHITELISTED_<index>` (optional) | List of routes to disable csrf protection for. | `/example/**` |
| `INFO_APPSWITCHER_URL` (optional) | App switcher url for usage in refarch frontend. | `https://appswitcher.muenchen.de` |
21 changes: 6 additions & 15 deletions refarch-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -12,25 +12,25 @@ spring:
oauth2:
resourceserver:
jwt:
issuer-uri: ${refarch.security.sso-issuer-url}
issuer-uri: ${SSO_ISSUER_URL}
client:
provider:
keycloak:
issuer-uri: ${refarch.security.sso-issuer-url}
issuer-uri: ${SSO_ISSUER_URL}
registration:
keycloak:
client-id: ${refarch.security.sso-client-id}
client-secret: ${refarch.security.sso-client-secret}
client-id: ${SSO_CLIENT_ID}
client-secret: ${SSO_CLIENT_SECRET}
scope: email, profile, openid # needed for userInfo endpoint
provider: keycloak
cloud:
gateway:
globalcors:
cors-configurations:
'[/public/**]':
allowedOriginPatterns: ${refarch.security.cors.allowed-origins-public}
allowedOriginPatterns: ${ALLOWED_ORIGINS_PUBLIC}
'[/clients/**]':
allowedOriginPatterns: ${refarch.security.cors.allowed-origins-clients}
allowedOriginPatterns: ${ALLOWED_ORIGINS_CLIENTS}
allowedHeaders: "*"
allowCredentials: true
default-filters:
@@ -75,14 +75,5 @@ info:
name: ${spring.application.name}
version: '@project.version@'

refarch:
security:
sso-issuer-url:
sso-client:
sso-secret:
cors:
allowed-origins-public:
csrf-whitelisted:

config:
map5xxto400: true