Skip to content

Commit

Permalink
Eliminate well-known-config OIDC call
Browse files Browse the repository at this point in the history
  • Loading branch information
joshigaurava committed Jan 5, 2022
1 parent f32bc20 commit 929041f
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions pinot-controller/src/main/resources/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const App = () => {
const [redirectUri, setRedirectUri] = React.useState(null);
const [clientId, setClientId] = React.useState(null);
const [authWorkflow, setAuthWorkflow] = React.useState(null);
const [authorizationEndopoint, setAuthorizationEndopoint] = React.useState(
const [authorizationEndpoint, setAuthorizationEndpoint] = React.useState(
null
);

Expand Down Expand Up @@ -121,15 +121,8 @@ const App = () => {

setIsAuthenticated(true);
} else {
// Get authorization endpoint
const openIdConfigResponse = await PinotMethodUtils.getWellKnownOpenIdConfiguration(
issuer
);
setAuthorizationEndopoint(
openIdConfigResponse && openIdConfigResponse.authorization_endpoint
? openIdConfigResponse.authorization_endpoint
: ''
);
// Set authorization endpoint
setAuthorizationEndpoint(`${issuer}/auth`);

setLoading(false);
}
Expand All @@ -151,11 +144,11 @@ const App = () => {
}, [authWorkflow]);

React.useEffect(() => {
if (authorizationEndopoint && oidcSignInFormRef && oidcSignInFormRef.current) {
// Authorization endpoint available; submit signin form
if (authorizationEndpoint && oidcSignInFormRef && oidcSignInFormRef.current) {
// Authorization endpoint available; submit sign in form
oidcSignInFormRef.current.submit();
}
}, [authorizationEndopoint]);
}, [authorizationEndpoint]);

React.useEffect(() => {
if (isAuthenticated) {
Expand Down Expand Up @@ -189,12 +182,12 @@ const App = () => {
<NotificationContextProvider>
<CustomNotification />
{/* OIDC auth workflow */}
{authWorkflow && authWorkflow === AuthWorkflow.OIDC ? (
{authWorkflow && authWorkflow === AuthWorkflow.OIDC && !isAuthenticated ? (
<>
{/* OIDC sign in form */}
<form
hidden
action={authorizationEndopoint}
action={authorizationEndpoint}
method="post"
ref={oidcSignInFormRef}
>
Expand All @@ -209,7 +202,7 @@ const App = () => {
</>
) : (
<>
{/* Non-OIDC auth workflow */}
{/* Non-OIDC/authenticated workflow */}
{loading ? (
<CircularProgress className={classes.loader} size={80} />
) : (
Expand Down

0 comments on commit 929041f

Please sign in to comment.