Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
remix-auth-microsoft
Advanced tools
The Microsoft strategy is used to authenticate users against a [Microsoft Identity](https://docs.microsoft.com/en-us/azure/active-directory/develop/) account. This can be a work/school account or a personal Microsoft account, like Skype, Xbox and Outlook.
Weekly downloads
Readme
The Microsoft strategy is used to authenticate users against a Microsoft Identity account. This can be a work/school account or a personal Microsoft account, like Skype, Xbox and Outlook.com. It extends the OAuth2Strategy.
Runtime | Has Support |
---|---|
Node.js | ✅ |
Cloudflare | ✅ |
Follow the steps on the Microsoft documentation to create a new App Registration. You should select Web as the platform, configure a Redirect URI and add a client secret.
If you want to support login with both personal Microsoft accounts and school/work accounts, you might need to configure the supported account types by editing the manifest file. Set `signInAudience` value to `MicrosoftADandPersonalMicrosoftAccount` to allow login also with personal accounts.
Be sure to copy the client secret, Redirect URI and the Application (client) ID (under Overview) because you will need them later.
import { MicrosoftStrategy } from "remix-auth-microsoft";
let microsoftStrategy = new MicrosoftStrategy(
{
clientID: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
callbackURL: "https://example.com/auth/microsoft/callback",
},
async ({ accessToken, extraParams, profile }) => {
// Here you can fetch the user from database or return a user object based on profile
// return {profile}
// The returned object is stored in the session storage you are using by the authenticator
// If you're using cookieSessionStorage, be aware that cookies have a size limit of 4kb
// For example this won't work
// return {accessToken, extraParams, profile}
return User.findOrCreate({ email: profile.emails[0].value });
}
);
authenticator.use(microsoftStrategy);
// app/routes/login.tsx
export default function Login() {
return (
<Form action="/auth/microsoft" method="post">
<button>Login with Microsoft</button>
</Form>
);
}
// app/routes/auth/microsoft.tsx
import { ActionFunction, LoaderFunction } from "remix";
import { authenticator } from "~/auth.server";
export let loader: LoaderFunction = () => redirect("/login");
export let action: ActionFunction = ({ request }) => {
return authenticator.authenticate("microsoft", request);
};
// app/routes/auth/microsoft/callback.tsx
import { ActionFunction, LoaderFunction } from "remix";
import { authenticator } from "~/auth.server";
export let loader: LoaderFunction = ({ request }) => {
return authenticator.authenticate("microsoft", request, {
successRedirect: "/dashboard",
failureRedirect: "/login",
});
};
If you want to allow login only for users from a single organization, you should add the tenant
attribute to the configuration passed to MicrosoftStrategy
. The value of tenant
should be the Directory (tenant) ID found under Overview in your App Registration page.
You must also select Accounts in this organizational directory as Supported account types in your App Registration.
let microsoftStrategy = new MicrosoftStrategy(
{
clientID: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
callbackURL: "https://example.com/auth/microsoft/callback",
tenant: "YOUR_TENANT_ID",
},
async (accessToken, _, extraParams, profile) => {
return User.findOrCreate({ email: profile.emails[0].value });
}
);
FAQs
The Microsoft strategy is used to authenticate users against an account on [Microsoft Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/develop/) using [Remix-Auth](https://github.com/sergiodxa/remix-auth). This can be a work/schoo
The npm package remix-auth-microsoft receives a total of 4,394 weekly downloads. As such, remix-auth-microsoft popularity was classified as popular.
We found that remix-auth-microsoft demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.