Skip to content

Commit 7935b60

Browse files
committedMar 27, 2024
Open up the console for users with no auth
1 parent abf1ce3 commit 7935b60

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed
 

‎packages/web-console/src/providers/AuthProvider.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
5252
const [loading, setLoading] = useState(true)
5353
const [sessionData, setSessionData] =
5454
useState<ContextProps["sessionData"]>(undefined)
55-
const [ready, setReady] = useState(false)
55+
const [ready, setReady] = useState(
56+
!settings["acl.basic.auth.realm.enabled"] && !settings["acl.oidc.enabled"],
57+
)
5658
const [errorMessage, setErrorMessage] = useState<string | undefined>(
5759
undefined,
5860
)
@@ -76,12 +78,12 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
7678
setSessionData(tokenResponse)
7779
// Remove the code from the URL
7880
history.replaceState &&
79-
history.replaceState(
80-
null,
81-
"",
82-
location.pathname +
83-
location.search.replace(/[\?&]code=[^&]+/, "").replace(/^&/, "?"),
84-
)
81+
history.replaceState(
82+
null,
83+
"",
84+
location.pathname +
85+
location.search.replace(/[\?&]code=[^&]+/, "").replace(/^&/, "?"),
86+
)
8587
} else {
8688
const error = tokenResponse as unknown as OAuth2Error
8789
// display error message

‎packages/web-console/src/providers/QuestProvider/index.tsx

+19-8
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,29 @@
2222
*
2323
******************************************************************************/
2424

25-
import React, { createContext, PropsWithChildren, useEffect, useState } from "react";
25+
import React, {
26+
createContext,
27+
PropsWithChildren,
28+
useEffect,
29+
useState,
30+
} from "react"
2631
import * as QuestDB from "../../utils/questdb"
2732
import { useSelector } from "react-redux"
2833
import { selectors } from "../../store"
2934
import { useAuth } from "../AuthProvider"
3035
import { AuthPayload } from "../../modules/OAuth2/types"
3136
import { getValue } from "../../utils/localStorage"
3237
import { StoreKey } from "../../utils/localStorage/types"
33-
import { formatCommitHash, formatVersion } from "./services";
34-
import { Versions } from "./types";
38+
import { formatCommitHash, formatVersion } from "./services"
39+
import { Versions } from "./types"
3540

3641
const questClient = new QuestDB.Client()
3742

3843
type Props = {}
3944

4045
type ContextProps = {
41-
quest: QuestDB.Client,
42-
buildVersion: Versions,
46+
quest: QuestDB.Client
47+
buildVersion: Versions
4348
commitHash: string
4449
}
4550

@@ -57,8 +62,14 @@ export const QuestContext = createContext<ContextProps>(defaultValues)
5762
export const QuestProvider = ({ children }: PropsWithChildren<Props>) => {
5863
const settings = useSelector(selectors.console.getSettings)
5964
const { sessionData, refreshAuthToken } = useAuth()
60-
const [authCheckFinished, setAuthCheckFinished] = React.useState(settings["acl.basic.auth.realm.enabled"])
61-
const [buildVersion, setBuildVersion] = useState<Versions>(defaultValues.buildVersion)
65+
const [authCheckFinished, setAuthCheckFinished] = useState(
66+
settings["acl.basic.auth.realm.enabled"] ||
67+
(!settings["acl.oidc.enabled"] &&
68+
!settings["acl.basic.auth.realm.enabled"]),
69+
)
70+
const [buildVersion, setBuildVersion] = useState<Versions>(
71+
defaultValues.buildVersion,
72+
)
6273
const [commitHash, setCommitHash] = useState<string>("")
6374

6475
const finishAuthCheck = async () => {
@@ -115,7 +126,7 @@ export const QuestProvider = ({ children }: PropsWithChildren<Props>) => {
115126
value={{
116127
quest: questClient,
117128
buildVersion,
118-
commitHash
129+
commitHash,
119130
}}
120131
>
121132
{children}

0 commit comments

Comments
 (0)
Failed to load comments.