3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1
- import { ConsoleSettingsShape , ConsoleSettings } from "../../store/Console/types"
1
+ import {
2
+ ConsoleSettingsShape ,
3
+ ConsoleSettings ,
4
+ } from "../../store/Console/types"
2
5
3
6
type TokenPayload = Partial < {
4
7
grant_type : string
@@ -10,7 +13,9 @@ type TokenPayload = Partial<{
10
13
} >
11
14
12
15
const getBaseURL = ( config : ConsoleSettings ) => {
13
- return `${ config [ "acl.oidc.tls.enabled" ] ? "https" : "http" } ://${ config [ "acl.oidc.host" ] } :${ config [ "acl.oidc.port" ] } `
16
+ return `${ config [ "acl.oidc.tls.enabled" ] ? "https" : "http" } ://${
17
+ config [ "acl.oidc.host" ]
18
+ } :${ config [ "acl.oidc.port" ] } `
14
19
}
15
20
16
21
export const getAuthorisationURL = ( {
@@ -67,3 +72,8 @@ export const getAuthToken = async (
67
72
} ,
68
73
)
69
74
}
75
+
76
+ export const hasNoAuth = ( config : ConsoleSettings ) =>
77
+ ( config [ "acl.basic.auth.realm.enabled" ] !== undefined &&
78
+ ! config [ "acl.basic.auth.realm.enabled" ] ) ||
79
+ ( config [ "acl.oidc.enabled" ] == undefined && ! config [ "acl.oidc.enabled" ] )
Original file line number Diff line number Diff line change 9
9
getAuthorisationURL ,
10
10
getAuthToken ,
11
11
getTokenExpirationDate ,
12
+ hasNoAuth ,
12
13
} from "../modules/OAuth2/utils"
13
14
import {
14
15
generateCodeChallenge ,
@@ -52,9 +53,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
52
53
const [ loading , setLoading ] = useState ( true )
53
54
const [ sessionData , setSessionData ] =
54
55
useState < ContextProps [ "sessionData" ] > ( undefined )
55
- const [ ready , setReady ] = useState (
56
- ! settings [ "acl.basic.auth.realm.enabled" ] && ! settings [ "acl.oidc.enabled" ] ,
57
- )
56
+ const [ ready , setReady ] = useState ( hasNoAuth ( settings ) )
58
57
const [ errorMessage , setErrorMessage ] = useState < string | undefined > (
59
58
undefined ,
60
59
)
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import { getValue } from "../../utils/localStorage"
37
37
import { StoreKey } from "../../utils/localStorage/types"
38
38
import { formatCommitHash , formatVersion } from "./services"
39
39
import { Versions } from "./types"
40
+ import { hasNoAuth } from "../../modules/OAuth2/utils"
40
41
41
42
const questClient = new QuestDB . Client ( )
42
43
@@ -63,9 +64,7 @@ export const QuestProvider = ({ children }: PropsWithChildren<Props>) => {
63
64
const settings = useSelector ( selectors . console . getSettings )
64
65
const { sessionData, refreshAuthToken } = useAuth ( )
65
66
const [ authCheckFinished , setAuthCheckFinished ] = useState (
66
- settings [ "acl.basic.auth.realm.enabled" ] ||
67
- ( ! settings [ "acl.oidc.enabled" ] &&
68
- ! settings [ "acl.basic.auth.realm.enabled" ] ) ,
67
+ hasNoAuth ( settings ) ,
69
68
)
70
69
const [ buildVersion , setBuildVersion ] = useState < Versions > (
71
70
defaultValues . buildVersion ,
0 commit comments