don't redirect attack your client, duh!
This commit is contained in:
		
							parent
							
								
									23d9268627
								
							
						
					
					
						commit
						7de254d597
					
				| @ -23,6 +23,19 @@ | |||||||
|       opts = opts || {}; |       opts = opts || {}; | ||||||
|       opts.debug = true; |       opts.debug = true; | ||||||
|       providerUri = OAUTH3_CORE.normalizeUrl(providerUri); |       providerUri = OAUTH3_CORE.normalizeUrl(providerUri); | ||||||
|  |       if (window.location.hostname.match(providerUri)) { | ||||||
|  |         console.warn("It looks like you're a provider checking for your own directive," | ||||||
|  |           + " so we we're just gonna use OAUTH3.request({ method: 'GET', url: '.well-known/oauth3/directive.json' })"); | ||||||
|  |         return OAUTH3.request({ | ||||||
|  |           method: 'GET' | ||||||
|  |         , url: OAUTH3.core.normalizeUrl(providerUri) + '/.well-known/oauth3/directives.json' | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       if (!window.location.hostname.match(opts.client_id || opts.client_uri)) { | ||||||
|  |         console.warn("It looks like your client_id doesn't match your current window... this probably won't end well"); | ||||||
|  |         console.warn(opts.client_id || opts.client_uri, window.location.hostname); | ||||||
|  |       } | ||||||
|       var discObj = OAUTH3_CORE.urls.discover(providerUri, { client_id: (opts.client_id || opts.client_uri || getDefaultAppUrl()), debug: opts.debug }); |       var discObj = OAUTH3_CORE.urls.discover(providerUri, { client_id: (opts.client_id || opts.client_uri || getDefaultAppUrl()), debug: opts.debug }); | ||||||
| 
 | 
 | ||||||
|       // TODO ability to reuse iframe instead of closing
 |       // TODO ability to reuse iframe instead of closing
 | ||||||
| @ -146,7 +159,7 @@ | |||||||
|           err.code = "E_TIMEOUT"; |           err.code = "E_TIMEOUT"; | ||||||
|           reject(err); |           reject(err); | ||||||
|           cleanup(); |           cleanup(); | ||||||
|         }, opts.timeout || 15000); |         }, opts.timeout || 15 * 1000); | ||||||
| 
 | 
 | ||||||
|         // TODO hidden / non-hidden (via directive even)
 |         // TODO hidden / non-hidden (via directive even)
 | ||||||
|         var framesrc = '<iframe class="js-oauth3-iframe" src="' + url + '" '; |         var framesrc = '<iframe class="js-oauth3-iframe" src="' + url + '" '; | ||||||
| @ -260,7 +273,7 @@ | |||||||
|           // Oauth3.init({ logout: function () {} });
 |           // Oauth3.init({ logout: function () {} });
 | ||||||
|           //return Oauth3.logout();
 |           //return Oauth3.logout();
 | ||||||
| 
 | 
 | ||||||
|           var redirectUri = opts.redirectUri |           var redirectUri = opts.redirect_uri || opts.redirectUri | ||||||
|             || (window.location.protocol + '//' + (window.location.host + window.location.pathname) + 'oauth3.html') |             || (window.location.protocol + '//' + (window.location.host + window.location.pathname) + 'oauth3.html') | ||||||
|             ; |             ; | ||||||
|           var params = { |           var params = { | ||||||
| @ -272,6 +285,7 @@ | |||||||
|           , logins: true |           , logins: true | ||||||
|           , redirect_uri: redirectUri |           , redirect_uri: redirectUri | ||||||
|           , state: prequest.state |           , state: prequest.state | ||||||
|  |           , debug: opts.debug | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           if (prequest.url === params.redirect_uri) { |           if (prequest.url === params.redirect_uri) { | ||||||
|  | |||||||
| @ -213,11 +213,13 @@ | |||||||
|     if (!opts.client_id) { |     if (!opts.client_id) { | ||||||
|       throw new Error("cannot discover without options.client_id"); |       throw new Error("cannot discover without options.client_id"); | ||||||
|     } |     } | ||||||
|  |     var clientId = core.normalizeUrl(opts.client_id || opts.client_uri); | ||||||
|  |     providerUri = core.normalizeUrl(providerUri); | ||||||
| 
 | 
 | ||||||
|     var params = { |     var params = { | ||||||
|       action: 'directives' |       action: 'directives' | ||||||
|     , state: core.utils.randomState() |     , state: core.utils.randomState() | ||||||
|     , redirect_uri: opts.client_id + (opts.client_callback_path || '/.well-known/oauth3/callback.html') |     , redirect_uri: clientId + (opts.client_callback_path || '/.well-known/oauth3/callback.html') | ||||||
|     , response_type: 'rpc' |     , response_type: 'rpc' | ||||||
|     , _method: 'GET' |     , _method: 'GET' | ||||||
|     , _pathname: '.well-known/oauth3/directives.json' |     , _pathname: '.well-known/oauth3/directives.json' | ||||||
|  | |||||||
| @ -239,7 +239,10 @@ | |||||||
|     }); |     }); | ||||||
|   }; |   }; | ||||||
|   oauth3.requests.grants = function (providerUri, opts) { |   oauth3.requests.grants = function (providerUri, opts) { | ||||||
|     return oauth3.discover(providerUri, opts).then(function (directive) { |     return oauth3.discover(providerUri, { | ||||||
|  |       client_id: providerUri | ||||||
|  |     , debug: opts.debug | ||||||
|  |     }).then(function (directive) { | ||||||
|       console.log('core.urls.grants(directive, opts)', core.urls.grants(directive, opts)); |       console.log('core.urls.grants(directive, opts)', core.urls.grants(directive, opts)); | ||||||
|       return oauth3.request(core.urls.grants(directive, opts)).then(function (grantsResult) { |       return oauth3.request(core.urls.grants(directive, opts)).then(function (grantsResult) { | ||||||
|         if ('POST' === opts.method) { |         if ('POST' === opts.method) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user