1 | connect-vtexid [![Build Status][travis-image]][travis-status]
|
2 | ==============
|
3 |
|
4 | VTEX ID Authentication middleware for Connect.
|
5 | Written in **coffee-script**
|
6 |
|
7 | It automatticaly caches vtexid response and handles errors
|
8 |
|
9 | ## Installation
|
10 | $ npm install --save connect-vtexid
|
11 |
|
12 | ## Usage
|
13 |
|
14 | Use it as any other Connect middleware
|
15 |
|
16 | ```js
|
17 | var connect = require('connect')
|
18 | var app = connect()
|
19 |
|
20 | var FIVE_MINUTES = 5 * 60
|
21 |
|
22 | var options = {
|
23 | ttl: FIVE_MINUTES
|
24 | }
|
25 |
|
26 | var connectVtexid = require('connect-vtexid')
|
27 | middleware = connectVtexid(options)
|
28 |
|
29 | app.use(middleware)
|
30 | ```
|
31 |
|
32 | Can as well be used as a **grunt-contrib-connect** middleware
|
33 |
|
34 | ### Options
|
35 |
|
36 | #### verbose
|
37 |
|
38 | *Default: false*
|
39 |
|
40 | Enables logging
|
41 |
|
42 | ### verbosityLevel
|
43 |
|
44 | *Default: 1*
|
45 |
|
46 | Controls the desired verbosity level.
|
47 | Available 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 |
|
57 | Value (in seconds) setting how long the cache will live
|
58 |
|
59 | #### replaceWhiteList
|
60 |
|
61 | *Default: false*
|
62 |
|
63 | Overrides default route `white-list` with an array of strings or regexes
|
64 | Does not replace if values is false (default)
|
65 |
|
66 | #### addToWhiteList
|
67 |
|
68 | *Default: []*
|
69 |
|
70 | Adds routes to current `white-list`.
|
71 | It can be a string, a regexp or an array containing either strings or regexes
|
72 |
|
73 | #### redirectUrl
|
74 |
|
75 | *Default: /admin/login?ReturnUrl=*
|
76 |
|
77 | String to vtexid redirect page
|
78 | It is automatically added to the `white-list`
|
79 |
|
80 | #### logoutUrl
|
81 |
|
82 | *Default: /admin/logout*
|
83 |
|
84 | String to logout route
|
85 |
|
86 | #### useReturnUrl
|
87 |
|
88 | *Default: true*
|
89 |
|
90 | Set 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
|
97 | all 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:
|
121 | It receives the `res` object, a `statusCode` as parameter and an optional `customErrorPagePath`
|
122 | , and returns an `errorRendering` function.
|
123 |
|
124 | The `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
|