-
Notifications
You must be signed in to change notification settings - Fork 14
Automatic ACS URL in IdP forms w/ copy button #2510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
diff --git a/app/ui/lib/TextInput.tsx b/app/ui/lib/TextInput.tsx
index 786c1ee6..5e64bcef 100644
--- a/app/ui/lib/TextInput.tsx
+++ b/app/ui/lib/TextInput.tsx
@@ -8,6 +8,7 @@
import { announce } from '@react-aria/live-announcer'
import cn from 'classnames'
import React, { useEffect } from 'react'
+import type { Merge } from 'type-fest'
import { CopyToClipboard } from './CopyToClipboard'
@@ -34,14 +35,18 @@ export type TextAreaProps =
// it makes a bunch of props required that should be optional. Instead we simply
// take the props of an input field (which are part of the Field props) and
// manually tack on validate.
-export type TextInputBaseProps = React.ComponentPropsWithRef<'input'> & {
+export type TextInputBaseProps = Merge<
+ React.ComponentPropsWithRef<'input'>,
+ {
// error is used to style the wrapper, also to put aria-invalid on the input
error?: boolean
disabled?: boolean
className?: string
fieldClassName?: string
copyable?: boolean
+ value?: string
}
+>
export const TextInput = React.forwardRef<
HTMLInputElement,
@@ -88,7 +93,7 @@ export const TextInput = React.forwardRef<
/>
{copyable && (
<CopyToClipboard
- text={fieldProps.value as string}
+ text={fieldProps.value}
className="flex h-full items-stretch border-l border-solid px-3 border-default hover:border-hover"
/>
)} It doesn't seem like we're passing anything other than string to it anywhere because there are no type errors when I do that, except
In this particular case, we know it won't be undefined because we're constructing it and passing it in, but the only way to ensure that in the code is something like {copyable && fieldProps.value && <CopyToClipboard />} Which I guess is fine, though it risks us accidentally doing something weird later where we set Another option would be to not use a real input at all here, and instead construct a little div that looks like an input, then we don't have to modify |
We don't have an e2e test exercising the IdP create form! I will add one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome. It works really well. The only thing I wanna do before merging is make sure there’s really no way the user can be accessing the console through some other domain (through a proxy, maybe) that could cause us to be wrong to pull the delegated domain out of window.location
.
Based on some discussion in chat, it seems like my concern about a proxy is founded.
The idea would be that there is a "true" rack hostname that the IdP is supposed to use when talking to the rack, but the user is hitting the rack through a proxy that gives them a different one, so putting the latter in the ACS URL would be wrong. This is only a problem if the IdP is not also supposed to be using the same proxy. This only makes sense if the proxy is doing TLS termination because otherwise it could not change the hostname on the incoming request, and Nexus would reject it because Nexus relies on the hostname being the one it knows about. This all seems kind of unlikely, so one option is to do nothing and see if it becomes a problem. If it is, the user can always use the CLI instead. I don't love that because even though it's unlikely, it's a wrinkle that pops up at rack setup time, which is an especially critical time for customer perception of the product. Options
Any other ways we could do it? |
I'm thinking we can overexplain in the help text and that will let us keep the checkbox label short. I'm also realizing that "Service provider" is a lot less clear than saying what it really means, which is the rack. Maybe something more like:
And then what if the checkbox says "Override standard format" and defaults to unchecked? That part isn’t necessary, it could still be “Use standard format” and default checked, like you have it. |
app/forms/idp/create.tsx
Outdated
@@ -62,6 +65,24 @@ export function CreateIdpSideModalForm() { | |||
}) | |||
|
|||
const form = useForm({ defaultValues }) | |||
const name = form.watch('name') | |||
|
|||
const acsUrlForm = useForm({ defaultValues: { generateUrl: true } }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but it would be simpler as a regular useState
and a Checkbox instead of a CheckboxField
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Try the useState
thing, see if it’s nicer, but this is good to go.
oxidecomputer/console@6eeab20...9ef82ba * [9ef82bad](oxidecomputer/console@9ef82bad) oxidecomputer/console#2529 * [23beefea](oxidecomputer/console@23beefea) oxidecomputer/console#2537 * [48693a22](oxidecomputer/console@48693a22) oxidecomputer/console#2510 * [8da7b6d0](oxidecomputer/console@8da7b6d0) oxidecomputer/console#2539 * [5edf89ef](oxidecomputer/console@5edf89ef) oxidecomputer/console#2536 * [dcddc81f](oxidecomputer/console@dcddc81f) oxidecomputer/console#2538 * [6f83d416](oxidecomputer/console@6f83d416) oxidecomputer/console#2518 * [7dcd41c2](oxidecomputer/console@7dcd41c2) oxidecomputer/console#2511 * [b01ca85d](oxidecomputer/console@b01ca85d) bump omicron to latest main * [b4920b11](oxidecomputer/console@b4920b11) oxidecomputer/console#2530 * [0552b62e](oxidecomputer/console@0552b62e) oxidecomputer/console#2527 * [ca7f6e20](oxidecomputer/console@ca7f6e20) oxidecomputer/console#2528
oxidecomputer/console@6eeab20...9ef82ba * [9ef82bad](oxidecomputer/console@9ef82bad) oxidecomputer/console#2529 * [23beefea](oxidecomputer/console@23beefea) oxidecomputer/console#2537 * [48693a22](oxidecomputer/console@48693a22) oxidecomputer/console#2510 * [8da7b6d0](oxidecomputer/console@8da7b6d0) oxidecomputer/console#2539 * [5edf89ef](oxidecomputer/console@5edf89ef) oxidecomputer/console#2536 * [dcddc81f](oxidecomputer/console@dcddc81f) oxidecomputer/console#2538 * [6f83d416](oxidecomputer/console@6f83d416) oxidecomputer/console#2518 * [7dcd41c2](oxidecomputer/console@7dcd41c2) oxidecomputer/console#2511 * [b01ca85d](oxidecomputer/console@b01ca85d) bump omicron to latest main * [b4920b11](oxidecomputer/console@b4920b11) oxidecomputer/console#2530 * [0552b62e](oxidecomputer/console@0552b62e) oxidecomputer/console#2527 * [ca7f6e20](oxidecomputer/console@ca7f6e20) oxidecomputer/console#2528
https://console-git-automaticacsurl-oxidecomputer.vercel.app/system/silos/maze-war/idps-new
This adds a click-to-copy component as an option for inputs, and then uses that new feature in the IDP form to allow the user to copy an auto-generated ACS URL.
Augustus had the very good idea (in #2472):
This PR, then, sets up that form to have the ACS value automatically generated.
Closes #2472
There are a two things I have questions on.
fieldProps.value as string
… would rather not cast it, but none of the other things I tried seemed to handle it.