Comments (3)
Of course passing the authenticate call into every single resource middleware chain is going to fail on you - the strategy is for starting and consuming an authorization request and response callback. Nothing more.
Is this how I am supposed to protect an endpoint when using with passport?
Please consult the passport documentation for this.
My read of the code is that because id_token is not set, this method won't ever return a defined value.
if (error) throw;
if (id_token) validate(); // implicit and hybrid response types
if (code) finish validate() from before and then do tokenEndpoint();
I can see that when none of these is present no promise is returned, i will fix that with a rejection that the received data does not seem like an OIDC response or something similar. That ain't going to fix your issue of using passport in an incorrect way.
from node-openid-client.
Aha! So, in order to use with passport, I need to protect the endpoints entirely separately, with something like:
function checkAuthentication (options) {
return function (req, res, next) {
if (req.isAuthenticated()) {
return next()
}
res.redirect((options || {}).loginRedirect || '/');
}
}
router.use(checkAuthentication());
That does seem to move it forward. Passport's documentation isn't exactly wonderful, and without an example that does seem to be a gap here. I'll maybe see if I can work out an example I can make in a PR if you're interested.
from node-openid-client.
Any and all improvements, additions, typo fixes and such contributions are indeed very welcome. Happy to hear you're progressing.
from node-openid-client.
Related Issues (20)
- OAuth 2.0 Device Authorization Grant (Device Flow) - poll without PKCE HOT 3
- Type checking httpOptions and rejectUnauthorized
- RPError thrown when IdToken JWE Header enc is blank HOT 2
- client won't run under `edge` runtime HOT 1
- Support setting client_secret to an empty string when using client_secret_basic or client_secret_post HOT 1
- Cannot assign to read only property 'dpopProof' of object '#<Client>' HOT 2
- Unsuccessful Callback to Unknow client side error HOT 10
- isKeyObject check fails in Bun HOT 5
- Scope delimiter replace problem HOT 2
- Multiple authenticate requests from the same session causes state mismatch HOT 1
- Can't authenticate when the server advertises authorization_response_iss_parameter_supported HOT 2
- Requests made without Accept-Encoding header HOT 1
- "cty" should not be included in jwks query HOT 2
- URL is not a constructor at Issuer.request HOT 1
- Application and Identity manger on different domains HOT 1
- Support other status code than 200 HOT 4
- Unable to use private_key_jwt auth method with Azure.
- Audience matching doesn't work as intended HOT 1
- Using `authorizationUrl()` in combination with PAR adds too many parameters HOT 3
- update interface AuthenticateOptions to include redirect_uri HOT 1
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 node-openid-client.