allow for api-hostname template
This commit is contained in:
		
							parent
							
								
									4fd5aa05de
								
							
						
					
					
						commit
						ac47b7314d
					
				| @ -616,6 +616,7 @@ | |||||||
|         return OAUTH3._discoverHelper(providerUri, opts).then(function (directives) { |         return OAUTH3._discoverHelper(providerUri, opts).then(function (directives) { | ||||||
|           directives.azp = directives.azp || OAUTH3.url.normalize(providerUri); |           directives.azp = directives.azp || OAUTH3.url.normalize(providerUri); | ||||||
|           directives.issuer = directives.issuer || OAUTH3.url.normalize(providerUri); |           directives.issuer = directives.issuer || OAUTH3.url.normalize(providerUri); | ||||||
|  |           directives.api = (directives.api||':hostname').replace(/:hostname/, directives.issuer || OAUTH3.url.normalize(providerUri)); | ||||||
|           // OAUTH3.PromiseA.resolve() is taken care of because this is wrapped
 |           // OAUTH3.PromiseA.resolve() is taken care of because this is wrapped
 | ||||||
|           return OAUTH3.hooks.directives.set(providerUri, directives); |           return OAUTH3.hooks.directives.set(providerUri, directives); | ||||||
|         }); |         }); | ||||||
|  | |||||||
| @ -173,7 +173,7 @@ OAUTH3.urls.resourceOwnerPassword = function (directive, opts) { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     url: OAUTH3.url.resolve(directive.issuer, uri) |     url: OAUTH3.url.resolve(directive.api, uri) | ||||||
|   , method: args.method |   , method: args.method | ||||||
|   , data: body |   , data: body | ||||||
|   }; |   }; | ||||||
| @ -206,7 +206,7 @@ OAUTH3.urls.grants = function (directive, opts) { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   var url = OAUTH3.url.resolve(directive.issuer, directive.grants.url) |   var url = OAUTH3.url.resolve(directive.api, directive.grants.url) | ||||||
|     .replace(/(:azp|:client_id)/g, OAUTH3.uri.normalize(opts.client_id || opts.client_uri)) |     .replace(/(:azp|:client_id)/g, OAUTH3.uri.normalize(opts.client_id || opts.client_uri)) | ||||||
|     .replace(/(:sub|:account_id)/g, opts.session.token.sub) |     .replace(/(:sub|:account_id)/g, opts.session.token.sub) | ||||||
|     ; |     ; | ||||||
| @ -241,7 +241,7 @@ OAUTH3.authn.loginMeta = function (directive, opts) { | |||||||
|     method: directive.credential_meta.method || 'GET' |     method: directive.credential_meta.method || 'GET' | ||||||
|     // TODO lint urls
 |     // TODO lint urls
 | ||||||
|     // TODO client_uri
 |     // TODO client_uri
 | ||||||
|   , url: OAUTH3.url.resolve(directive.issuer, directive.credential_meta.url) |   , url: OAUTH3.url.resolve(directive.api, directive.credential_meta.url) | ||||||
|       .replace(':type', 'email') |       .replace(':type', 'email') | ||||||
|       .replace(':id', opts.email) |       .replace(':id', opts.email) | ||||||
|   }); |   }); | ||||||
| @ -250,7 +250,7 @@ OAUTH3.authn.otp = function (directive, opts) { | |||||||
|   // TODO client_uri
 |   // TODO client_uri
 | ||||||
|   var preq = { |   var preq = { | ||||||
|     method: directive.credential_otp.method || 'POST' |     method: directive.credential_otp.method || 'POST' | ||||||
|   , url: OAUTH3.url.resolve(directive.issuer, directive.credential_otp.url) |   , url: OAUTH3.url.resolve(directive.api, directive.credential_otp.url) | ||||||
|   , data: { |   , data: { | ||||||
|       // TODO replace with signed hosted file
 |       // TODO replace with signed hosted file
 | ||||||
|       client_agree_tos: 'oauth3.org/tos/draft' |       client_agree_tos: 'oauth3.org/tos/draft' | ||||||
| @ -465,7 +465,7 @@ OAUTH3.requests.accounts.update = function (directive, session, opts) { | |||||||
| OAUTH3.requests.accounts.create = function (directive, session, account) { | OAUTH3.requests.accounts.create = function (directive, session, account) { | ||||||
|   var dir = directive.create_account || { |   var dir = directive.create_account || { | ||||||
|     method: 'POST' |     method: 'POST' | ||||||
|   , url: 'https://' + directive.issuer + '/api/org.oauth3.provider/accounts' |   , url: 'https://' + directive.api + '/api/org.oauth3.provider/accounts' | ||||||
|   , bearer: 'Bearer' |   , bearer: 'Bearer' | ||||||
|   }; |   }; | ||||||
|   var data = { |   var data = { | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| { "terms": [ "oauth3.org/tos/draft" ] | { "terms": [ "oauth3.org/tos/draft" ] | ||||||
|  | , "api": "api.:hostname" | ||||||
| , "authorization_dialog": { "url": "#/authorization_dialog" } | , "authorization_dialog": { "url": "#/authorization_dialog" } | ||||||
| , "access_token": { "method": "POST", "url": "api/org.oauth3.provider/access_token" } | , "access_token": { "method": "POST", "url": "api/org.oauth3.provider/access_token" } | ||||||
| , "otp": { "method": "POST", "url": "api/org.oauth3.provider/otp" } | , "otp": { "method": "POST", "url": "api/org.oauth3.provider/otp" } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user