Coder Social home page Coder Social logo

azure-samples / microsoft-identity-express Goto Github PK

View Code? Open in Web Editor NEW
18.0 29.0 8.0 3.05 MB

Simple wrapper around MSAL Node for handling authN/authZ in Express.js web apps with the Microsoft identity platform

TypeScript 99.44% JavaScript 0.49% Shell 0.07%
msal-node authentication authorization azure-active-directory azure-ad-b2c authorization-code-grant express mvc ms-identity middleware

microsoft-identity-express's Issues

isAuthenticated() not redirecting users to sign in

Hi,

According to the documentation I should be able to add isAuthenticated() into the middleware chain to protect routes, with an optional route to redirect to (such as to send them to sign-in).

msid.isAuthenticated({
unauthorizedRedirect: "/sign-in"
}

However, I'm not seeing where that unauthorized route is ever used:

isAuthenticated(options?: GuardOptions): RequestHandler {
return (req: Request, res: Response, next: NextFunction): void => {
if (req.session) {
if (!req.session.isAuthenticated) {
this.logger.error(ErrorMessages.NOT_PERMITTED);
return res.redirect(this.appSettings.authRoutes.unauthorized);
}
next();
} else {
this.logger.error(ErrorMessages.SESSION_NOT_FOUND);
res.redirect(this.appSettings.authRoutes.unauthorized);
}
}
};

Ideally, I'd like the user to be redirected to MSAAD for sign-in if req.session.isAuthenticated is false, and I did this in my own middleware. But am I missing something that's included in this project?

Thank you!

ERR_INVALID_ARG_TYPE on the /redirect

I've got a basic app setup and when AAD goes to redirect back to my site I'm getting [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at new NodeError (node:internal/errors:371:5)
at Function.from (node:buffer:321:9)
at _callee$ (C:\Projects\myproject\node_modules\microsoft-identity-express\src\client\webapp\MsalWebAppAuthClient.ts:184:139)

any ideas?

(node:100152) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'state' of undefined on the /redirect

I've done basic app setup and when AAD goes to redirect back to my site I'm getting UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'state' of undefined
at _callee$ (/home/akhilesh/Workspace/gems_re/ms-identity-javascript-nodejs-tutorial/1-Authentication/1-sign-in/App/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:1605:31)

any ideas?

Handling separate sign in and sign up B2C user flows

I'm trying to create a B2C authentication solution with separate user flows for singing in and signing up for more granular control. Is it possible to utilize this library to create a separate .../sing-up handle? If so, what steps should I look to take?

redirect users to intended page (dynamically)

Issue

This issue is for a

    - [x] question

When calling the /signin route with parameters (e.g. /signin?callingURL=https%3A%2F%2Fgoogle.com) the parameters are not passed to postLogoutRedirect. Is there any way to preserve req.qurey? I am trying to redirect the user back to the intended page (in a dynamic way) following a signin. In other words I don't want the postLogoutRedirect to be static. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.