-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add basic auth config * add authority++ * move values to env * add authReq to msal service * pass bearer token to backend * remove console.log * Update .gitignore --------- Co-authored-by: Håkon Frøland <[email protected]>
- Loading branch information
Showing
6 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ dist-ssr | |
|
||
# bun | ||
*.tsbuildinfo | ||
|
||
# environment files | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
type Configuration, | ||
type PopupRequest, | ||
PublicClientApplication, | ||
type RedirectRequest, | ||
type SsoSilentRequest, | ||
} from "@azure/msal-browser"; | ||
|
||
export const clientId = import.meta.env.VITE_CLIENT_ID; | ||
const authority = import.meta.env.VITE_AUTHORITY; | ||
const redirectUri = import.meta.env.VITE_LOGIN_REDIRECT_URI; | ||
|
||
if (!clientId) { | ||
throw new Error("Client ID is not set"); | ||
} | ||
if (!authority) { | ||
throw new Error("Authority is not set"); | ||
} | ||
if (!redirectUri) { | ||
throw new Error("Redirect URI is not set"); | ||
} | ||
|
||
// MSAL configuration | ||
const configuration: Configuration = { | ||
auth: { | ||
clientId, | ||
authority, | ||
redirectUri, // Points to window.location.origin. You must register this URI on Microsoft Entra admin center/App Registration. | ||
postLogoutRedirectUri: "/", // Indicates the page to navigate after logout. | ||
navigateToLoginRequestUrl: false, // If "true", will navigate back to the original request location before processing the auth code response. | ||
}, | ||
cache: { | ||
cacheLocation: "localStorage", // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO between tabs. | ||
storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge | ||
}, | ||
}; | ||
|
||
export const msalInstance = new PublicClientApplication(configuration); | ||
|
||
export const scopes = import.meta.env.VITE_AUTH_SCOPES?.split(",") ?? []; | ||
|
||
export const authenticationRequest: | ||
| PopupRequest | ||
| RedirectRequest | ||
| SsoSilentRequest = { | ||
scopes, | ||
}; |