<DashboardEmbedWithAuth />
Learn about the <DashboardEmbedWithAuth /> component and how to enhance your embedded dashboards with authentication in your React applications using the `embed-dossier-mstr-react` package.
Import
import { DashboardEmbedWithAuth } from "embed-dossier-mstr-react"
Props
| Prop | Type | Required | Description |
|---|---|---|---|
dossierUrl | string | Yes | The complete URL of your MicroStrategy dossier in the format: https://{env-url}/{libraryName}/app/{projectId}/{dossierId} |
loginMode | "guest" | "standard" | "saml" | "oidc" | "ldap" | Yes | The authentication method to use |
username | string | For 'standard' and 'ldap' | Username for authentication (required for standard and LDAP authentication) |
password | string | For 'standard' and 'ldap' | Password for authentication (required for standard and LDAP authentication) |
className | string | No | CSS class names to apply to the container element |
style | React.CSSProperties | No | Inline styles to apply to the container element |
config | Omit<MicroStrategyDossierConfig, "placeholder" | "url"> | No | Additional configuration options for the dashboard |
loadingComponent | ReactNode | No | Custom component to show during authentication and loading (defaults to a simple "Loading..." message) |
errorComponent | ReactNode | ((error: string) => ReactNode) | No | Custom component or render function for error states (defaults to a basic error message) |
Basic Usage
Here's a simple example of using the DashboardEmbedWithAuth component with standard authentication:
import { DashboardEmbedWithAuth } from "embed-dossier-mstr-react"
const MyAuthenticatedDashboard = () => {
return (
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="standard"
username="jsmith"
password="password123"
className="my-dashboard"
style={{ height: "700px" }}
/>
)
}
Authentication Methods
The component supports multiple authentication methods:
Guest Authentication
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="guest"
/>
Standard Authentication
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="standard"
username="jsmith"
password="password123"
/>
LDAP Authentication
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="ldap"
username="jsmith"
password="password123"
/>
Single Sign-On Methods
For SAML and OIDC, the component will redirect to the identity provider's login page:
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="saml"
/>
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="oidc"
/>
Custom Loading and Error States
You can customize the loading and error states using the loadingComponent and errorComponent props:
Custom Loading Component
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="standard"
username="jsmith"
password="password123"
loadingComponent={
<div className="flex justify-center items-center h-60">
<div className="spinner-border" role="status">
<span className="sr-only">Loading...</span>
</div>
<p className="ml-2">Loading your dashboard...</p>
</div>
}
/>
Custom Error Component
You can provide either a React node:
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="standard"
username="jsmith"
password="password123"
errorComponent={
<div className="bg-red-50 border-l-4 border-red-500 p-4 my-4">
<p className="text-red-700">
Failed to authenticate with the MicroStrategy server.
</p>
<p className="text-sm text-red-500">
Please check your credentials and try again.
</p>
</div>
}
/>
Or a render function that receives the error message:
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="standard"
username="jsmith"
password="password123"
errorComponent={(errorMessage) => (
<div className="error-container">
<h3>Authentication Error</h3>
<p>{errorMessage}</p>
<button onClick={() => window.location.reload()}>Retry</button>
</div>
)}
/>
Advanced Configuration
Similar to the DashboardEmbed component, you can customize the behavior and appearance of your dashboard by providing a config object:
<DashboardEmbedWithAuth
dossierUrl="https://demo.microstrategy.com/MicroStrategyLibrary/app/B7CA92F04B9FAE8D941C3E9B7E0CD754/27D332AC6D43352E0928B9A1FCAF4AB0"
loginMode="standard"
username="jsmith"
password="password123"
config={{
enableResponsive: true,
disableNotification: true,
dockedFilter: {
dockedPosition: "left",
canClose: true,
dockChangeable: true,
isDocked: true,
},
navigationBar: {
enabled: true,
gotoLibrary: true,
title: true,
toc: true,
},
filterFeature: {
enabled: true,
edit: true,
summary: true,
},
}}
style={{ height: "800px", width: "100%" }}
/>
How It Works
The DashboardEmbedWithAuth component:
- Extracts the server URL from the provided dossier URL using the
getInfoFromUrlutility - Uses the
useCreateDashboardWithAuthhook to handle authentication and dashboard creation - Displays a loading component during authentication
- Shows an error component if authentication fails
- Renders the dashboard once authentication is successful
Authentication Flow
- The component attempts to authenticate with the MicroStrategy server using the provided credentials and login mode
- For standard and LDAP authentication, it sends the username and password to the server
- For SAML and OIDC, it redirects to the identity provider's login page
- For guest authentication, it connects using the guest user credentials
- Once authenticated, it creates and renders the dashboard
Error Handling
The component automatically handles authentication errors and provides several ways to customize error states:
- If authentication fails, it displays the error component with the error message
- The error message includes details about what went wrong, such as invalid credentials or server issues
- You can provide a custom error component or function to display errors in a way that matches your application's design
Security Considerations
When using this component, keep these security best practices in mind:
- Avoid hardcoding credentials in your code; use environment variables or a secure credential management system
- Use HTTPS for all communications with the MicroStrategy server
- For production deployments, prefer SAML, OIDC, or backend proxy authentication over storing credentials in the frontend
- Consider implementing additional security measures such as IP restrictions or session timeouts
Related Components
DashboardEmbed- Basic component without authentication handlingLibraryPageEmbed- For embedding the MicroStrategy library page
Related Hooks
useCreateDashboardWithAuth- The hook used internally by this componentuseCreateDashboard- Basic dashboard creation hook without authentication