Comments (4)
@jefjos the passport-azure-ad
library can log the reasons to console if you set:
loggingNoPII: false
in config.js
.
However there is no feature in the library that would allow you to send these logs to the front-end (there might be other tools for that but I'm not aware of any). What you can do, though, is to set your own validation logic for reasons you care about, and send a response for them with the reason stated. If you actually look at the index.js, there we have:
if (req.authInfo['scp'].split(" ").indexOf("demo.read") >= 0) {
// Service relies on the name claim.
res.status(200).json({
'request-for': 'access_token',
'requested-by': req.authInfo['name'],
'issued-by': req.authInfo['iss'],
'issued-for': req.authInfo['aud'],
'scope': req.authInfo['scp']
});
} else {
console.log("Invalid Scope, 403");
res.status(403).json({'error': 'insufficient_scope'});
}
You could do something similar for validating the issuer, for example:
if (req.authInfo['iss'] != "https://sts.windows.net/{your-tenant-id}") {
res.status(403).json({'error': 'invalid issuer'});
}
from active-directory-javascript-nodejs-webapi-v2.
Thanks @derisen . But if I implement my own logic to do validation, then wouldn't that defeat the purpose of using the library?
from active-directory-javascript-nodejs-webapi-v2.
@jefjos sorry I must have misunderstood you. You can pass a "custom callback" function to passport.authenticate()
. Take a look at the documentation. The info
parameter should tell you the reason for rejection, you can return this then as response.
from active-directory-javascript-nodejs-webapi-v2.
Thanks @derisen ! This helps me.
from active-directory-javascript-nodejs-webapi-v2.
Related Issues (12)
- Documentation HOT 2
- req.user is undefined HOT 2
- Is it best practice to use sessions? HOT 4
- The client links in the overview are 404'd HOT 2
- Another 404 HOT 3
- Authentication failed due to: jwt audience is invalid HOT 3
- dead link?
- UPN, Profile ID missing from Account info page HOT 2
- Documentation HOT 1
- Authentication failed due to: In Strategy.prototype.jwtVerify: cannot verify token HOT 2
- cannot get AAD Federation metadata from endpoint you specified HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active-directory-javascript-nodejs-webapi-v2.