-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.d.ts
241 lines (196 loc) · 5.73 KB
/
index.d.ts
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
import { IncomingMessage, ServerResponse, OutgoingMessage } from "http";
declare namespace CAS {
type version = 1 | 2 | 3;
}
declare namespace httpCasClient {
interface Handler {
/**
* @returns inProgress?
*/
(req: IncomingMessage, res: ServerResponse, hooks: Handler.hooks): Promise<Boolean>;
}
namespace Handler {
interface hooks {
/**
* Define a function to get ticket id from any store.
*/
getTicket?: () => String;
/**
* Do something when a new ticket created.
*/
ticketCreated?: (ticketId: String) => void;
/**
* Do something when a specific ticket has been destroyed.
*/
ticketDestroyed?: (ticketId: String) => void;
/**
* A function return resolved request body object.
*/
bodyParser?: () => Object | Promise<Object>;
}
}
interface Options {
/**
* CAS protocol version 1, 2, 3.
*/
cas?: CAS.version;
/**
* The start of the CAS server URL, i.e. https://localhost:8443/cas
*/
casServerUrlPrefix: String,
/**
* The name of the server this application is hosted on.
* Service URL will be dynamically constructed using this,
* i.e. https://localhost:8443 (you must include the protocol,
* but port is optional if it's a standard port).
*/
serverName: String;
/**
* The options of this application server (CAS Client).
*/
client?: Options.client;
/**
* The options of CAS Server.
*/
server?: Options.server;
}
namespace Options {
interface client {
/**
* The name of the server this application is hosted on.
* Service URL will be dynamically constructed using this,
* i.e. https://localhost:8443 (you must include the protocol,
* but port is optional if it's a standard port).
*/
service?: String;
/**
* Use SLO or not.
*/
slo?: Boolean;
/**
* If this parameter is set, ticket validation will only succeed if the service ticket was
* issued from the presentation of the user’s primary credentials.
*/
renew?: Boolean;
/**
* If this parameter is set, CAS will not ask the client for credentials.
*/
gateway?: Boolean;
/**
* Whether to store the Assertion in session or not. If sessions are not used, tickets
* will be required for each request. Defaults to false.
*/
useSession?: Boolean
/**
* The method to be used when sending responses. While native HTTP redirects (GET) may
* be utilized as the default method, applications that require a POST response can use
* this parameter to indicate the method type. A HEADER method may also be specified to
* indicate the CAS final response such as service and ticketshould be returned in form
* of HTTP response headers. It is up to the CAS server implementation to determine whether
* or not POST or HEADER responses are supported.
*/
method?: String;
/**
* URLs of requests matched rules will not be affected.
*
* - If you use strings and regexp lists, you only need to satisfy one item to pass.
* - Or provide a function to define custom rules.
*/
ignore?: RegExp[] | ((httpRequest: IncomingMessage) => Boolean | Promise<Boolean>);
/**
* A callback function to decide skip cas authentication or not.
*/
skip?: ((httpRequest: IncomingMessage, httpResponse: OutgoingMessage, options: Options) => Boolean | Promise<Boolean>);
/**
* About CAS proxy.
*/
proxy?: proxy;
}
interface server {
/**
* Defines the location of the CAS server login URL, i.e.
* https://localhost:8443/cas/login. This overrides casServerUrlPrefix, if set.
*/
loginUrl?: String;
/**
* CAS URIs.
* https://apereo.github.io/cas/6.0.x/protocol/CAS-Protocol-Specification.html#2-cas-uris
*/
path?: path;
}
interface path {
/**
* credential requestor / acceptor
*/
login?: String;
/**
* destroy CAS session (logout)
*/
logout?: String;
/**
* service ticket validation [CAS 1.0]
*/
validate?: String;
/**
* service ticket validation [CAS 2.0]
*/
serviceValidate?: String;
/**
* service/proxy ticket validation [CAS 2.0]
*/
proxyValidate?: String;
/**
* proxy ticket service [CAS 2.0]
*/
proxy?: String;
/**
* CAS 3.0 uri
*/
p3?: {
/**
* service ticket validation [CAS 3.0]
*/
serviceValidate?: String;
/**
* service/proxy ticket validation [CAS 3.0]
*/
proxyValidate?: String;
}
}
interface proxy {
/**
* Specifies whether any proxy is OK. Defaults to false.
*/
acceptAny?: Boolean;
/**
* Specifies the proxy chain. Each acceptable proxy chain should include
* a space-separated list of URLs (for exact match) or regular expressions
* of URLs (starting by the ^ character). Each acceptable proxy chain
* should appear on its own line.
*
* - Or provide a function to define custom rules.
*/
allowedChains?: ((proxiex: string[]) => Boolean | Promise<Boolean>);
/**
* The callback URL to provide the CAS server to accept Proxy Granting Tickets.
*/
callbackUrl?: String;
/**
* The URL to watch for PGTIOU/PGT responses from the CAS server. Should be
* defined from the root of the context. For example, if your application is
* deployed in /cas-client-app and you want the proxy receptor URL to be
* /cas-client-app/my/receptor you need to configure proxyReceptorUrl to be
* /my/receptor.
*/
receptorUrl?: String;
}
}
}
declare class CasServerAgent {
constructor(options: httpCasClient.Options);
}
/**
* Create a native CasClientHandler for native http.createServer.
*/
declare function httpCasClient(...options: httpCasClient.Options[]): httpCasClient.Handler;
export = httpCasClient;