Skip to content

Commit

Permalink
adding feature to allow for override of the default rekor domain on s…
Browse files Browse the repository at this point in the history
…tartup of the UI

Signed-off-by: Ahmed Alsabag <[email protected]>
  • Loading branch information
aalsabag committed Nov 1, 2023
1 parent ee2bfaf commit e5967a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
## Deploy

The app is based on [Next.JS](https://nextjs.org/) and is automatically built & deployed to GitHub Pages when pushing to the `main` branch.

## Internal Server Configuration

This app supports overriding of the default rekor server instance for those running private instances of the the sigstore stack.
Create a `.env.local` file at the root and include in it this environment variable
```properties
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN=https://privaterekor.sigstore.dev
```
4 changes: 4 additions & 0 deletions src/modules/api/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const RekorClientProvider: FunctionComponent<PropsWithChildren<{}>> = ({
const [baseUrl, setBaseUrl] = useState<string>();

const context: RekorClientContext = useMemo(() => {
if (baseUrl === undefined && process.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN) {
setBaseUrl(process.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN)
}

return {
client: new RekorClient({ BASE: baseUrl }),
baseUrl,
Expand Down
6 changes: 5 additions & 1 deletion src/modules/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export function Settings({
}, []);

const onSave = useCallback(() => {
if (localBaseUrl === undefined && process.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN){
setLocalBaseUrl(process.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN);
}

setBaseUrl(localBaseUrl);
onClose();
}, [localBaseUrl, setBaseUrl, onClose]);
Expand All @@ -49,7 +53,7 @@ export function Settings({
<Typography variant="overline">Override rekor endpoint</Typography>
<TextField
value={localBaseUrl ?? ""}
placeholder="https://rekor.sigstore.dev"
placeholder= {(baseUrl === undefined) ? "https://rekor.sigstore.dev" : baseUrl}
onChange={handleChangeBaseUrl}
fullWidth
/>
Expand Down

0 comments on commit e5967a6

Please sign in to comment.