adds pomerium version to the user info endpoint (#3093)

* adds pomerium version to the user info endpoint

* linting

* order imports
This commit is contained in:
Nathan Hayfield 2022-03-03 20:00:17 +01:00 committed by GitHub
parent 0bb47ed190
commit 351f562c42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 4 deletions

View file

@ -28,6 +28,7 @@ import (
"github.com/pomerium/pomerium/internal/sessions" "github.com/pomerium/pomerium/internal/sessions"
"github.com/pomerium/pomerium/internal/telemetry/trace" "github.com/pomerium/pomerium/internal/telemetry/trace"
"github.com/pomerium/pomerium/internal/urlutil" "github.com/pomerium/pomerium/internal/urlutil"
"github.com/pomerium/pomerium/internal/version"
"github.com/pomerium/pomerium/pkg/cryptutil" "github.com/pomerium/pomerium/pkg/cryptutil"
"github.com/pomerium/pomerium/pkg/grpc/databroker" "github.com/pomerium/pomerium/pkg/grpc/databroker"
"github.com/pomerium/pomerium/pkg/grpc/directory" "github.com/pomerium/pomerium/pkg/grpc/directory"
@ -575,6 +576,7 @@ func (a *Authenticate) userInfo(w http.ResponseWriter, r *http.Request) error {
WebAuthnCreationOptions: creationOptions, WebAuthnCreationOptions: creationOptions,
WebAuthnRequestOptions: requestOptions, WebAuthnRequestOptions: requestOptions,
WebAuthnURL: urlutil.WebAuthnURL(r, authenticateURL, state.sharedKey, r.URL.Query()), WebAuthnURL: urlutil.WebAuthnURL(r, authenticateURL, state.sharedKey, r.URL.Query()),
PomeriumVersion: version.FullVersion(),
}).ServeHTTP(w, r) }).ServeHTTP(w, r)
return nil return nil
} }

View file

@ -26,6 +26,7 @@ type UserInfoData struct {
WebAuthnCreationOptions *webauthn.PublicKeyCredentialCreationOptions WebAuthnCreationOptions *webauthn.PublicKeyCredentialCreationOptions
WebAuthnRequestOptions *webauthn.PublicKeyCredentialRequestOptions WebAuthnRequestOptions *webauthn.PublicKeyCredentialRequestOptions
WebAuthnURL string WebAuthnURL string
PomeriumVersion string
} }
// ToJSON converts the data into a JSON map. // ToJSON converts the data into a JSON map.
@ -52,6 +53,7 @@ func (data UserInfoData) ToJSON() map[string]interface{} {
m["webAuthnCreationOptions"] = data.WebAuthnCreationOptions m["webAuthnCreationOptions"] = data.WebAuthnCreationOptions
m["webAuthnRequestOptions"] = data.WebAuthnRequestOptions m["webAuthnRequestOptions"] = data.WebAuthnRequestOptions
m["webAuthnUrl"] = data.WebAuthnURL m["webAuthnUrl"] = data.WebAuthnURL
m["pomeriumVersion"] = data.PomeriumVersion
return m return m
} }

View file

@ -8,11 +8,12 @@ import UserInfoPage from "./components/UserInfoPage";
import WebAuthnRegistrationPage from "./components/WebAuthnRegistrationPage"; import WebAuthnRegistrationPage from "./components/WebAuthnRegistrationPage";
import { SubpageContextProvider } from "./context/Subpage"; import { SubpageContextProvider } from "./context/Subpage";
import { createTheme } from "./theme"; import { createTheme } from "./theme";
import { PageData } from "./types"; import {PageData, UserInfoPageData} from "./types";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import CssBaseline from "@mui/material/CssBaseline"; import CssBaseline from "@mui/material/CssBaseline";
import { ThemeProvider } from "@mui/material/styles"; import { ThemeProvider } from "@mui/material/styles";
import React, { FC } from "react"; import React, { FC } from "react";
import {get} from "lodash";
const theme = createTheme(); const theme = createTheme();
@ -54,7 +55,7 @@ const App: FC = () => {
<ToolbarOffset /> <ToolbarOffset />
</Box> </Box>
</Box> </Box>
<Footer /> <Footer pomeriumVersion={get(data, 'pomeriumVersion')} />
</SubpageContextProvider> </SubpageContextProvider>
</ThemeProvider> </ThemeProvider>
); );

View file

@ -4,7 +4,11 @@ import React, { FC } from "react";
import {FooterLink} from "./FooterLink"; import {FooterLink} from "./FooterLink";
import AppBar from "@mui/material/AppBar"; import AppBar from "@mui/material/AppBar";
const Footer: FC = () => { type FooterData = {
pomeriumVersion?: string;
}
const Footer: FC<FooterData> = ({pomeriumVersion}) => {
return ( return (
<AppBar <AppBar
position="fixed" position="fixed"
@ -20,7 +24,10 @@ const Footer: FC = () => {
justifyContent="center" justifyContent="center"
sx={{ sx={{
fontSize: "0.85rem", fontSize: "0.85rem",
padding: "16px", paddingLeft: "16px",
paddingRight: "16px",
paddingBottom: "8px",
paddingTop: "16px",
}} }}
> >
<Box> <Box>
@ -45,6 +52,19 @@ const Footer: FC = () => {
</FooterLink> </FooterLink>
</Box> </Box>
</Stack> </Stack>
{!!pomeriumVersion && (
<Stack
direction="row"
spacing={2}
justifyContent="center"
sx={{
paddingBottom: "6px",
fontSize: "0.85rem",
}}
>
<Box><b>Pomerium Version:</b> {pomeriumVersion}</Box>
</Stack>
)}
</AppBar> </AppBar>
); );
}; };

View file

@ -115,6 +115,7 @@ export type UserInfoPageData = BasePageData & {
webAuthnCreationOptions?: WebAuthnCreationOptions; webAuthnCreationOptions?: WebAuthnCreationOptions;
webAuthnRequestOptions?: WebAuthnRequestOptions; webAuthnRequestOptions?: WebAuthnRequestOptions;
webAuthnUrl?: string; webAuthnUrl?: string;
pomeriumVersion: string;
}; };
export type WebAuthnRegistrationPageData = BasePageData & { export type WebAuthnRegistrationPageData = BasePageData & {