List App Grants
This commit is contained in:
		
							parent
							
								
									0ff3a2e3ce
								
							
						
					
					
						commit
						4ab4ad0ac0
					
				
							
								
								
									
										23
									
								
								index.html
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								index.html
									
									
									
									
									
								
							| @ -426,7 +426,7 @@ | |||||||
|                 <textarea class="form-control" ng-model="vm.accessToken" ng-change="vm.api.jwt.decode()"></textarea> |                 <textarea class="form-control" ng-model="vm.accessToken" ng-change="vm.api.jwt.decode()"></textarea> | ||||||
|                 <textarea ng-if="vm.refreshToken" class="form-control" ng-model="vm.refreshToken" ng-change="vm.api.jwt.decodeRefresh()"></textarea> |                 <textarea ng-if="vm.refreshToken" class="form-control" ng-model="vm.refreshToken" ng-change="vm.api.jwt.decodeRefresh()"></textarea> | ||||||
| 
 | 
 | ||||||
|                 <pre ng-if="vm.ropSession"><code ng-bind="vm.ropSession | json"></code></pre> |                 <pre ng-if="vm.ropToken"><code ng-bind="vm.ropToken | json"></code></pre> | ||||||
|               </div> |               </div> | ||||||
|             </div> |             </div> | ||||||
| 
 | 
 | ||||||
| @ -467,22 +467,25 @@ | |||||||
|               <br> |               <br> | ||||||
|               <br> |               <br> | ||||||
|               <div class="col-md-3"> |               <div class="col-md-3"> | ||||||
|                 <strong>Approved Devices</strong> |                 <strong>Approved Apps</strong> | ||||||
|                 <br> |                 <br> | ||||||
|                 (these are the public keys generated on remember-me devices and the opaque tokens issued to remember-me-not devices) |                 (these are the public keys generated on remember-me devices and the opaque tokens issued to remember-me-not devices) | ||||||
|               </div> |               </div> | ||||||
|               <div class="col-md-9"> |               <div class="col-md-9"> | ||||||
|                 <button class="btn btn-default" ng-click="vm.api.authn.verify()" ng-disabled="!vm.form.accessToken">List Devices</button> |                 <button class="btn btn-default" ng-click="vm.api.authz.grants()" ng-disabled="!vm.form.accessToken">List App Grants</button> | ||||||
|                 <br> |                 <br> | ||||||
| 
 | 
 | ||||||
|                 <div ng-if="vm.urls.publicKeys"> |                 <pre><code>OAUTH3.urls.grants(directives, opts);</code></pre> | ||||||
|                   <pre><code><span ng-bind="vm.urls.publicKeys.method"></span> <span ng-bind="vm.urls.publicKeys.url"></span> |                 <pre><code>OAUTH3.authz.grants(directives, <span ng-bind="vm.api.authz._grantsOpts_"></span>);</code></pre> | ||||||
| <span ng-if="vm.urls.publicKeys.headers" ng-bind="vm.urls.publicKeys.headers | json"></span> | 
 | ||||||
| <span ng-bind="vm.urls.publicKeys.data | json"></span> |                 <div ng-if="vm.urls.grants"> | ||||||
|  |                   <pre><code><span ng-bind="vm.urls.grants.method"></span> <span ng-bind="vm.urls.grants.url"></span> | ||||||
|  | <span ng-if="vm.urls.grants.headers" ng-bind="vm.urls.grants.headers | json"></span> | ||||||
|  | <span ng-bind="vm.urls.grants.data | json"></span> | ||||||
| </code></pre> | </code></pre> | ||||||
|                   <pre ng-if="vm.responses.publicKeys"><code><span ng-bind="vm.responses.publicKeys.status"></span> |                   <pre ng-if="vm.responses.grants"><code><span ng-bind="vm.responses.grants.status"></span> | ||||||
| <span ng-if="vm.responses.publicKeys.headers" ng-bind="vm.responses.publicKeys.headers | json"></span> | <span ng-if="vm.responses.grants.headers" ng-bind="vm.responses.grants.headers | json"></span> | ||||||
| <span ng-bind="vm.responses.publicKeys.data | json"></span> | <span ng-bind="vm.responses.grants.data | json"></span> | ||||||
| </code></pre> | </code></pre> | ||||||
|                 </div> |                 </div> | ||||||
|                 ... |                 ... | ||||||
|  | |||||||
| @ -56,6 +56,12 @@ | |||||||
|     // Convenience for our app
 |     // Convenience for our app
 | ||||||
