In my node project I have the following basic code to connect to Azure via a token. The login/logout works great together with our Azure:
const express = require("express");
const msal = require('@azure/msal-node');
const SERVER_PORT = process.env.PORT || 3000;
const config = {
auth: {
clientId: "XXX",
authority: "https://login.microsoftonline.com/common",
clientSecret: "XXX"
},
system: {
loggerOptions: {
loggerCallback(loglevel, message, containsPii) {
console.log(message);
},
piiLoggingEnabled: false,
logLevel: msal.LogLevel.Verbose,
}
}
};
const pca = new msal.ConfidentialClientApplication(config);
const app = express();
app.get('/', (req, res) => {
res.send("<a href=\"login\">Login</a> <a href=\"logout\">Logout</a>");
});
app.get('/dashboard', (req, res) => {
// check here for valid token...
});
app.get('/login', (req, res) => {
const authCodeUrlParameters = {
scopes: ["user.read"],
redirectUri: "http://localhost:3000/redirect",
};
pca.getAuthCodeUrl(authCodeUrlParameters).then((response) => {
res.redirect(response);
}).catch((error) => console.log(JSON.stringify(error)));
});
app.get('/logout', (req, res) => {
res.redirect('https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri=http://localhost:3000/');
});
app.get('/redirect', (req, res) => {
const tokenRequest = {
code: req.query.code,
scopes: ["user.read"],
redirectUri: "http://localhost:3000/redirect",
};
pca.acquireTokenByCode(tokenRequest).then((response) => {
console.log("\nResponse: \n:", response);
res.sendStatus(200);
}).catch((error) => {
console.log(error);
res.status(500).send(error);
});
});
app.listen(SERVER_PORT, () => console.log(`Msal Node Auth Code Sample app listening on port ${SERVER_PORT}!`))
But how to properly check after that logging in if the token is still valid?
So the question is, how can I be save that the user on /dashboard has still a valid token or is logged in?
app.get('/dashboard', (req, res) => {
// check here for valid token...
});
At the end I need a node.js application that:
- is safe (token-based)
- has user auth (msal)
- can give granular permissions on routes
Can I do all that in node.js or better doing that in client-side? But am I then reducing the security?
buy generic cialis cheap
viagra versus levitra
cialis without a doctor
how can i get propecia
viagra online generic
ivermectina bula
generic clomiphene – generic clomid clomid capsules 50mg
ivermectin tablets
278138 888984Echt tolle Seite. Rubbish bin eigentlich nur per Zufall hier gelandet, aber ich bin jetzt schon complete von der tremendous Seite beeindruckt. Gratuliere dazu!! Viel Erfolg noch durch der sehr guten Home-page mein Freund. 845761
[url=http://ivermectineffects.com]ivermectin dosage[/url]
ed treatment pills – online ed meds best place to buy ed pills online
which is better viagra cialis or levitra levitra medicine levitra 10 mg tablets
zithromax z pak
ivermectin for humans over the counter is cost of ivermectin pill can humans take ivermectin paste
ventolin hfa inhaler coupon 2021
stromectol ivermectin tablets ivermectin tablets
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help prescription drugs canadian generic drugs without doctor’s prescription online prescriptions no visit
what is better for health insurance: high deductible and lower premiums or vice versa? proventil savings card albuterol side effects
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help ivermectin over the counter stromectol stromectol
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help ivermectina dosis ivermectin tablets ivermectin tablets
349651 163990The planet are really secret by having temperate garden which are normally beautiful, rrncluding a jungle that is surely definitely profligate featuring so several systems by way of example the game courses, golf procedure and in addition private pools. Hotel reviews 159997
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help ivermectin for sale ivermectin tablets ivermectin human dosage
amoxicillin over counter – amoxicillin without a doctor amoxicillin pneumonia
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help stromectol ivermectin ivermectin online ivermectin м •м њ мЃкµ
money can t buy everything essay – essay on help write essays for money
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help levitra without prescription 20mg levitra vardenafil 20mg india
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help stromectol ivermectin ivermectin tablets
prednisone 10 mg tablet – buying prednisone 4mg without prescription purchase prednisone
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help augmentin amoxicillin uses amoxicillin clavulanate
Store MSAL logged-in users and precheck them before doing a request on node.js web app – JavaScript Help ivermectin for humans for sale ivermectin for humans ivermectin human dose uk
ivermectin uk buy – purchase stromectol stromectol pharmacy
vardenafil coupon – cvs online pharmacy new ed drugs
discount prednisone 10 mg – prednisone online no prescription prednisone 200 mg daily
viagra canada pharmacy – sildenafil without a doctor’s prescription order viagra online cheap
buy ivermectin 6mg – stromectol online pharmacy ivermectin 3mg oral
how much is prednisone 10 mg – prednisone 20mg cost of prednisone 40 mg
prednisone 20mg online without prescription – 60 mg prednisone prednisone buy without prescription
725670 673117I found your weblog web site on google and check a couple of of your early posts. Proceed to maintain up the very very good operate. I just extra up your RSS feed to my MSN News Reader. Searching for ahead to reading extra from you later on! 536341
purchase sildalis online cheap – sildalis order online buy glucophage 1000mg pill
acheter 50mg viagra en ligne – vrai cialis prix tadalafil 20mg generique
lisinopril 10mg sale – buy metoprolol online cheap prilosec 10mg without prescription