Giter Site home page Giter Site logo

pinkpeachabc / vue-auth-msal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shigeyf/vue-auth-msal

0.0 0.0 0.0 526 KB

Vue Plugin library for MSAL.JS (Microsoft Authentication Library for JS) - Support Vue.js 3.x or later

License: Apache License 2.0

Shell 2.28% JavaScript 25.18% TypeScript 72.55%

vue-auth-msal's Introduction

Microsoft Authentication Library plugin for Vue 3.x (vue-auth-msal)

npm version npm downloads Apache 2.0 License

Getting Started Azure AD docs Sample apps

Table of Contents

  1. About
  2. FAQ (TBD)
  3. Changelog (TBD)
  4. Prerequisites
  5. Installation
  6. Usage
  7. Samples
  8. Build and Test
  9. License

About

MSAL library for JavaScript enables client-side JavaScript applications to authenticate users using Azure AD work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through Azure AD B2C service. It also enables your app to get tokens to access services including your custom services and Microsoft Cloud services such as Microsoft Graph.

This vue-auth-msal vue-plugin package in this repository is an unofficial implementation of MASL authentication plugin for Vue 3.x app, which uses the @azure/msal-browser package as a peer dependency to enable authentication in Javascript Single-Page Applications without backend servers. This version of the library uses the OAuth 2.0 Authorization Code Flow with PKCE.

To read more about this protocol, as well as the differences between implicit flow and authorization code flow, see the section in the @azure/msal-browser README.

This package is inspired by a sample implementation of MSAL.js 2.x + Vue 3 + TypeScript application in the Microsoft GitHub repository.

Prerequisites

Installation

The MSAL Vue package is available on NPM.

Please installl vue-auth-msal with your favorite package manager to your application:

npm install vue-auth-msal
# or with yarn
yarn add vue-auth-msal
# or with pnpm
pnpm install vue-auth-msal

Usage

Quick Starter

To use this plugin, create a MSAL plugin instance (via createMsal()) and pass it to the app as a plugin (with use() Vue function) as below.

This example is to use the plugin with vue-router.

import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import routes from './router'
import { createMsal, MsalPlugin } from 'vue-auth-msal'
import type { MsalCreateOptions, MsalPluginOptions } from 'vue-auth-msal'
import { msalConfig, interactionType, loginRequest } from './authConfig' // Your MSAL config file
import App from './App.vue'

const app = createApp(App)

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: routes,
})
app.use(router)

const msalOptions: MsalCreateOptions = {
  configuration: msalConfig,
  interactionType: interactionType,
  loginRequest: loginRequest,
}
const msal: MsalPlugin = createMsal(msalOptions)
app.use<MsalPluginOptions>(msal, { router })

app.mount('#app')

Getting Started

For more help getting started with vue-auth-msal please see our Getting Started doc.

Samples

Our samples directory contains several example apps you can spin up to see how this plugin can be used in different scenarios.

Build and Test

See the contributing.md file for more information.

Building the package locally

To build the vue-auth-msal library, you can do the following:

// Install dev dependencies from root of repo
npm install
// Change to vue-auth-msal package directory
cd packages/vue-auth-msal/
// To run build only for vue-auth-msal package
npm run build

License

Copyright (c) Shige Fukushima. All rights reserved. Licensed under the Apache 2.0 License.

Thank You

vue-auth-msal's People

Contributors

shigeyf avatar

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.