ember-auth-source 3.0.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/dist/ember-auth.js +323 -19
- metadata +3 -3
data/dist/ember-auth.js
CHANGED
@@ -91,6 +91,278 @@
|
|
91
91
|
};
|
92
92
|
|
93
93
|
}));
|
94
|
+
/*
|
95
|
+
* JQuery URL Parser plugin, v2.2.1
|
96
|
+
* Developed and maintanined by Mark Perkins, mark@allmarkedup.com
|
97
|
+
* Source repository: https://github.com/allmarkedup/jQuery-URL-Parser
|
98
|
+
* Licensed under an MIT-style license. See https://github.com/allmarkedup/jQuery-URL-Parser/blob/master/LICENSE for details.
|
99
|
+
*/
|
100
|
+
|
101
|
+
|
102
|
+
;(function(factory) {
|
103
|
+
if (typeof define === 'function' && define.amd) {
|
104
|
+
// AMD available; use anonymous module
|
105
|
+
if ( typeof jQuery !== 'undefined' ) {
|
106
|
+
define(['jquery'], factory);
|
107
|
+
} else {
|
108
|
+
define([], factory);
|
109
|
+
}
|
110
|
+
} else {
|
111
|
+
// No AMD available; mutate global vars
|
112
|
+
if ( typeof jQuery !== 'undefined' ) {
|
113
|
+
factory(jQuery);
|
114
|
+
} else {
|
115
|
+
factory();
|
116
|
+
}
|
117
|
+
}
|
118
|
+
})(function($, undefined) {
|
119
|
+
|
120
|
+
var tag2attr = {
|
121
|
+
a : 'href',
|
122
|
+
img : 'src',
|
123
|
+
form : 'action',
|
124
|
+
base : 'href',
|
125
|
+
script : 'src',
|
126
|
+
iframe : 'src',
|
127
|
+
link : 'href'
|
128
|
+
},
|
129
|
+
|
130
|
+
key = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment'], // keys available to query
|
131
|
+
|
132
|
+
aliases = { 'anchor' : 'fragment' }, // aliases for backwards compatability
|
133
|
+
|
134
|
+
parser = {
|
135
|
+
strict : /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, //less intuitive, more accurate to the specs
|
136
|
+
loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // more intuitive, fails on relative paths and deviates from specs
|
137
|
+
},
|
138
|
+
|
139
|
+
toString = Object.prototype.toString,
|
140
|
+
|
141
|
+
isint = /^[0-9]+$/;
|
142
|
+
|
143
|
+
function parseUri( url, strictMode ) {
|
144
|
+
var str = decodeURI( url ),
|
145
|
+
res = parser[ strictMode || false ? 'strict' : 'loose' ].exec( str ),
|
146
|
+
uri = { attr : {}, param : {}, seg : {} },
|
147
|
+
i = 14;
|
148
|
+
|
149
|
+
while ( i-- ) {
|
150
|
+
uri.attr[ key[i] ] = res[i] || '';
|
151
|
+
}
|
152
|
+
|
153
|
+
// build query and fragment parameters
|
154
|
+
uri.param['query'] = parseString(uri.attr['query']);
|
155
|
+
uri.param['fragment'] = parseString(uri.attr['fragment']);
|
156
|
+
|
157
|
+
// split path and fragement into segments
|
158
|
+
uri.seg['path'] = uri.attr.path.replace(/^\/+|\/+$/g,'').split('/');
|
159
|
+
uri.seg['fragment'] = uri.attr.fragment.replace(/^\/+|\/+$/g,'').split('/');
|
160
|
+
|
161
|
+
// compile a 'base' domain attribute
|
162
|
+
uri.attr['base'] = uri.attr.host ? (uri.attr.protocol ? uri.attr.protocol+'://'+uri.attr.host : uri.attr.host) + (uri.attr.port ? ':'+uri.attr.port : '') : '';
|
163
|
+
|
164
|
+
return uri;
|
165
|
+
};
|
166
|
+
|
167
|
+
function getAttrName( elm ) {
|
168
|
+
var tn = elm.tagName;
|
169
|
+
if ( typeof tn !== 'undefined' ) return tag2attr[tn.toLowerCase()];
|
170
|
+
return tn;
|
171
|
+
}
|
172
|
+
|
173
|
+
function promote(parent, key) {
|
174
|
+
if (parent[key].length == 0) return parent[key] = {};
|
175
|
+
var t = {};
|
176
|
+
for (var i in parent[key]) t[i] = parent[key][i];
|
177
|
+
parent[key] = t;
|
178
|
+
return t;
|
179
|
+
}
|
180
|
+
|
181
|
+
function parse(parts, parent, key, val) {
|
182
|
+
var part = parts.shift();
|
183
|
+
if (!part) {
|
184
|
+
if (isArray(parent[key])) {
|
185
|
+
parent[key].push(val);
|
186
|
+
} else if ('object' == typeof parent[key]) {
|
187
|
+
parent[key] = val;
|
188
|
+
} else if ('undefined' == typeof parent[key]) {
|
189
|
+
parent[key] = val;
|
190
|
+
} else {
|
191
|
+
parent[key] = [parent[key], val];
|
192
|
+
}
|
193
|
+
} else {
|
194
|
+
var obj = parent[key] = parent[key] || [];
|
195
|
+
if (']' == part) {
|
196
|
+
if (isArray(obj)) {
|
197
|
+
if ('' != val) obj.push(val);
|
198
|
+
} else if ('object' == typeof obj) {
|
199
|
+
obj[keys(obj).length] = val;
|
200
|
+
} else {
|
201
|
+
obj = parent[key] = [parent[key], val];
|
202
|
+
}
|
203
|
+
} else if (~part.indexOf(']')) {
|
204
|
+
part = part.substr(0, part.length - 1);
|
205
|
+
if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
|
206
|
+
parse(parts, obj, part, val);
|
207
|
+
// key
|
208
|
+
} else {
|
209
|
+
if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
|
210
|
+
parse(parts, obj, part, val);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
function merge(parent, key, val) {
|
216
|
+
if (~key.indexOf(']')) {
|
217
|
+
var parts = key.split('['),
|
218
|
+
len = parts.length,
|
219
|
+
last = len - 1;
|
220
|
+
parse(parts, parent, 'base', val);
|
221
|
+
} else {
|
222
|
+
if (!isint.test(key) && isArray(parent.base)) {
|
223
|
+
var t = {};
|
224
|
+
for (var k in parent.base) t[k] = parent.base[k];
|
225
|
+
parent.base = t;
|
226
|
+
}
|
227
|
+
set(parent.base, key, val);
|
228
|
+
}
|
229
|
+
return parent;
|
230
|
+
}
|
231
|
+
|
232
|
+
function parseString(str) {
|
233
|
+
return reduce(String(str).split(/&|;/), function(ret, pair) {
|
234
|
+
try {
|
235
|
+
pair = decodeURIComponent(pair.replace(/\+/g, ' '));
|
236
|
+
} catch(e) {
|
237
|
+
// ignore
|
238
|
+
}
|
239
|
+
var eql = pair.indexOf('='),
|
240
|
+
brace = lastBraceInKey(pair),
|
241
|
+
key = pair.substr(0, brace || eql),
|
242
|
+
val = pair.substr(brace || eql, pair.length),
|
243
|
+
val = val.substr(val.indexOf('=') + 1, val.length);
|
244
|
+
|
245
|
+
if ('' == key) key = pair, val = '';
|
246
|
+
|
247
|
+
return merge(ret, key, val);
|
248
|
+
}, { base: {} }).base;
|
249
|
+
}
|
250
|
+
|
251
|
+
function set(obj, key, val) {
|
252
|
+
var v = obj[key];
|
253
|
+
if (undefined === v) {
|
254
|
+
obj[key] = val;
|
255
|
+
} else if (isArray(v)) {
|
256
|
+
v.push(val);
|
257
|
+
} else {
|
258
|
+
obj[key] = [v, val];
|
259
|
+
}
|
260
|
+
}
|
261
|
+
|
262
|
+
function lastBraceInKey(str) {
|
263
|
+
var len = str.length,
|
264
|
+
brace, c;
|
265
|
+
for (var i = 0; i < len; ++i) {
|
266
|
+
c = str[i];
|
267
|
+
if (']' == c) brace = false;
|
268
|
+
if ('[' == c) brace = true;
|
269
|
+
if ('=' == c && !brace) return i;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
function reduce(obj, accumulator){
|
274
|
+
var i = 0,
|
275
|
+
l = obj.length >> 0,
|
276
|
+
curr = arguments[2];
|
277
|
+
while (i < l) {
|
278
|
+
if (i in obj) curr = accumulator.call(undefined, curr, obj[i], i, obj);
|
279
|
+
++i;
|
280
|
+
}
|
281
|
+
return curr;
|
282
|
+
}
|
283
|
+
|
284
|
+
function isArray(vArg) {
|
285
|
+
return Object.prototype.toString.call(vArg) === "[object Array]";
|
286
|
+
}
|
287
|
+
|
288
|
+
function keys(obj) {
|
289
|
+
var keys = [];
|
290
|
+
for ( prop in obj ) {
|
291
|
+
if ( obj.hasOwnProperty(prop) ) keys.push(prop);
|
292
|
+
}
|
293
|
+
return keys;
|
294
|
+
}
|
295
|
+
|
296
|
+
function purl( url, strictMode ) {
|
297
|
+
if ( arguments.length === 1 && url === true ) {
|
298
|
+
strictMode = true;
|
299
|
+
url = undefined;
|
300
|
+
}
|
301
|
+
strictMode = strictMode || false;
|
302
|
+
url = url || window.location.toString();
|
303
|
+
|
304
|
+
return {
|
305
|
+
|
306
|
+
data : parseUri(url, strictMode),
|
307
|
+
|
308
|
+
// get various attributes from the URI
|
309
|
+
attr : function( attr ) {
|
310
|
+
attr = aliases[attr] || attr;
|
311
|
+
return typeof attr !== 'undefined' ? this.data.attr[attr] : this.data.attr;
|
312
|
+
},
|
313
|
+
|
314
|
+
// return query string parameters
|
315
|
+
param : function( param ) {
|
316
|
+
return typeof param !== 'undefined' ? this.data.param.query[param] : this.data.param.query;
|
317
|
+
},
|
318
|
+
|
319
|
+
// return fragment parameters
|
320
|
+
fparam : function( param ) {
|
321
|
+
return typeof param !== 'undefined' ? this.data.param.fragment[param] : this.data.param.fragment;
|
322
|
+
},
|
323
|
+
|
324
|
+
// return path segments
|
325
|
+
segment : function( seg ) {
|
326
|
+
if ( typeof seg === 'undefined' ) {
|
327
|
+
return this.data.seg.path;
|
328
|
+
} else {
|
329
|
+
seg = seg < 0 ? this.data.seg.path.length + seg : seg - 1; // negative segments count from the end
|
330
|
+
return this.data.seg.path[seg];
|
331
|
+
}
|
332
|
+
},
|
333
|
+
|
334
|
+
// return fragment segments
|
335
|
+
fsegment : function( seg ) {
|
336
|
+
if ( typeof seg === 'undefined' ) {
|
337
|
+
return this.data.seg.fragment;
|
338
|
+
} else {
|
339
|
+
seg = seg < 0 ? this.data.seg.fragment.length + seg : seg - 1; // negative segments count from the end
|
340
|
+
return this.data.seg.fragment[seg];
|
341
|
+
}
|
342
|
+
}
|
343
|
+
|
344
|
+
};
|
345
|
+
|
346
|
+
};
|
347
|
+
|
348
|
+
if ( typeof $ !== 'undefined' ) {
|
349
|
+
|
350
|
+
$.fn.url = function( strictMode ) {
|
351
|
+
var url = '';
|
352
|
+
if ( this.length ) {
|
353
|
+
url = $(this).attr( getAttrName(this[0]) ) || '';
|
354
|
+
}
|
355
|
+
return purl( url, strictMode );
|
356
|
+
};
|
357
|
+
|
358
|
+
$.url = purl;
|
359
|
+
|
360
|
+
} else {
|
361
|
+
window.purl = purl;
|
362
|
+
}
|
363
|
+
|
364
|
+
});
|
365
|
+
|
94
366
|
(function() {
|
95
367
|
var evented;
|
96
368
|
|
@@ -269,20 +541,38 @@
|
|
269
541
|
rememberTokenKey: null,
|
270
542
|
rememberPeriod: 14,
|
271
543
|
rememberAutoRecall: true,
|
272
|
-
rememberStorage: 'cookie'
|
544
|
+
rememberStorage: 'cookie',
|
545
|
+
urlAuthentication: false
|
273
546
|
});
|
274
547
|
|
275
548
|
}).call(this);
|
276
549
|
(function() {
|
277
550
|
Auth.Route = Em.Route.extend(Em.Evented, {
|
278
551
|
redirect: function() {
|
279
|
-
if (
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
552
|
+
if (Auth.get('authToken')) {
|
553
|
+
return;
|
554
|
+
}
|
555
|
+
if (Auth.Config.get('urlAuthentication')) {
|
556
|
+
Auth.Module.UrlAuthentication.authenticate({
|
557
|
+
async: false
|
558
|
+
});
|
559
|
+
if (Auth.get('authToken')) {
|
560
|
+
return;
|
561
|
+
}
|
562
|
+
}
|
563
|
+
if (Auth.Config.get('rememberMe') && Auth.Config.get('rememberAutoRecall')) {
|
564
|
+
Auth.Module.RememberMe.recall({
|
565
|
+
async: false
|
566
|
+
});
|
567
|
+
if (Auth.get('authToken')) {
|
568
|
+
return;
|
284
569
|
}
|
285
570
|
}
|
571
|
+
this.trigger('authAccess');
|
572
|
+
if (Auth.Config.get('authRedirect')) {
|
573
|
+
Auth.set('prevRoute', this.routeName);
|
574
|
+
return this.transitionTo(Auth.Config.get('signInRoute'));
|
575
|
+
}
|
286
576
|
}
|
287
577
|
});
|
288
578
|
|
@@ -336,6 +626,7 @@
|
|
336
626
|
var _this = this;
|
337
627
|
|
338
628
|
Auth.on('signInSuccess', function() {
|
629
|
+
_this.forget();
|
339
630
|
return _this.remember();
|
340
631
|
});
|
341
632
|
Auth.on('signInError', function() {
|
@@ -408,22 +699,35 @@
|
|
408
699
|
}
|
409
700
|
});
|
410
701
|
|
411
|
-
|
412
|
-
|
413
|
-
|
702
|
+
}).call(this);
|
703
|
+
(function() {
|
704
|
+
Auth.Module.UrlAuthentication = Em.Object.create({
|
705
|
+
authenticate: function(opts) {
|
706
|
+
var data, token;
|
414
707
|
|
415
|
-
if (
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
708
|
+
if (opts == null) {
|
709
|
+
opts = {};
|
710
|
+
}
|
711
|
+
if (!Auth.Config.get('urlAuthentication')) {
|
712
|
+
return;
|
713
|
+
}
|
714
|
+
if (!Auth.get('authToken') && (token = this.retrieveToken())) {
|
715
|
+
data = {};
|
716
|
+
if (opts.async != null) {
|
717
|
+
data['async'] = opts.async;
|
424
718
|
}
|
719
|
+
data[Auth.Config.get('tokenKey')] = token;
|
720
|
+
return Auth.signIn(data);
|
721
|
+
}
|
722
|
+
},
|
723
|
+
retrieveToken: function() {
|
724
|
+
var token;
|
725
|
+
|
726
|
+
token = $.url().param(Auth.Config.get('tokenKey'));
|
727
|
+
if (token && token.charAt(token.length - 1) === '/') {
|
728
|
+
token = token.slice(0, -1);
|
425
729
|
}
|
426
|
-
return
|
730
|
+
return token;
|
427
731
|
}
|
428
732
|
});
|
429
733
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember-auth-source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ember-rails
|
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
51
|
version: '0'
|
52
52
|
segments:
|
53
53
|
- 0
|
54
|
-
hash: -
|
54
|
+
hash: -896551263
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|