Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When Auth Server is unavailable, browser can access protected routes #925

Open
markwt-waymark opened this issue Nov 21, 2022 · 1 comment

Comments

@markwt-waymark
Copy link

If I run the following code when the identity server is running it functions as expected; I am asked to login when attempting to access the protected dashboard route.

However, if the identity server is not running, there is no error in the console and the browser simply allows the client to access the protected route.

Am I doing something wrong here or is this a bug?

Thanks

const oidcConfig = {
    onSignIn: async (user: User | null) => {
        alert('You just signed in, congratz! Check out the console!');
        console.log(user);
        window.location.hash = '';
    },
    authority: process.env.REACT_APP_IDENTITY_AUTH_URL,
    clientId: process.env.REACT_APP_IDENTITY_CLIENT_ID,
    responseType: 'code',
    redirectUri: process.env.REACT_APP_IDENTITY_REDIRECT_URL,
    silentRedirectUri: process.env.REACT_APP_IDENTITY_SILENT_REDIRECT_URL,
    postLogoutRedirectUri: process.env.REACT_APP_IDENTITY_LOGOFF_REDIRECT_URL,
    scope: process.env.REACT_APP_IDENTITY_SCOPE
};

const router = createBrowserRouter([
    {
        path: "/",
        element: <Home />,
    },
    {
        path: "/dashboard",
        element:
            <AuthProvider {...oidcConfig}>
                <Dashboard />
            </AuthProvider>
    }
]);

function App() {
  return (
    <React.StrictMode>
        <RouterProvider router={router} />
    </React.StrictMode>
);
}
@simenandre
Copy link
Member

Not sure, does your browser run any requests that fail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants