-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WG309 Auth Context and Welcome screen - WIP * WG309 Auth Context and Welcome screen - WIP2 * WG309 Auth Context and Welcome screen - WIP * Add sign_in handler * WG309 Update welcome screen form * WG309 Update sign in formData submit * WG309 Update sign in req and payload * Fix format in helm testdata * Enable CORS for dev * Remove unnecessary package * WG309 Userinfo draft and cleanup * Callback working - use REACT_API_URL=http://0.0.0.0:9001 * WG309 User info returns 200 * WG309 Remove CORS related code * WG309 Remove CORS related code - update * Add tests for Signin handler * Update tests * Remove username from sign in form * Add token signer/verifier * Fix test * Add new middleware * Add tests for Signin handler * User from stash * WG309 AuthContext update on user info check * WG309 AuthContext update on user info check - 2 * WG309 Refactor loading in AuthContext * WG309 AuthContext reruns on history change * Fix conflict * WG309 AuthContext refactor * WG309 On refresh page doesnt go to 404 anymore * Wrap loading page * WG309 Fix oidc return url * Issued cookies should have the Secure attribute to true * WG309 Display alert error * Remove secret yaml example * WG309 Improve loading transition * Add OIDC flow test for user info endpoint * WG309 Improve loading transition - 2 * Fix eslint errors * Split out authchecking from the authcontext, single router * WG309 Add switch for password visibility * WG309 Add switch for password visibility - updated * Add BE logout code * Update package.json with main version * Lint it * WG407 Add user settings section - WIP * Rm security risk printing user-supplied value * WG407 Add user settings section - WIP2 * WG309 Hide UI behind flag - WIP * Push first pass at GET /v1/config * https in tests * Revert "https in tests" This reverts commit 286211b. * get feature flags innit * WG309 Hide UI behind feature flag - updated * Linting and testing * Update exports * untagglin * fix fix fix * OIDC is optional now * Update package.lock * WG407 Hide userSettings when authFlag is null * WG309 Hide UI behind feature flag - updated2 * WG407 Hide userSettings when authFlag is null - 2 * Fix issues in package-lock.json * Fix issues in package-lock.json - 2 * WG407 Add FeatureFlags context * WG407 Add FeatureFlags context - updated * WG407 Add FeatureFlags context - updated2 * Fix linting error * Update ui/contexts/AuthContext.tsx Co-authored-by: Simon <footless@gmail.com> * Implement PR feedback * Implement PR feedback - 2 Co-authored-by: Yiannis <yiannis@weave.works> Co-authored-by: Simon Howe <footless@gmail.com>
- Loading branch information
1 parent
2d686a9
commit 7297ddf
Showing
7 changed files
with
178 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { | ||
IconButton, | ||
ListItemIcon, | ||
Menu, | ||
MenuItem, | ||
Tooltip, | ||
} from "@material-ui/core"; | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import { Auth } from "../contexts/AuthContext"; | ||
import Icon, { IconType } from "./Icon"; | ||
|
||
const UserAvatar = styled(Icon)` | ||
padding-right: ${(props) => props.theme.spacing.medium}; | ||
`; | ||
|
||
const SettingsMenu = styled(Menu)` | ||
.MuiListItemIcon-root { | ||
min-width: 25px; | ||
color: ${(props) => props.theme.colors.black}; | ||
} | ||
`; | ||
|
||
function UserSettings() { | ||
const [anchorEl, setAnchorEl] = React.useState(null); | ||
const { userInfo, logOut } = React.useContext(Auth); | ||
|
||
const open = Boolean(anchorEl); | ||
const handleClick = (event) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Tooltip title="Account settings"> | ||
<IconButton | ||
onClick={handleClick} | ||
aria-controls={open ? "account-menu" : undefined} | ||
aria-haspopup="true" | ||
aria-expanded={open ? "true" : undefined} | ||
> | ||
<UserAvatar size="xl" type={IconType.Account} color="white" /> | ||
</IconButton> | ||
</Tooltip> | ||
<SettingsMenu | ||
anchorEl={anchorEl} | ||
id="account-menu" | ||
open={open} | ||
onClose={handleClose} | ||
onClick={handleClose} | ||
transformOrigin={{ horizontal: "right", vertical: "top" }} | ||
> | ||
<MenuItem>Hello, {userInfo?.email}</MenuItem> | ||
<MenuItem onClick={() => logOut()}> | ||
<ListItemIcon> | ||
<Icon type={IconType.LogoutIcon} size="base" /> | ||
</ListItemIcon> | ||
Logout | ||
</MenuItem> | ||
</SettingsMenu> | ||
</> | ||
); | ||
} | ||
|
||
export default styled(UserSettings)``; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as React from "react"; | ||
|
||
export type FeatureFlagsContext = { | ||
authFlag: boolean | null; | ||
}; | ||
|
||
export const FeatureFlags = | ||
React.createContext<FeatureFlagsContext | null>(null); | ||
|
||
export default function FeatureFlagsContextProvider({ children }) { | ||
const [authFlag, setAuthFlag] = React.useState<boolean>(null); | ||
|
||
const getAuthFlag = React.useCallback(() => { | ||
fetch("/v1/featureflags") | ||
.then((response) => response.json()) | ||
.then((data) => | ||
setAuthFlag(data.flags.WEAVE_GITOPS_AUTH_ENABLED === "true") | ||
) | ||
.catch((err) => console.log(err)); | ||
}, []); | ||
|
||
React.useEffect(() => { | ||
getAuthFlag(); | ||
}, [getAuthFlag]); | ||
|
||
// Loading... | ||
if (authFlag === null) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<FeatureFlags.Provider | ||
value={{ | ||
authFlag, | ||
}} | ||
> | ||
{children} | ||
</FeatureFlags.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters