Skip to content

Commit

Permalink
Implemented azuread authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
runely committed May 25, 2022
1 parent be0585b commit 6709f50
Show file tree
Hide file tree
Showing 21 changed files with 999 additions and 60 deletions.
76 changes: 76 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@azure/msal-browser": "2.24.0",
"@microsoft/teams-js": "2.0.0",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "13.5.0",
Expand Down
36 changes: 18 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
import { BrowserRouter, Routes, Route } from 'react-router-dom'

import { Queue } from './pages/Queue'
import { Statistics } from './pages/Statistics'
import { APIKeys } from './pages/APIKeys'
import { PageNotFound } from './pages/PageNotFound'
import { Login } from './pages/Auth/Login'
import { HandleLogin } from './pages/Auth/HandleLogin'
import { LoginRedirect } from './pages/Auth/LoginRedirect'
import { Logout } from './pages/Auth/Logout'
import { AuthRoute } from './pages/Auth/AuthRoute'
import { DefaultLayout } from './layouts/Default'

function App() {
function App () {
return (
<Router>
<div className='app'>
<Routes>
<Route path='/' element={<Queue />} />
<Route path='/statistics' element={<Statistics />} />
<Route path='/apikeys' element={<APIKeys />} />

<Route path='*' element={<PageNotFound />} />
</Routes>
</div>
</Router>
<BrowserRouter>
<Routes>
<Route path='/login' element={<Login />} />
<Route path='/handlelogin' element={<HandleLogin />} />
<Route path='/loginredirect' element={<LoginRedirect />} />
<Route path='/logout' element={<Logout />} />
<Route path='/*' element={<AuthRoute><DefaultLayout /></AuthRoute>} />
</Routes>
</BrowserRouter>
)
}

export default App;
export default App
41 changes: 41 additions & 0 deletions src/auth/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Import modules
*/
import envToObj from './lib/envToObj'

/*
Default configuration
*/
const defaultConfig = {
common: {
loginUrl: '/loginredirect',
storage: 'local',
login: {
type: 'redirect'
}
},
providers: {
azuread: {
client: {
auth: {
clientId: '[Requred in environment variables]',
authority: 'https://sts.windows.net/08f3813c-9f29-482f-9aec-16ef7cbf477a',
redirectUri: 'http://localhost:3000/handlelogin',
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: 'localStorage',
storeAuthStateInCookie: false
}
},
login: {
scopes: ['clientId/.default']
}
}
}
}

const config = envToObj(defaultConfig, { prefixes: 'auth' })
if (process.env.NODE_ENV === 'development') console.log('Authentication configuration', config)

export default config
Loading

0 comments on commit 6709f50

Please sign in to comment.