Skip to content

Commit

Permalink
Changed: simpler OIDC config init
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Oct 3, 2024
1 parent d940723 commit 5bc3cc6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
18 changes: 15 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,31 @@ import { UserJSDataverseRepository } from './users/infrastructure/repositories/U
import { DataverseApiAuthMechanism } from '@iqss/dataverse-client-javascript/dist/core/infra/repositories/ApiConfig'
import { BASE_URL } from './config'
import 'react-loading-skeleton/dist/skeleton.css'
import { AuthProvider, TAuthConfig } from 'react-oauth2-code-pkce'

if (BASE_URL === '') {
throw Error('VITE_DATAVERSE_BACKEND_URL environment variable should be specified.')
} else {
ApiConfig.init(`${BASE_URL}/api/v1`, DataverseApiAuthMechanism.SESSION_COOKIE)
}

const authConfig: TAuthConfig = {
clientId: 'test',
authorizationEndpoint: 'http://localhost:8000/realms/test/protocol/openid-connect/auth',
tokenEndpoint: 'http://localhost:8000/realms/test/protocol/openid-connect/token',
logoutEndpoint: 'http://localhost:8000/realms/test/protocol/openid-connect/logout',
redirectUri: 'http://localhost:8000/spa',
scope: 'openid'
}

const userRepository = new UserJSDataverseRepository()
function App() {
return (
<SessionProvider repository={userRepository}>
<Router />
</SessionProvider>
<AuthProvider authConfig={authConfig}>
<SessionProvider repository={userRepository}>
<Router />
</SessionProvider>
</AuthProvider>
)
}

Expand Down
24 changes: 0 additions & 24 deletions src/SecuredApp.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import ReactDOM from 'react-dom/client'
import './i18n'
import { LoadingProvider } from './sections/loading/LoadingProvider'
import { ThemeProvider } from '@iqss/dataverse-design-system'
import SecuredApp from './SecuredApp'
import App from './App'

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
<React.StrictMode>
<React.Suspense>
<LoadingProvider>
<ThemeProvider>
<SecuredApp />
<App />
</ThemeProvider>
</LoadingProvider>
</React.Suspense>
Expand Down

0 comments on commit 5bc3cc6

Please sign in to comment.