forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapis.yaml
More file actions
58 lines (56 loc) · 1.3 KB
/
apis.yaml
File metadata and controls
58 lines (56 loc) · 1.3 KB
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
# yaml-language-server: $schema=https://www.membrane-api.io/v7.1.2.json
#
# API on port 2000: fetch login cookie then proxy to backend
api:
port: 2000
flow:
- request:
- log:
message: Calling login API
- call:
url: http://localhost:3000/login
- log:
message: "Got: ${header['set-cookie']}"
# Inject received Set-Cookie header as Cookie
- setHeader:
name: Cookie
value: ${header['set-cookie']}
# Forward request (with cookie) to protected backend
target:
url: http://localhost:3001
---
# Simulated authentication service on port 3000
api:
port: 3000
path:
uri: /login
flow:
- response:
# Return a static SESSION cookie
- setHeader:
name: Set-Cookie
value: SESSION=akj34
- log:
message: Logged in. Cookie is set.
- return:
status: 200
---
# Protected backend on port 3001
api:
port: 3001
flow:
- request:
- log:
message: "Got: ${header['set-cookie']}"
- if:
test: cookie.SESSION != 'akj34'
flow:
- static:
src: Unauthorized!
- return:
status: 401
- response:
- static:
src: Success!
- return:
status: 200