UNPKG

2.61 kBMarkdownView Raw
1connect-vtexid [![Build Status][travis-image]][travis-status]
2==============
3
4VTEX ID Authentication middleware for Connect.
5Written in **coffee-script**
6
7It automatticaly caches vtexid response and handles errors
8
9## Installation
10 $ npm install --save connect-vtexid
11
12## Usage
13
14Use it as any other Connect middleware
15
16```js
17var connect = require('connect')
18var app = connect()
19
20var FIVE_MINUTES = 5 * 60
21
22var options = {
23 ttl: FIVE_MINUTES
24}
25
26var connectVtexid = require('connect-vtexid')
27middleware = connectVtexid(options)
28
29app.use(middleware)
30```
31
32Can as well be used as a **grunt-contrib-connect** middleware
33
34### Options
35
36#### verbose
37
38*Default: false*
39
40Enables logging
41
42### verbosityLevel
43
44*Default: 1*
45
46Controls the desired verbosity level.
47Available options:
48- 0: quiet mode
49- 1: low verbosity
50- 2: medium verbosity
51- 3: high verbosity
52
53#### ttl
54
55*Default: 5 minutes*
56
57Value (in seconds) setting how long the cache will live
58
59#### replaceWhiteList
60
61*Default: false*
62
63Overrides default route `white-list` with an array of strings or regexes
64Does not replace if values is false (default)
65
66#### addToWhiteList
67
68*Default: []*
69
70Adds routes to current `white-list`.
71It can be a string, a regexp or an array containing either strings or regexes
72
73#### redirectUrl
74
75*Default: /admin/login?ReturnUrl=*
76
77String to vtexid redirect page
78It is automatically added to the `white-list`
79
80#### logoutUrl
81
82*Default: /admin/logout*
83
84String to logout route
85
86#### useReturnUrl
87
88*Default: true*
89
90Set to false if you do not want to pass the request url as parameter to the redirectUrl
91
92### Custom libs
93
94#### URI White list
95
96`white-list` sets a white list containing every public URI. It receives a `publicUris` parameter that is an array containing
97all public uris. Each public uri must be either a String or a RegExp
98
99*Default:*
100
101- */admin/Content*
102- */admin/Scripts*
103- */meta/whoami*
104- */^\/admin\/Site\/Login.aspx/*
105
106#### Redirect url
107
108`return-url` sets the vtexid redirect url.
109
110#### Cookie parser
111
112`cookie-parser` is a custom lib-independent cookie-parsing function.
113
114#### Redirect
115
116`redirect` is a custom lib-independent client-side redirect function.
117
118#### Http errors
119
120`http-errors` is a custom function for rendering error pages:
121It receives the `res` object, a `statusCode` as parameter and an optional `customErrorPagePath`
122, and returns an `errorRendering` function.
123
124The `errorRendering` function receives an error message `body` and the vtexid `cookie` as parameters
125
126
127[travis-image]: https://travis-ci.org/vtex/connect-vtexid.svg?branch=v0.1.2
128[travis-status]: https://travis-ci.org/vtex/connect-vtexid