-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.wick
247 lines (247 loc) · 6.64 KB
/
component.wick
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---
name: oauth_engine
kind: wick/component@v1
metadata:
version: 0.1.0
description: Oauth Middleware component.
import:
- name: http
component:
kind: wick/component/types@v1
ref: registry.candle.dev/types/http:0.4.0
types:
- name: UserInfo
kind: wick/type/struct@v1
fields:
- name: sub
type: string
- name: email
type: string
- name: groups
type: string[]
- name: OAuthTokenResponse
kind: wick/type/struct@v1
fields:
- name: access_token
type: string
- name: expires_in
type: u32?
- name: token_type
type: string
- name: id_token
type: string?
- name: SessionDetails
kind: wick/type/struct@v1
fields:
- name: expires_at
type: datetime
- name: access_token
type: string
- name: IdToken
kind: wick/type/struct@v1
fields:
- name: id_token
type: string
requires:
- name: dbclient
interface:
operations:
- name: insert_token
inputs:
- name: session_id
type: string
- name: token_type
type: string
- name: access_token
type: string
- name: id_token
type: string
- name: refresh_token
type: string
- name: expires_at
type: datetime
outputs:
- name: output
type: object
- name: insert_claims
inputs:
- name: session_id
type: string
- name: claims
type: string
outputs:
- name: output
type: object
- name: get_session
inputs:
- name: session_id
type: string
outputs:
- name: output
type: SessionDetails
- name: get_id_token
inputs:
- name: session_id
type: string
outputs:
- name: output
type: IdToken
- name: get_oidc_claims
inputs:
- name: session_id
type: string
outputs:
- name: output
type: object
- name: update_session
inputs:
- name: expires_at
type: datetime
- name: access_token
type: string
- name: refresh_token
type: string
- name: session_id
type: string
outputs:
- name: output
type: object
- name: delete_session
inputs:
- name: session_id
type: string
outputs:
- name: output
type: object
- name: get_login_hint_claim
inputs:
- name: session_id
type: string
outputs:
- name: output
type: object
- name: httpclient
interface:
operations:
- name: get_token
inputs:
- name: access_code
type: string
- name: redirect_uri
type: string
outputs:
- name: response
type: http::HttpResponse
- name: body
type: OAuthTokenResponse
- name: refresh_token
inputs:
- name: refresh_token
type: string
outputs:
- name: response
type: http::HttpResponse
- name: body
type: OAuthTokenResponse
component:
kind: wick/component/wasmrs@v1
ref: build/component.signed.wasm
with:
- name: auth_endpoint
type: string
- name: logout_endpoint
type: string
- name: redirect_uri
type: string
- name: session_cookie_name
type: string
- name: session_cookie_duration_minutes
type: u32
- name: client_id
type: string
- name: scope
type: string
- name: email_claim
type: string
- name: logout_redirect_uri
type: string
- name: redirect_logout
type: string
- name: groups_claim
type: string?
operations:
- name: auth
inputs:
- name: request
type: http::HttpRequest
outputs:
- name: output
type: http::RequestMiddlewareResponse
- name: oidc
inputs:
- name: request
type: http::HttpRequest
outputs:
- name: output
type: http::RequestMiddlewareResponse
- name: get_user
inputs:
- name: request
type: http::HttpRequest
outputs:
- name: response
type: http::HttpResponse
- name: body
type: UserInfo
# tests:
# - name: auth
# with:
# auth_endpoint: https://login.microsoftonline.com/organizations/oauth2/authorize
# redirect_uri: http://localhost:8080/oidc/callback
# session_cookie_name: sid
# client_id: '1234567'
# client_secret: 'abc123'
# scope: 'openid profile email'
# email_claim: 'email'
# groups_claim: 'groups'
# cases:
# - name: no cookie
# operation: auth
# inherent:
# seed: 1234567
# timestamp: 1689015106
# inputs:
# - name: request
# value:
# method: Get
# scheme: Http
# path: '/'
# uri: 'http://localhost:8080/'
# version: Http11
# authority: 'localhost:8080'
# remote_addr: '127.0.0.1'
# query_parameters: {}
# headers:
# host:
# - 'localhost:8080'
# user-agent:
# - 'curl/7.64.1'
# accept:
# - '*/*'
# outputs:
# - name: output
# value:
# version: '1.1'
# status: '307'
# headers:
# location:
# - 'https://login.microsoftonline.com/organizations/oauth2/authorize?response_type=code&client_id=1234567&redirect_uri=http://localhost:8080/oidc/callback&scope=openid%20profile%20email&state=17b66ba8-38f7-9361-5068-fb22b0c72353'
# 'set-cookie':
# [
# 'auth_state=17b66ba8-38f7-9361-5068-fb22b0c72353; HttpOnly; Path=/; Expires=Mon, 10 Jul 2023 18:54:58 GMT',
# 'return_url=http://localhost:8080/; HttpOnly; Path=/; Expires=Mon, 10 Jul 2023 18:54:58 GMT',
# 'sid=expired; HttpOnly; Path=/; Expires=Mon, 10 Jul 2023 18:49:57 GMT',
# ]
# - name: output
# flags:
# done: true