added accountIdx and accountHash to req.oauth3
This commit is contained in:
		
							parent
							
								
									a1f514a155
								
							
						
					
					
						commit
						de594964b4
					
				@ -188,11 +188,21 @@ function attachOauth3(req, res, next) {
 | 
				
			|||||||
      , url: 'https://oauth3.org/docs/errors#E_NOT_JWT'
 | 
					      , url: 'https://oauth3.org/docs/errors#E_NOT_JWT'
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if (!decoded.iss) {
 | 
				
			||||||
 | 
					      return PromiseA.reject({
 | 
				
			||||||
 | 
					        message: 'token missing iss'
 | 
				
			||||||
 | 
					      , code: 'E_MISSING_ISS'
 | 
				
			||||||
 | 
					      , url: 'https://oauth3.org/docs/errors#E_MISSING_ISS'
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    var ppid = decoded.sub || decoded.ppid || decoded.appScopedId;
 | 
					    var ppid = decoded.sub || decoded.ppid || decoded.appScopedId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    req.oauth3.encodedToken = token;
 | 
					    req.oauth3.encodedToken = token;
 | 
				
			||||||
    req.oauth3.token = decoded;
 | 
					    req.oauth3.token = decoded;
 | 
				
			||||||
    req.oauth3.ppid = ppid;
 | 
					    req.oauth3.ppid = ppid;
 | 
				
			||||||
 | 
					    req.oauth3.accountIdx  = ppid+'@'+token.iss;
 | 
				
			||||||
 | 
					    req.oauth3.accountHash = require('crypto').createHash('sha256').update(req.oauth3.accountIdx).digest('base64');
 | 
				
			||||||
 | 
					    req.oauth3.accountHash = req.oauth3.accountHash.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+/g, '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    req.oauth3.rescope = function (sub) {
 | 
					    req.oauth3.rescope = function (sub) {
 | 
				
			||||||
      // TODO: this function is supposed to convert PPIDs of different parties to some account
 | 
					      // TODO: this function is supposed to convert PPIDs of different parties to some account
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user