|     //
 |     //
 | ||||||
|     vm.fn = {}; |     vm.fn = {}; | ||||||
|  |     vm.fn.updateUrls = function () { | ||||||
|  |       Object.keys(vm.api.urls).forEach(function (key) { | ||||||
|  |         var fn = vm.api.urls[key]; | ||||||
|  |         fn(); | ||||||
|  |       }); | ||||||
|  |     }; | ||||||
|     vm.fn._debounce = {}; |     vm.fn._debounce = {}; | ||||||
|     vm.fn.debounceUi = function () { |     vm.fn.debounceUi = function () { | ||||||
|       if (vm.debouncing.user || vm.debouncing.provider) { |       if (vm.debouncing.user || vm.debouncing.provider) { | ||||||
| @ -162,7 +168,7 @@ | |||||||
|         return key; |         return key; | ||||||
|       }).join(','); |       }).join(','); | ||||||
| 
 | 
 | ||||||
|       vm.api.urls.implicitGrant(); |       vm.fn.updateUrls(); // vm.api.urls.implicitGrant();
 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     vm.fn.lock = function () { |     vm.fn.lock = function () { | ||||||
| @ -189,13 +195,15 @@ | |||||||
|     vm.api.authn = {}; |     vm.api.authn = {}; | ||||||
|     vm.api.jwt = {}; |     vm.api.jwt = {}; | ||||||
|     vm.api.urls.credentialMeta = function () { |     vm.api.urls.credentialMeta = function () { | ||||||
|  |       if (!vm.directives ||!vm.directives.credential_meta || !vm.form.id) { return; } | ||||||
|       vm.urls.credentialMeta = OAUTH3.urls.credentialMeta(vm.directives, { email: vm.form.id }); |       vm.urls.credentialMeta = OAUTH3.urls.credentialMeta(vm.directives, { email: vm.form.id }); | ||||||
|     }; |     }; | ||||||
|     vm.api.urls.otp = function () { |     vm.api.urls.otp = function () { | ||||||
|  |       if (!vm.directives || !vm.form.id) { return; } | ||||||
|       vm.urls.otp = OAUTH3.urls.otp(vm.directives, { email: vm.form.id }); |       vm.urls.otp = OAUTH3.urls.otp(vm.directives, { email: vm.form.id }); | ||||||
|     }; |     }; | ||||||
|     vm.api.authn.otp = function () { |     vm.api.authn.otp = function () { | ||||||
|       vm.api.urls.otp(); |       vm.fn.updateUrls(); // vm.api.urls.otp();
 | ||||||
|       OAUTH3.authn.otp(vm.directives, { email: vm.form.id }).then(function (resp) { |       OAUTH3.authn.otp(vm.directives, { email: vm.form.id }).then(function (resp) { | ||||||
|         vm.responses.otp = resp; |         vm.responses.otp = resp; | ||||||
|         vm.form.otpUuid = resp.data.code_id; |         vm.form.otpUuid = resp.data.code_id; | ||||||
| @ -205,12 +213,14 @@ | |||||||
|         console.log('vm.form.otpUuid:'); |         console.log('vm.form.otpUuid:'); | ||||||
|         console.log(vm.form.otpUuid); |         console.log(vm.form.otpUuid); | ||||||
| 
 | 
 | ||||||
|         vm.api.urls.resourceOwnerPassword(); |         vm.fn.updateUrls(); // vm.api.urls.resourceOwnerPassword();
 | ||||||
|       }); |       }); | ||||||
|     }; |     }; | ||||||
|     vm.api.authn.credentialMeta = function () { |     vm.api.authn.credentialMeta = function () { | ||||||
|       vm.api.urls.credentialMeta(); |       vm.fn.updateUrls(); // vm.api.urls.credentialMeta();
 | ||||||
|       OAUTH3.authn.loginMeta(vm.directives, { email: vm.form.id }); |       OAUTH3.authn.loginMeta(vm.directives, { email: vm.form.id }).then(function () { | ||||||
|  |         vm.fn.updateUrls(); // vm.api.urls.credentialMeta();
 | ||||||
|  |       }); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -237,24 +247,28 @@ | |||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|     vm.api.urls.resourceOwnerPassword = function () { |     vm.api.urls.resourceOwnerPassword = function () { | ||||||
|  |       if (!vm.directives || !vm.form.otpUuid) { return; } | ||||||
|       vm.urls.resourceOwnerPassword = OAUTH3.urls.resourceOwnerPassword(vm.directives, vm.api.authn._ropOpts()); |       vm.urls.resourceOwnerPassword = OAUTH3.urls.resourceOwnerPassword(vm.directives, vm.api.authn._ropOpts()); | ||||||
|     }; |     }; | ||||||
|     vm.api.authn.resourceOwnerPassword = function () { |     vm.api.authn.resourceOwnerPassword = function () { | ||||||
|       vm.api.urls.resourceOwnerPassword(); |       vm.fn.updateUrls(); // vm.api.urls.resourceOwnerPassword();
 | ||||||
|       OAUTH3.authn.resourceOwnerPassword(vm.directives, vm.api.authn._ropOpts()).then(function (resp) { |       OAUTH3.authn.resourceOwnerPassword(vm.directives, vm.api.authn._ropOpts()).then(function (resp) { | ||||||
|         vm.responses.resourceOwnerPassword = { status: 0, data: resp }; |         vm.responses.resourceOwnerPassword = { status: 0, data: resp }; | ||||||
|         vm.form.accessToken = vm.accessToken = resp.access_token; |         vm.form.accessToken = vm.accessToken = resp.access_token; | ||||||
|         vm.form.refreshToken = vm.refreshToken = resp.refresh_token; |         vm.form.refreshToken = vm.refreshToken = resp.refresh_token; | ||||||
|         vm.ropSession = resp.token; |         vm.ropSession = resp; | ||||||
|  |         vm.ropToken = resp.token; | ||||||
|  | 
 | ||||||
|  |         vm.fn.updateUrls(); // vm.api.urls.resourceOwnerPassword(); also grants
 | ||||||
|       }); |       }); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     vm.api.jwt.decode = function () { |     vm.api.jwt.decode = function () { | ||||||
|       vm.ropSession = OAUTH3.jwt.decode(vm.form.accessToken || vm.accessToken); |       vm.ropToken = OAUTH3.jwt.decode(vm.form.accessToken || vm.accessToken); | ||||||
|     }; |     }; | ||||||
|     vm.api.jwt.decodeRefresh = function () { |     vm.api.jwt.decodeRefresh = function () { | ||||||
|       vm.ropSession = OAUTH3.jwt.decode(vm.form.refreshToken || vm.refreshToken); |       vm.ropToken = OAUTH3.jwt.decode(vm.form.refreshToken || vm.refreshToken); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     vm.api.providerUri = function () { |     vm.api.providerUri = function () { | ||||||
| @ -406,6 +420,32 @@ | |||||||
|         vm.session = session; |         vm.session = session; | ||||||
|       }); |       }); | ||||||
|     }; |     }; | ||||||
|  |     vm.api.authz = {}; | ||||||
|  |     vm.api.authz._grantsOpts = function () { | ||||||
|  |       return vm.api.authz._grantsOpts_ = { | ||||||
|  |         method: 'GET' | ||||||
|  |       , client_id: vm.conf.client_id | ||||||
|  |       , client_uri: vm.conf.client_uri | ||||||
|  |       , session: vm.ropSession | ||||||
|  |       , debug: vm.conf.debug | ||||||
|  |       , all: true | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |     vm.api.urls.grants = function () { | ||||||
|  |       if (!vm.directives || !vm.ropSession || !vm.form.id) { return; } | ||||||
|  |       vm.urls.grants = OAUTH3.urls.grants(vm.directives, vm.api.authz._grantsOpts()); | ||||||
|  |     }; | ||||||
|  |     vm.api.authz.grants = function () { | ||||||
|  |       vm.fn.updateUrls(); // vm.api.urls.grants();
 | ||||||
|  |       return OAUTH3.authz.grants(vm.form.provider, vm.api.authz._grantsOpts()).then(function (resp) { | ||||||
|  |         vm.responses.grants = { status: 0, data: resp }; | ||||||
|  |         vm.fn.updateUrls(); // vm.api.urls.grants();
 | ||||||
|  |       }, function (err) { | ||||||
|  |         console.error('[error] authz.grants:'); | ||||||
|  |         console.error(err); | ||||||
|  |         vm.error = err; | ||||||
|  |       }); | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     vm.form.provider = vm.defaults.provider; |     vm.form.provider = vm.defaults.provider; | ||||||
|     vm.validated.provider = vm.defaults.provider; |     vm.validated.provider = vm.defaults.provider; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user