forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxies.xml
More file actions
45 lines (39 loc) · 1.91 KB
/
proxies.xml
File metadata and controls
45 lines (39 loc) · 1.91 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
<spring:beans xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://membrane-soa.org/proxies/1/" xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
<router>
<!-- API on port 2000: fetch login cookie then proxy to backend -->
<api port="2000">
<request>
<!-- Call auth service to obtain SESSION cookie -->
<call url="http://localhost:3000/login" />
<!-- Inject received Set-Cookie header as Cookie -->
<setHeader name="Cookie" value="${header['set-cookie']}"/>
</request>
<!-- Forward request (with cookie) to protected backend -->
<target url="http://localhost:3001"/>
</api>
<!-- Simulated authentication service on port 3000 -->
<api port="3000">
<path>/login</path>
<response>
<!-- Return a static SESSION cookie -->
<setHeader name="Set-Cookie" value="SESSION=akj34" />
</response>
<return />
</api>
<!-- Protected backend on port 3001 -->
<api port="3001">
<!-- If correct SESSION cookie present, succeed -->
<if test="cookie.SESSION == 'akj34'">
<static>Success!</static>
<return/>
</if>
<!-- Otherwise, ask to log in with 401 status -->
<static>Please log in!</static>
<return statusCode="401"/>
</api>
</router>
</spring:beans>