npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

azure-ad-login-authentication

v1.1.5

Published

To test azure AD authentication in React components

Downloads

18

Readme

Quickstart

Install the module with:

Register a web application
npm install azure-ad-login-authentication

Register your Application

  1. Sign in to the Azure portal.
  2. If you have access to multiple tenants, use the Directories + subscriptions filter in the top menu to switch to the tenant in which you want to register the application.
  3. Search for and select Azure Active Directory. Under Manage, select App registrations > New registration.
  4. When the Register an application page appears, enter a name for your application.
  5. Under Supported account types, select Accounts in any organizational directory and personal Microsoft accounts.
  6. Select Register. On the app Overview page, note the Application (client) ID value for later use.
  7. Under Manage, select Authentication.
  8. Under Platform configurations, select Add a platform. In the pane that opens select Single-page application.
  9. Set the Redirect URIs value to http://localhost:3000/. This is the default port NodeJS will listen on your local machine. We’ll return the authentication response to this URI after successfully authenticating the user.
  10. Select Configure to apply the changes.
  11. Under Platform Configurations expand Single-page application.
  12. Confirm that under Grant types Already configured Your Redirect URI is eligible for the Authorization Code Flow with PKCE.

Depedency Required

npm install react-router-dom --save
npm install @azure/msal-browser

Getting Started

Import Login to your React Page Component

import Login from '../node_modules/azure-ad-login-authentication/dist/component/Login'

Create .env file in your root folder, add values of registered app in .env file.

.env file

REACT_APP_APPID=<Enter your application ID here>
REACT_APP_BASE_URL=<Enter your base URL here on which application runs>
REACT_APP_SCOPES=<Enter scope here>
REACT_APP_AUTHORITY=<Enter authority here>
REACT_APP_LANDING_PAGE_PATH=<Enter path of landing page after login>

.env file Example

REACT_APP_APPID=605283c9-ed67-478e-b870-5fc1a84fr436
REACT_APP_BASE_URL=http://localhost:3000
REACT_APP_SCOPES=user.read
REACT_APP_AUTHORITY=https://login.microsoftonline.com/<organisation name>.com
REACT_APP_LANDING_PAGE_PATH=home

How to use

and then in your app.js file import component-

import Login from '../node_modules/azure-ad-login-authentication/dist/component/Login'
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import Home from './component/home';

function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Login></Login>}/>
        <Route path="/home" element={<Home></Home>}></Route>
        
      </Routes>
    </BrowserRouter>
  );
}

Example

import Login from '../node_modules/azure-ad-login-authentication/dist/component/Login'
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import Home from './component/home';
function App() {
  return (
   <BrowserRouter>
      <Routes>
        <Route path="/" element={<Login></Login>}/>
        <Route path="/home" element={<Home></Home>}></Route>
        
      </Routes>
    </BrowserRouter>
  );
}

export default App;