summaryrefslogtreecommitdiff
path: root/microservices/02-api-gateway/linux/deb/package/etc/ceit-fs-api-gateway/application.yaml
blob: d037d5be0ea72661c9a2612a43c81169fe310af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
server:
  port: 8050
  address: 127.0.0.1

app:
  userRolesUrl: "http://localhost:8052/myservices/security/open/users/{username}/roles"

# logging:
#   level:
#     org.springframework.security: trace

spring:
  application:
    name: api-gateway

  cloud:
    gateway:
      server:
        webflux:
          globalcors:
            cors-configurations:
              '[/**]':
                allowedOrigins:
                  - "https://fs-react-app.dev.ceit.pdn.ac.lk"
                allowedMethods: "*"
                allowedHeaders: "*"
                allowCredentials: true
          routes:
            # Frontend tries to access this URL when the login link is clicked.
            # If user is not logged in, user will be redirected to OAuth2 server.
            # If logged in, frontend will be reloaded.
            - id: frontend
              uri: no://op # CRITICAL: Prevents forwarding to a backend server
              predicates:
                - Path=/ui
              filters:
                - RedirectTo=302, https://fs-react-app.dev.ceit.pdn.ac.lk/
            # Forward requests to backend service (OAuth2 resource server)
            - id: backend-service
              uri: http://localhost:8052
              predicates:
                - Path=/api/**
              filters:
                # 1. ALWAYS strip incoming spoof headers from the public web first
                - RemoveRequestHeader=X-User-Id
                - RemoveRequestHeader=X-User-Name
                - RemoveRequestHeader=X-User-Roles
                - RemoveRequestHeader=Authorization
                - PrefixPath=/myservices
                - TokenRelay # Add oauth (or jwt) token to request header before forwarding

  security:
    oauth2:
      client:
        provider:
          platform-auth-server:
            issuer-uri: https://fs-auth-server.dev.ceit.pdn.ac.lk
        registration:
          api-gateway:
            provider: platform-auth-server
            client-id: api-gateway
            client-secret: "apiGatewayPassword1234"
            client-authentication-method: client_secret_basic
            authorization-grant-type: authorization_code
            redirect-uri: https://fs-react-app.dev.ceit.pdn.ac.lk/bff/login/oauth2/code/api-gateway
            scope:
              - openid
              - profile
com:
  c4-soft:
    springaddons:
      oidc:
        ops:
          - iss: https://fs-auth-server.dev.ceit.pdn.ac.lk
        client:
          client-uri: https://fs-react-app.dev.ceit.pdn.ac.lk
          login-uri: /bff/oauth2/authorization/api-gateway
          security-matchers:
            - /**
          permit-all:
            - /login/**
            - /oauth2/**
            - /
            - /api/**
          csrf: cookie-accessible-from-js
          oauth2-redirections:
            rp-initiated-logout: ACCEPTED
          post-logout-redirect-host: https://fs-react-app.dev.ceit.pdn.ac.lk
          post-logout-redirect-path: /