Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(auth): redesign auth screens and enforce shared password policy (#7350)

Andrew Huang04665bc3f2b2
diff --git a/.gitignore b/.gitignore
index dc5f528060..bed5cdc34f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,3 +77,7 @@ upgrade-impact/.local-output/
/npm/bin
__pycache__
+
+# Local Codex design QA artifacts
+/.design-qa/
+/design-qa.md
diff --git a/DESIGN.md b/DESIGN.md
index a94b692741..d5cc723dc2 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -14,9 +14,10 @@ agents producing new UI or user-visible copy.
## 1. Visual Theme & Atmosphere
Infisical is a security tool for operators. The interface reads like
-infrastructure: dense, calm, and legible — never ornamental. Dark is the native
-medium; the page canvas is `--color-background`, and light themes are not part
-of the system yet.
+infrastructure: dense, calm, and legible. Decorative treatments are reserved
+for brand-forward surfaces such as authentication and onboarding; the core
+product remains utilitarian. Dark is the native medium; the page canvas is
+`--color-background`, and light themes are not part of the system yet.
Color carries **meaning before brand**. A danger badge is red because the
action is destructive, not because red is the accent. A project-colored button
@@ -32,8 +33,9 @@ values are masked by default; revealing one is an intentional act.
- Dark-native; `--color-background` page canvas
- Semantic-first color (danger / success / warning / info / neutral)
- Scope-aware (org / sub-org / project / admin)
-- Border-defined depth, no decorative shadows
-- Inter, one family, across everything
+- Border-defined depth; overlapping labels retain the shared Badge styling
+- Inter for product UI, Alliance for display typography, and distinct
+ functional and decorative monospace roles
- Secrets masked by default; reveal is an act
## 2. Color Palette & Roles
@@ -47,38 +49,38 @@ in this file.
Used to signal the scope a surface, badge, or action belongs to.
-| Scope | Token |
-| ---------------- | ------------------ |
-| Organization | `--color-org` |
-| Sub-Organization | `--color-sub-org` |
-| Project | `--color-project` |
-| Admin | `--color-admin` |
+| Scope | Token |
+| ---------------- | ----------------- |
+| Organization | `--color-org` |
+| Sub-Organization | `--color-sub-org` |
+| Project | `--color-project` |
+| Admin | `--color-admin` |
### Semantic colors
-| Intent | Token | Use |
-| -------- | ------------------ | ------------------------------------------------ |
-| Success | `--color-success` | Healthy states, completed rotations |
-| Info | `--color-info` | Informational states, external documentation |
-| Warning | `--color-warning` | Attention-warranting states, stale items |
-| Danger | `--color-danger` | Destructive actions, errors, expired access |
-| Neutral | `--color-neutral` | Disabled, muted, "empty" states |
+| Intent | Token | Use |
+| ------- | ----------------- | -------------------------------------------- |
+| Success | `--color-success` | Healthy states, completed rotations |
+| Info | `--color-info` | Informational states, external documentation |
+| Warning | `--color-warning` | Attention-warranting states, stale items |
+| Danger | `--color-danger` | Destructive actions, errors, expired access |
+| Neutral | `--color-neutral` | Disabled, muted, "empty" states |
### Surface & chrome
-| Role | Token |
-| ------------------ | ------------------------ |
-| Page background | `--color-background` |
-| Foreground text | `--color-foreground` |
-| Card surface | `--color-card` |
-| Popover / Sheet | `--color-popover` |
-| Container | `--color-container` |
-| Container (hover) | `--color-container-hover`|
-| Border | `--color-border` |
-| Focus ring | `--color-ring` |
-| Accent text | `--color-accent` |
-| Muted text | `--color-muted` |
-| Label text | `--color-label` |
+| Role | Token |
+| ----------------- | ------------------------- |
+| Page background | `--color-background` |
+| Foreground text | `--color-foreground` |
+| Card surface | `--color-card` |
+| Popover / Sheet | `--color-popover` |
+| Container | `--color-container` |
+| Container (hover) | `--color-container-hover` |
+| Border | `--color-border` |
+| Focus ring | `--color-ring` |
+| Accent text | `--color-accent` |
+| Muted text | `--color-muted` |
+| Label text | `--color-label` |
The `mineshaft-*` scale (50–900) is the underlying neutral ramp; see
`index.css` for the full list. Prefer semantic tokens (`card`, `border`,
@@ -104,19 +106,38 @@ never as solid fills. The two canonical recipes:
## 3. Typography
-Inter is the only font family (`--font-inter`). All weights and sizes use
-Tailwind's default scale.
-
-| Role | Class | Notes |
-| ------------------------ | --------------------------------------- | --------------------------------------------------------------------- |
-| Page title (h1) | `text-2xl font-medium underline underline-offset-4 decoration-<scope>/90` | In `PageHeader`; scope icon (size 26) sits inline before the title |
-| Page description | `text-mineshaft-300` | Sits under the title, `mt-1.5` |
-| Card title | `text-lg font-semibold leading-none` | `flex gap-1.5` so badges can sit inline |
-| Card description | `text-sm text-accent` | |
-| Body | `text-sm` | Default for table cells, form values, dialog content |
-| Label / meta | `text-xs text-accent` | Field labels, table column captions, metadata |
-| Badge | `text-xs` (auto, via `Badge`) | Never override |
-| Button | `text-sm` (md/sm/lg), `text-xs` (xs) | Auto via `Button` sizing |
+Typography uses several intentional families. Do not collapse them into one
+font or substitute one role for another:
+
+- **Inter** (`font-inter`, `--font-inter`) is the default product and control
+ face. Body copy, forms, tables, buttons, labels, navigation, and dense product
+ surfaces inherit Inter unless a documented role below applies.
+- **Alliance No. 2** (`font-alliance`, `--font-alliance`) is the display face.
+ Use it selectively for prominent authentication, onboarding, and
+ brand-forward headings or supporting display copy—not routine product chrome.
+- **The existing application mono** (`font-mono`) is functional. Preserve it
+ for code, secret values, identifiers, timestamps, logs, and other content
+ whose character shapes and alignment carry meaning.
+- **JetBrains Mono** (`font-jetbrains-mono`, `--font-jetbrains-mono`) is a
+ decorative mono. Use it for short eyebrow labels, technical decals, and
+ brand-forward microcopy. It does not replace `font-mono` and should not be
+ used for code editors, data tables, IDs, logs, or secret values.
+
+| Role | Class | Notes |
+| ---------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------ |
+| Page title (h1) | `text-2xl font-medium underline underline-offset-4 decoration-<scope>/90` | In `PageHeader`; scope icon (size 26) sits inline before the title |
+| Page description | `text-mineshaft-300` | Sits under the title, `mt-1.5` |
+| Card title | `text-lg font-semibold leading-none` | `flex gap-1.5` so badges can sit inline |
+| Card description | `text-sm text-accent` | |
+| Body | `text-sm` | Default for table cells, form values, dialog content |
+| Label / meta | `text-xs text-accent` | Field labels, table column captions, metadata |
+| Badge | `text-xs` (auto, via `Badge`) | Never override |
+| Button | `text-sm` (md/sm/lg), `text-xs` (xs) | Auto via `Button` sizing |
+
+On brand-forward surfaces, a short phrase may use the `text-highlight`
+utility to create the solid project-yellow text block. Keep the phrase short,
+use it as typographic emphasis rather than status or scope, and do not apply it
+inside routine product UI.
Sentence case for descriptions, helper text, and empty states. Title Case for
page titles, card titles, dialog titles, sheet titles, button labels, badge
@@ -153,70 +174,78 @@ variants, sizes, and class lists, open the source or its `*.stories.tsx`
— the stories are canonical.
#### Actions
-| Component | Reach for this when… |
-| --- | --- |
-| [`Button`](frontend/src/components/v3/generic/Button/Button.tsx) | A text-bearing button — primary or secondary action. |
-| [`IconButton`](frontend/src/components/v3/generic/IconButton/IconButton.tsx) | A square icon-only button — toolbars, row actions, compact triggers. Always `aria-label`. |
-| [`ButtonGroup`](frontend/src/components/v3/generic/ButtonGroup/ButtonGroup.tsx) | Visually join related controls — toolbars, segmented controls, split buttons, key-value chips. |
-| [`Dropdown`](frontend/src/components/v3/generic/Dropdown/Dropdown.tsx) | An action menu — overflow `⋯`, split-button alternates, contextual lists. |
+
+| Component | Reach for this when… |
+| ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [`Button`](frontend/src/components/v3/generic/Button/Button.tsx) | A text-bearing button — primary or secondary action. |
+| [`ButtonBadge`](frontend/src/components/v3/generic/Button/ButtonBadge.tsx) | A short decorative flag attached to a Button corner—such as "Last Used", "New", or "Recommended". It inherits Badge typography, sizing, radius, border, and casing; only its corner positioning and solidified semantic tint are specialized. |
+| [`IconButton`](frontend/src/components/v3/generic/IconButton/IconButton.tsx) | A square icon-only button — toolbars, row actions, compact triggers. Always `aria-label`. |
+| [`ButtonGroup`](frontend/src/components/v3/generic/ButtonGroup/ButtonGroup.tsx) | Visually join related controls — toolbars, segmented controls, split buttons, key-value chips. |
+| [`Dropdown`](frontend/src/components/v3/generic/Dropdown/Dropdown.tsx) | An action menu — overflow `⋯`, split-button alternates, contextual lists. |
#### Forms
-| Component | Reach for this when… |
-| --- | --- |
-| [`Field`](frontend/src/components/v3/generic/Field/Field.tsx) | Wrap every form control — label + control + description + error. **Never render a bare control in a form.** |
-| [`Label`](frontend/src/components/v3/generic/Label/Label.tsx) | Standalone form label outside a `Field`. |
-| [`Input`](frontend/src/components/v3/generic/Input/Input.tsx) / [`TextArea`](frontend/src/components/v3/generic/TextArea/TextArea.tsx) | Single-line / multi-line text entry. |
-| [`InputGroup`](frontend/src/components/v3/generic/InputGroup/InputGroup.tsx) | Input with left/right addons — search bars, prefixed values. |
-| [`Select`](frontend/src/components/v3/generic/Select/Select.tsx) / [`ReactSelect`](frontend/src/components/v3/generic/ReactSelect/index.ts) | Native-style dropdown / async or searchable dropdown. |
-| [`Switch`](frontend/src/components/v3/generic/Switch/Switch.tsx) / [`Checkbox`](frontend/src/components/v3/generic/Checkbox/Checkbox.tsx) | Boolean toggle / multi-select boolean. |
-| [`Calendar`](frontend/src/components/v3/generic/Calendar/Calendar.tsx) | Date / multi-date / range picker primitive. |
-| [`DateRangeFilter`](frontend/src/components/v3/generic/DateRangeFilter/DateRangeFilter.tsx) | Date-range filter with presets — for filter bars. |
-| [`SecretInput`](frontend/src/components/v3/generic/SecretInput/SecretInput.tsx) | Secret-value editor with mask toggle and `${var}` highlighting. |
-| [`PasswordGenerator`](frontend/src/components/v3/generic/PasswordGenerator/PasswordGenerator.tsx) | Generate a password against project secret-validation rules. |
+
+| Component | Reach for this when… |
+| ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
+| [`Field`](frontend/src/components/v3/generic/Field/Field.tsx) | Wrap every form control — label + control + description + error. **Never render a bare control in a form.** |
+| [`Label`](frontend/src/components/v3/generic/Label/Label.tsx) | Standalone form label outside a `Field`. |
+| [`Input`](frontend/src/components/v3/generic/Input/Input.tsx) / [`TextArea`](frontend/src/components/v3/generic/TextArea/TextArea.tsx) | Single-line / multi-line text entry. |
+| [`InputGroup`](frontend/src/components/v3/generic/InputGroup/InputGroup.tsx) | Input with left/right addons — search bars, prefixed values. |
+| [`Select`](frontend/src/components/v3/generic/Select/Select.tsx) / [`ReactSelect`](frontend/src/components/v3/generic/ReactSelect/index.ts) | Native-style dropdown / async or searchable dropdown. |
+| [`Switch`](frontend/src/components/v3/generic/Switch/Switch.tsx) / [`Checkbox`](frontend/src/components/v3/generic/Checkbox/Checkbox.tsx) | Boolean toggle / multi-select boolean. |
+| [`Calendar`](frontend/src/components/v3/generic/Calendar/Calendar.tsx) | Date / multi-date / range picker primitive. |
+| [`DateRangeFilter`](frontend/src/components/v3/generic/DateRangeFilter/DateRangeFilter.tsx) | Date-range filter with presets — for filter bars. |
+| [`SecretInput`](frontend/src/components/v3/generic/SecretInput/SecretInput.tsx) | Secret-value editor with mask toggle and `${var}` highlighting. |
+| [`PasswordGenerator`](frontend/src/components/v3/generic/PasswordGenerator/PasswordGenerator.tsx) | Generate a password against project secret-validation rules. |
#### Containers & overlays
-| Component | Reach for this when… |
-| --- | --- |
-| [`Card`](frontend/src/components/v3/generic/Card/Card.tsx) | Default section container — tables, filters, forms, empty states all live in a Card. |
-| [`Sheet`](frontend/src/components/v3/generic/Sheet/Sheet.tsx) | Right-side panel — **use for large create/edit forms** (multiple fields, multi-step, scrollable detail). |
-| [`Dialog`](frontend/src/components/v3/generic/Dialog/Dialog.tsx) | Centered modal — **use for small create/edit forms** (1–2 fields, single confirmation prompt) and short interactive prompts. |
-| [`AlertDialog`](frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx) | Confirm an action (destructive included). Replaces `confirm()`. |
-| [`Popover`](frontend/src/components/v3/generic/Popover/Popover.tsx) | Anchored floating panel — filters, pickers, contextual UI. |
-| [`Tooltip`](frontend/src/components/v3/generic/Tooltip/Tooltip.tsx) | Small floating annotation on hover/focus. |
-| [`Accordion`](frontend/src/components/v3/generic/Accordion/Accordion.tsx) | Collapsible sections. |
+
+| Component | Reach for this when… |
+| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
+| [`Card`](frontend/src/components/v3/generic/Card/Card.tsx) | Default section container — tables, filters, forms, empty states all live in a Card. |
+| [`Sheet`](frontend/src/components/v3/generic/Sheet/Sheet.tsx) | Right-side panel — **use for large create/edit forms** (multiple fields, multi-step, scrollable detail). |
+| [`Dialog`](frontend/src/components/v3/generic/Dialog/Dialog.tsx) | Centered modal — **use for small create/edit forms** (1–2 fields, single confirmation prompt) and short interactive prompts. |
+| [`AlertDialog`](frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx) | Confirm an action (destructive included). Replaces `confirm()`. |
+| [`Popover`](frontend/src/components/v3/generic/Popover/Popover.tsx) | Anchored floating panel — filters, pickers, contextual UI. |
+| [`Tooltip`](frontend/src/components/v3/generic/Tooltip/Tooltip.tsx) | Small floating annotation on hover/focus. |
+| [`Accordion`](frontend/src/components/v3/generic/Accordion/Accordion.tsx) | Collapsible sections. |
#### Data display
-| Component | Reach for this when… |
-| --- | --- |
-| [`Table`](frontend/src/components/v3/generic/Table/Table.tsx) | Read-mostly list of records with sortable columns. Pair with `Empty` + `Pagination`. |
-| [`DataGrid`](frontend/src/components/v3/generic/DataGrid/data-grid.tsx) | Editable spreadsheet-style grid — copy/paste, multi-cell selection, keyboard nav. Use only when `Table` isn't enough. |
-| [`Pagination`](frontend/src/components/v3/generic/Pagination/Pagination.tsx) | Page controls under a Table or list. |
-| [`Item`](frontend/src/components/v3/generic/Item/Item.tsx) | Vertically-stacked list rows with shared spacing — when a `Table` is too heavy. |
-| [`Detail`](frontend/src/components/v3/generic/Detail/Detail.tsx) | Read-only label/value pairs in a detail view. |
-| [`Badge`](frontend/src/components/v3/generic/Badge/Badge.tsx) | Small label or chip — status, scope tag, key/value pair. |
+
+| Component | Reach for this when… |
+| ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
+| [`Table`](frontend/src/components/v3/generic/Table/Table.tsx) | Read-mostly list of records with sortable columns. Pair with `Empty` + `Pagination`. |
+| [`DataGrid`](frontend/src/components/v3/generic/DataGrid/data-grid.tsx) | Editable spreadsheet-style grid — copy/paste, multi-cell selection, keyboard nav. Use only when `Table` isn't enough. |
+| [`Pagination`](frontend/src/components/v3/generic/Pagination/Pagination.tsx) | Page controls under a Table or list. |
+| [`Item`](frontend/src/components/v3/generic/Item/Item.tsx) | Vertically-stacked list rows with shared spacing — when a `Table` is too heavy. |
+| [`Detail`](frontend/src/components/v3/generic/Detail/Detail.tsx) | Read-only label/value pairs in a detail view. |
+| [`Badge`](frontend/src/components/v3/generic/Badge/Badge.tsx) | Small label or chip — status, scope tag, key/value pair. |
#### Navigation & search
-| Component | Reach for this when… |
-| --- | --- |
-| [`Sidebar`](frontend/src/components/v3/generic/Sidebar/Sidebar.tsx) | Scope-aware product navigation panel. |
+
+| Component | Reach for this when… |
+| ---------------------------------------------------------------------------- | ------------------------------------------------- |
+| [`Sidebar`](frontend/src/components/v3/generic/Sidebar/Sidebar.tsx) | Scope-aware product navigation panel. |
| [`Breadcrumb`](frontend/src/components/v3/generic/Breadcrumb/Breadcrumb.tsx) | Hierarchical location trail at the top of a page. |
-| [`Command`](frontend/src/components/v3/generic/Command/Command.tsx) | Search-driven command palette / typeahead list. |
+| [`Command`](frontend/src/components/v3/generic/Command/Command.tsx) | Search-driven command palette / typeahead list. |
#### Feedback & loading
-| Component | Reach for this when… |
-| --- | --- |
-| [`Alert`](frontend/src/components/v3/generic/Alert/Alert.tsx) | Inline message banner inside a page or Card. |
-| [`Toast`](frontend/src/components/v3/generic/Toast/Toast.tsx) | Transient post-action feedback. Replaces `alert()`. |
-| [`Empty`](frontend/src/components/v3/generic/Empty/Empty.tsx) | Zero-state placeholder — pair with Table, list, or empty filter. |
-| [`Skeleton`](frontend/src/components/v3/generic/Skeleton/Skeleton.tsx) | Shimmer placeholder while data is loading. |
-| [`PageLoader`](frontend/src/components/v3/generic/PageLoader/PageLoader.tsx) | Centered Lottie spinner for full-page loading. |
+
+| Component | Reach for this when… |
+| ---------------------------------------------------------------------------- | ---------------------------------------------------------------- |
+| [`Alert`](frontend/src/components/v3/generic/Alert/Alert.tsx) | Inline message banner inside a page or Card. |
+| [`Toast`](frontend/src/components/v3/generic/Toast/Toast.tsx) | Transient post-action feedback. Replaces `alert()`. |
+| [`Empty`](frontend/src/components/v3/generic/Empty/Empty.tsx) | Zero-state placeholder — pair with Table, list, or empty filter. |
+| [`Skeleton`](frontend/src/components/v3/generic/Skeleton/Skeleton.tsx) | Shimmer placeholder while data is loading. |
+| [`PageLoader`](frontend/src/components/v3/generic/PageLoader/PageLoader.tsx) | Centered Lottie spinner for full-page loading. |
#### Atoms & domain
-| Component | Reach for this when… |
-| --- | --- |
-| [`Separator`](frontend/src/components/v3/generic/Separator/Separator.tsx) | Horizontal/vertical divider. |
-| [`ScopeIcons`](frontend/src/components/v3/platform/ScopeIcons.tsx) | `OrgIcon` / `SubOrgIcon` / `ProjectIcon` / `InstanceIcon` — use when intent is scope. |
-| [`DocumentationLinkBadge`](frontend/src/components/v3/platform/DocumentationLinkBadge/DocumentationLinkBadge.tsx) | Inline "Documentation" link badge in `CardTitle`. |
+
+| Component | Reach for this when… |
+| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
+| [`Separator`](frontend/src/components/v3/generic/Separator/Separator.tsx) | Horizontal/vertical divider. |
+| [`ScopeIcons`](frontend/src/components/v3/platform/ScopeIcons.tsx) | `OrgIcon` / `SubOrgIcon` / `ProjectIcon` / `InstanceIcon` — use when intent is scope. |
+| [`DocumentationLinkBadge`](frontend/src/components/v3/platform/DocumentationLinkBadge/DocumentationLinkBadge.tsx) | Inline "Documentation" link badge in `CardTitle`. |
**Icons** — [`lucide-react`](https://lucide.dev). Sizing is bound by the
host component; don't override unless necessary.
@@ -228,6 +257,7 @@ host component; don't override unless necessary.
- **Section** — one `Card` per logical section. Title + optional `DocumentationLinkBadge` in `CardHeader`; primary action in `CardAction` (top-right).
- **Tables inside Cards** — filters and search sit in the `CardHeader` above the table; pagination sits in the `CardFooter` or bottom of `CardContent`. **Empty state** — when the table has no rows (and isn't loading), hide the `Table` entirely and render `Empty` in its place; never leave a column header floating above a blank body. Add `className="border"` to `Empty` whenever it's nested in a `Card`, `Sheet`, or `Dialog` so the dashed frame is visible against the parent surface (the component ships dashed-but-borderless on purpose for page-level use).
- **Forms inside Sheets/Dialog** — create / edit flows open in a Sheet or Dialog, never inline, never as a full-page route. **Pick by form size:** small forms (1–2 fields, e.g. "Add domain", "Rename") go in a centered `Dialog`; large or multi-step forms (multiple fields, scrollable detail, file uploads, wizard steps) go in a right-side `Sheet`. When in doubt, default to Dialog — Sheet is for cases where Dialog feels cramped.
+- **Authentication form stacks** — use `CardContent className="flex flex-col gap-4"` for the major vertical rhythm between fields, validation groups, and primary actions. Use a nested `flex flex-col gap-2` only for compact sets of equivalent actions such as social or SSO provider buttons. Use `FieldSeparator` between alternate authentication paths. Do not recreate sibling spacing with `mt-*`, `mb-*`, or `py-*`; keep a wrapper only when it owns animation, responsive visibility, conditional grouping, or tightly coupled control/error content.
- **Spacing rhythm** — `gap-1.5` (intra-element), `gap-2 / gap-3` (adjacent elements), `p-4 / p-5` (section padding). Card = `p-5 gap-5`; Sheet header/footer = `p-4`.
## 6. Depth & Elevation
@@ -235,17 +265,19 @@ host component; don't override unless necessary.
Depth is conveyed by layered surface tones and borders. Shadows are reserved
for elements that float (Popover, DropdownMenu, Sheet).
-| Layer | Surface | Border |
-| ------------------- | ------------------ | ------------- |
-| Page | `bg-bunker-800` | — |
-| Card | `bg-card` | `border-border` |
-| Popover / Sheet | `bg-popover` | `border-border` + `shadow-lg` |
-| Row hover | `bg-container-hover` | — |
-| Focus | — | 3px ring, `--color-ring` |
-| Disabled | `opacity-50 / 75`, `pointer-events-none` | — |
+| Layer | Surface | Border |
+| --------------- | ---------------------------------------- | ----------------------------- |
+| Page | `bg-bunker-800` | — |
+| Card | `bg-card` | `border-border` |
+| Popover / Sheet | `bg-popover` | `border-border` + `shadow-lg` |
+| Row hover | `bg-container-hover` | — |
+| Focus | — | 3px ring, `--color-ring` |
+| Disabled | `opacity-50 / 75`, `pointer-events-none` | — |
-Never add a box-shadow to a Card, Table row, or Badge; it breaks the
-border-defined system.
+Never add a box-shadow to a Card, Table row, standalone Badge, or `ButtonBadge`;
+it breaks the border-defined system. An overlapping `ButtonBadge` uses its
+solidified semantic tint—not custom content styling or elevation—to remain
+legible across the control edge.
## 7. Do's and Don'ts
@@ -267,7 +299,12 @@ border-defined system.
doesn't belong.
- **DON'T** use `project` yellow, `org` blue, or `sub-org` green as generic
accents. They are scope signals; repurposing them creates false hierarchy.
-- **DON'T** mix font families. Inter only.
+ The documented brand-forward `text-highlight` treatment and deliberately
+ branded `ButtonBadge` flags are narrow exceptions for authentication and
+ onboarding surfaces.
+- **DON'T** mix font families arbitrarily. Choose the documented role: Inter
+ for product UI, Alliance for display type, `font-mono` for functional
+ monospaced content, and JetBrains Mono for decorative technical microcopy.
- **DON'T** animate for decoration. Motion should clarify state change only.
## 8. Voice & Content Tone
@@ -326,12 +363,14 @@ Pasteable prompt fragments for AI coding agents producing new UI.
not by color preference.
**Adding a section to an existing page:**
+
> Wrap the section in a `Card` from `@app/components/v3`. Use `CardHeader`
> with `CardTitle` + optional `CardDescription` + `CardAction` for the
> top-right primary button (variant `project` on a project page). Put the
> table or content in `CardContent`.
**A new create/edit form:**
+
> Pick the container by form size. **Small forms (1–2 fields, e.g. "Add
> domain", "Rename"):** centered `Dialog` (`Dialog`, `DialogContent`,
> `DialogHeader` with `DialogTitle` + `DialogDescription`, `DialogFooter`
@@ -344,6 +383,7 @@ Pasteable prompt fragments for AI coding agents producing new UI.
> `org` / `sub-org`), cancel is `ghost`.
**A status indicator:**
+
> Use `Badge` from `@app/components/v3`. Pick the variant by intent:
> `danger` for errors or expired access, `warning` for stale or
> attention-warranting, `success` for healthy / completed, `info` for
@@ -352,11 +392,13 @@ Pasteable prompt fragments for AI coding agents producing new UI.
> first child.
**A destructive confirmation:**
+
> Use `AlertDialog`. Title: "Delete `<resource-name>`". Description: one
> sentence naming the consequence, ending with "This cannot be undone."
> Confirm button is variant `danger`. Cancel button is variant `outline`.
**A documentation link in a section:**
+
> Use `DocumentationLinkBadge` from `@app/components/v3/platform`. Place it
> in the `CardTitle` next to the section name.
diff --git a/backend/bdd/features/environment.py b/backend/bdd/features/environment.py
index 24baa5f0f4..38aa071cd4 100644
--- a/backend/bdd/features/environment.py
+++ b/backend/bdd/features/environment.py
@@ -43,7 +43,7 @@ def bootstrap_infisical(context: Context):
"/api/v1/admin/signup",
json={
"email": f"{faker.user_name()}@infisical.com",
- "password": faker.password(),
+ "password": "BddAdminPassword7!",
"firstName": faker.first_name(),
"lastName": faker.last_name(),
},
diff --git a/backend/src/db/seed-oidc.ts b/backend/src/db/seed-oidc.ts
index 6b8dd55eae..b16a8b46e6 100644
--- a/backend/src/db/seed-oidc.ts
+++ b/backend/src/db/seed-oidc.ts
@@ -25,6 +25,7 @@ import { kmsRootConfigDALFactory } from "@app/services/kms/kms-root-config-dal";
import { KmsDataKey } from "@app/services/kms/kms-types";
import { orgDALFactory } from "@app/services/org/org-dal";
import { superAdminDALFactory } from "@app/services/super-admin/super-admin-dal";
+import { UserAliasType } from "@app/services/user-alias/user-alias-types";
import { initDbConnection } from "./instance";
import { getMigrationEnvConfig, getMigrationHsmConfig } from "./migrations/utils/env-config";
@@ -33,6 +34,7 @@ import { AccessScope, OrgMembershipRole, OrgMembershipStatus, TableName } from "
const ONE_YEAR_MS = 365 * 24 * 60 * 60 * 1000;
const SUPER_ADMIN_CONFIG_ID = "00000000-0000-0000-0000-000000000000";
+const KEYCLOAK_ADMIN_EXTERNAL_ID = "00000000-0000-4000-8000-000000000003";
// Parameterized variant of seed-data#generateUserSrpKeys; the SRP verifier is bound to the
// username (the email here), so it can't be shared with the hardcoded seed user.
@@ -208,6 +210,20 @@ const main = async () => {
await db(TableName.MembershipRole).insert({ membershipId: membership.id, role: OrgMembershipRole.Admin });
}
+ // The local Keycloak realm gives its admin a stable subject ID. Seed the matching verified
+ // alias so the first OIDC login links to this already-verified admin instead of entering the
+ // email-verification signup flow. Replacing any previous alias also heals databases seeded
+ // before the realm subject became stable.
+ await db(TableName.UserAliases).where({ userId: user.id, orgId: org.id, aliasType: UserAliasType.OIDC }).del();
+ await db(TableName.UserAliases).insert({
+ userId: user.id,
+ aliasType: UserAliasType.OIDC,
+ externalId: KEYCLOAK_ADMIN_EXTERNAL_ID,
+ emails: [email],
+ orgId: org.id,
+ isEmailVerified: true
+ });
+
// Pre-verified email domain (plain insert; email_domains has no encrypted columns).
await db(TableName.EmailDomains).where({ orgId: org.id, domain }).del();
await db(TableName.EmailDomains).insert({
diff --git a/backend/src/lib/validator/password-policy.test.ts b/backend/src/lib/validator/password-policy.test.ts
new file mode 100644
index 0000000000..b207fbf5b0
--- /dev/null
+++ b/backend/src/lib/validator/password-policy.test.ts
@@ -0,0 +1,90 @@
+import { describe, expect, test } from "vitest";
+
+import {
+ doesPasswordMeetRequirement,
+ PASSWORD_POLICY,
+ PasswordPolicyConfigSchema,
+ PasswordPolicySchema
+} from "./password-policy";
+
+describe("PasswordPolicySchema", () => {
+ const validPassword = ["Horse", "Battery", 7].join("-");
+
+ test("accepts a strong password", () => {
+ expect(PasswordPolicySchema.safeParse(validPassword).success).toBe(true);
+ });
+
+ test.each([
+ "Short-7",
+ validPassword.slice(0, -2),
+ "a".repeat(101),
+ "12345678901234!",
+ "abcdefghijklmn",
+ "Password!!!!7",
+ "Strong😀😀😀😀7",
+ "Password\\escape7"
+ ])("rejects a password outside the policy: %s", (password) => {
+ expect(PasswordPolicySchema.safeParse(password).success).toBe(false);
+ });
+
+ test.each(["plan.organize7Beta", "[email protected]", "https://example.com/Secure7", "123-45-6789Strong"])(
+ "allows a strong password regardless of email-, URL-, or identifier-like content: %s",
+ (password) => {
+ expect(PasswordPolicySchema.safeParse(password).success).toBe(true);
+ }
+ );
+
+ test("does not trim passwords", () => {
+ const password = ` ${validPassword} `;
+ const result = PasswordPolicySchema.parse(password);
+
+ expect(result).toBe(password);
+ });
+
+ test("allows up to three repeated Unicode characters", () => {
+ expect(PasswordPolicySchema.safeParse("StrongPassword😀😀😀7").success).toBe(true);
+ });
+
+ test("counts astral Unicode characters as single password characters", () => {
+ const fewerThanFourteenCodePoints = "😀😃😄😁😆😅1a";
+ const fewerThanOneHundredCodePoints = `${"😀😃".repeat(24)}😀Aa7`;
+
+ expect(Array.from(fewerThanFourteenCodePoints)).toHaveLength(8);
+ expect(fewerThanFourteenCodePoints).toHaveLength(14);
+ expect(PasswordPolicySchema.safeParse(fewerThanFourteenCodePoints).success).toBe(false);
+
+ expect(Array.from(fewerThanOneHundredCodePoints)).toHaveLength(52);
+ expect(fewerThanOneHundredCodePoints.length).toBeGreaterThan(100);
+ expect(PasswordPolicySchema.safeParse(fewerThanOneHundredCodePoints).success).toBe(true);
+ });
+
+ test("exports Unicode-aware length requirements", () => {
+ expect(PASSWORD_POLICY.requirements[0].flags).toBe("u");
+ expect(PASSWORD_POLICY.requirements[1].flags).toBe("u");
+ });
+
+ test("preserves the public validation error copy", () => {
+ const result = PasswordPolicySchema.safeParse("Short-7");
+
+ expect(result.success).toBe(false);
+ if (result.success) throw new Error("Expected password validation to fail");
+ expect(result.error.issues[0]?.message).toBe("Password must contain at least 14 characters");
+ });
+
+ test.each([validPassword, "Short-7", "密码安全-7", "Password!!!!7"])(
+ "keeps the exported policy contract aligned with server validation: %s",
+ (password) => {
+ const meetsExportedPolicy = PASSWORD_POLICY.requirements.every((requirement) =>
+ doesPasswordMeetRequirement(password, requirement)
+ );
+
+ expect(PasswordPolicySchema.safeParse(password).success).toBe(meetsExportedPolicy);
+ }
+ );
+
+ test("exports a serializable policy contract", () => {
+ const serializedPolicy: unknown = JSON.parse(JSON.stringify(PASSWORD_POLICY));
+
+ expect(PasswordPolicyConfigSchema.parse(serializedPolicy)).toEqual(PASSWORD_POLICY);
+ });
+});
diff --git a/backend/src/lib/validator/password-policy.ts b/backend/src/lib/validator/password-policy.ts
new file mode 100644
index 0000000000..5eaa8ea287
--- /dev/null
+++ b/backend/src/lib/validator/password-policy.ts
@@ -0,0 +1,114 @@
+import RE2 from "re2";
+import { z } from "zod";
+
+export const PasswordPolicyRequirementSchema = z.object({
+ code: z.string(),
+ message: z.string(),
+ validationMessage: z.string(),
+ isPrimary: z.boolean(),
+ patterns: z.string().array().min(1),
+ flags: z.string().optional(),
+ maxConsecutiveCharacters: z.number().int().positive().optional(),
+ shouldMatch: z.boolean()
+});
+
+export const PasswordPolicyConfigSchema = z.object({
+ requirements: PasswordPolicyRequirementSchema.array().min(1)
+});
+
+export type TPasswordPolicyRequirement = z.infer<typeof PasswordPolicyRequirementSchema>;
+export type TPasswordPolicyConfig = z.infer<typeof PasswordPolicyConfigSchema>;
+
+export const PASSWORD_POLICY = {
+ requirements: [
+ {
+ code: "minimumLength",
+ patterns: [String.raw`^[\s\S]{14,}$`],
+ flags: "u",
+ shouldMatch: true,
+ message: "At least 14 characters",
+ validationMessage: "Password must contain at least 14 characters",
+ isPrimary: true
+ },
+ {
+ code: "maximumLength",
+ patterns: [String.raw`^[\s\S]{0,100}$`],
+ flags: "u",
+ shouldMatch: true,
+ message: "At most 100 characters",
+ validationMessage: "Password must contain at most 100 characters",
+ isPrimary: false
+ },
+ {
+ code: "letter",
+ patterns: [String.raw`\p{L}`],
+ flags: "u",
+ shouldMatch: true,
+ message: "At least 1 letter",
+ validationMessage: "Password must contain at least 1 letter",
+ isPrimary: true
+ },
+ {
+ code: "numberOrSpecial",
+ patterns: [String.raw`[\d!@#$%^&*(),.?":{}|<>]|[^\p{L}\p{N}\s]`],
+ flags: "u",
+ shouldMatch: true,
+ message: "At least 1 number or special character",
+ validationMessage: "Password must contain at least 1 number or special character",
+ isPrimary: true
+ },
+ {
+ code: "repeatedCharacters",
+ patterns: [String.raw`\s{4,}`],
+ maxConsecutiveCharacters: 3,
+ shouldMatch: false,
+ message: "No more than 3 repeated consecutive characters",
+ validationMessage: "Password cannot contain more than 3 repeated consecutive characters",
+ isPrimary: false
+ },
+ {
+ code: "escapeCharacters",
+ patterns: [String.raw`[\n\t\r\\]`],
+ shouldMatch: false,
+ message: "No escape characters",
+ validationMessage: "Password cannot contain escape characters",
+ isPrimary: false
+ }
+ ]
+} as const satisfies TPasswordPolicyConfig;
+
+const hasMoreThanMaxConsecutiveCharacters = (password: string, maxConsecutiveCharacters: number) => {
+ let previousCharacter: string | undefined;
+ let consecutiveCharacterCount = 0;
+
+ return Array.from(password).some((character) => {
+ if (character === previousCharacter) {
+ consecutiveCharacterCount += 1;
+ } else {
+ previousCharacter = character;
+ consecutiveCharacterCount = 1;
+ }
+
+ return consecutiveCharacterCount > maxConsecutiveCharacters;
+ });
+};
+
+export const doesPasswordMeetRequirement = (password: string, requirement: TPasswordPolicyRequirement) => {
+ const matches =
+ requirement.patterns.some((pattern) => new RE2(pattern, requirement.flags).test(password)) ||
+ (requirement.maxConsecutiveCharacters !== undefined &&
+ hasMoreThanMaxConsecutiveCharacters(password, requirement.maxConsecutiveCharacters));
+
+ return matches === requirement.shouldMatch;
+};
+
+export const PasswordPolicySchema = z.string().superRefine((password, context) => {
+ PASSWORD_POLICY.requirements.forEach((requirement) => {
+ if (!doesPasswordMeetRequirement(password, requirement)) {
+ context.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: requirement.validationMessage
+ });
+ }
+ });
+});
diff --git a/backend/src/server/routes/v1/admin-router.ts b/backend/src/server/routes/v1/admin-router.ts
index 6c96970c94..ecd14f40e6 100644
--- a/backend/src/server/routes/v1/admin-router.ts
+++ b/backend/src/server/routes/v1/admin-router.ts
@@ -13,6 +13,7 @@ import { LicenseType } from "@app/ee/services/license/license-types";
import { getConfig, overridableKeys } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError } from "@app/lib/errors";
+import { PASSWORD_POLICY, PasswordPolicyConfigSchema, PasswordPolicySchema } from "@app/lib/validator/password-policy";
import { invalidateCacheLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { addAuthOriginDomainCookie } from "@app/server/lib/cookie";
import { GenericResourceNameSchema } from "@app/server/lib/schemas";
@@ -61,7 +62,8 @@ const SanitizedSuperAdminSchema = z.object({
// Always returned
defaultAuthOrgSlug: z.string().nullable(),
defaultAuthOrgAuthEnforced: z.boolean().nullish(),
- defaultAuthOrgAuthMethod: z.string().nullish()
+ defaultAuthOrgAuthMethod: z.string().nullish(),
+ passwordPolicy: PasswordPolicyConfigSchema
});
export const registerAdminRouter = async (server: FastifyZodProvider) => {
@@ -102,6 +104,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
defaultAuthOrgAuthEnforced: config.defaultAuthOrgAuthEnforced,
defaultAuthOrgAuthMethod: config.defaultAuthOrgAuthMethod,
enabledLoginMethods: config.enabledLoginMethods,
+ passwordPolicy: PASSWORD_POLICY,
authConsentContent: config.authConsentContent,
pageFrameContent: config.pageFrameContent,
isPublicSecretSharingDisabled: serverEnvs.DISABLE_PUBLIC_SECRET_SHARING,
@@ -114,6 +117,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
return {
config: {
...config,
+ passwordPolicy: PASSWORD_POLICY,
fipsEnabled: crypto.isFipsModeEnabled(),
isMigrationModeOn: serverEnvs.MAINTENANCE_MODE,
isSecretScanningDisabled: serverEnvs.DISABLE_SECRET_SCANNING,
@@ -191,7 +195,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
},
handler: async (req) => {
const config = await server.services.superAdmin.updateServerCfg(req.body, req.permission.id);
- return { config };
+ return { config: { ...config, passwordPolicy: PASSWORD_POLICY } };
}
});
@@ -628,8 +632,8 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
operationId: "adminSignUp",
body: z.object({
email: z.string().email().trim(),
- password: z.string().trim(),
- firstName: z.string().trim(),
+ password: PasswordPolicySchema,
+ firstName: z.string().trim().min(1),
lastName: z.string().trim().optional()
}),
response: {
diff --git a/backend/src/server/routes/v1/password-router.ts b/backend/src/server/routes/v1/password-router.ts
index 03f030dda6..ce7e77ce9d 100644
--- a/backend/src/server/routes/v1/password-router.ts
+++ b/backend/src/server/routes/v1/password-router.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { getConfig } from "@app/lib/config/env";
+import { PasswordPolicySchema } from "@app/lib/validator/password-policy";
import { authRateLimit, smtpRateLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ActorType, AuthMode } from "@app/services/auth/auth-type";
@@ -41,7 +42,7 @@ export const registerPasswordRouter = async (server: FastifyZodProvider) => {
schema: {
operationId: "setupPassword",
body: z.object({
- password: z.string().trim(),
+ password: PasswordPolicySchema,
token: z.string().trim()
}),
response: {
diff --git a/backend/src/server/routes/v2/password-router.ts b/backend/src/server/routes/v2/password-router.ts
index 1d4dd8c598..b4d710ea40 100644
--- a/backend/src/server/routes/v2/password-router.ts
+++ b/backend/src/server/routes/v2/password-router.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { getConfig } from "@app/lib/config/env";
+import { PasswordPolicySchema } from "@app/lib/validator/password-policy";
import { authRateLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { validatePasswordResetAuthorization } from "@app/services/auth/auth-fns";
@@ -17,7 +18,7 @@ export const registerPasswordRouter = async (server: FastifyZodProvider) => {
schema: {
operationId: "resetPassword",
body: z.object({
- newPassword: z.string().trim()
+ newPassword: PasswordPolicySchema
})
},
handler: async (req) => {
@@ -39,7 +40,7 @@ export const registerPasswordRouter = async (server: FastifyZodProvider) => {
operationId: "resetUserPassword",
body: z.object({
oldPassword: z.string().trim(),
- newPassword: z.string().trim()
+ newPassword: PasswordPolicySchema
})
},
config: {
diff --git a/backend/src/server/routes/v3/signup-router.ts b/backend/src/server/routes/v3/signup-router.ts
index 563f1dbd1c..7e47219a4d 100644
--- a/backend/src/server/routes/v3/signup-router.ts
+++ b/backend/src/server/routes/v3/signup-router.ts
@@ -2,6 +2,7 @@ import { z } from "zod";
import { getConfig } from "@app/lib/config/env";
import { ForbiddenRequestError } from "@app/lib/errors";
+import { PasswordPolicySchema } from "@app/lib/validator/password-policy";
import { authRateLimit, smtpRateLimit } from "@app/server/config/rateLimiter";
import { addAuthOriginDomainCookie } from "@app/server/lib/cookie";
import { GenericResourceNameSchema } from "@app/server/lib/schemas";
@@ -107,7 +108,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
firstName: z.string().trim(),
lastName: z.string().trim().optional(),
attributionSource: z.string().trim().optional(),
- password: z.string(),
+ password: PasswordPolicySchema,
organizationName: GenericResourceNameSchema.optional(),
hubspotUtk: z.string().trim().max(512).optional()
}),
diff --git a/backend/src/services/auth/auth-fns.test.ts b/backend/src/services/auth/auth-fns.test.ts
new file mode 100644
index 0000000000..8041f23f69
--- /dev/null
+++ b/backend/src/services/auth/auth-fns.test.ts
@@ -0,0 +1,40 @@
+import { LoginMethod } from "../super-admin/super-admin-types";
+import { assertOAuthLoginMethodEnabled, isOAuthLoginMethodDisabled } from "./auth-fns";
+import { AuthMethod } from "./auth-type";
+
+describe("OAuth login method policy", () => {
+ test.each([
+ [AuthMethod.GOOGLE, LoginMethod.GOOGLE],
+ [AuthMethod.GITHUB, LoginMethod.GITHUB],
+ [AuthMethod.GITLAB, LoginMethod.GITLAB]
+ ] as const)("allows %s when it is enabled", (authMethod, loginMethod) => {
+ expect(isOAuthLoginMethodDisabled(authMethod, [loginMethod])).toBe(false);
+ expect(() => assertOAuthLoginMethodEnabled({ authMethod, enabledLoginMethods: [loginMethod] })).not.toThrow();
+ });
+
+ test.each([AuthMethod.GOOGLE, AuthMethod.GITHUB, AuthMethod.GITLAB] as const)(
+ "rejects disabled %s login before a user exists",
+ (authMethod) => {
+ expect(isOAuthLoginMethodDisabled(authMethod, [LoginMethod.EMAIL])).toBe(true);
+ expect(() => assertOAuthLoginMethodEnabled({ authMethod, enabledLoginMethods: [LoginMethod.EMAIL] })).toThrow(
+ /disabled by administrator/
+ );
+ }
+ );
+
+ test("preserves the existing organization-admin lockout bypass", () => {
+ expect(() =>
+ assertOAuthLoginMethodEnabled({
+ authMethod: AuthMethod.GOOGLE,
+ enabledLoginMethods: [LoginMethod.EMAIL],
+ canBypass: true
+ })
+ ).not.toThrow();
+ });
+
+ test("treats an unset allowlist as all methods enabled", () => {
+ expect(() =>
+ assertOAuthLoginMethodEnabled({ authMethod: AuthMethod.GOOGLE, enabledLoginMethods: null })
+ ).not.toThrow();
+ });
+});
diff --git a/backend/src/services/auth/auth-fns.ts b/backend/src/services/auth/auth-fns.ts
index 07bdf015e3..a18321f5ac 100644
--- a/backend/src/services/auth/auth-fns.ts
+++ b/backend/src/services/auth/auth-fns.ts
@@ -3,7 +3,53 @@ import { request } from "@app/lib/config/request";
import { crypto } from "@app/lib/crypto";
import { BadRequestError, ForbiddenRequestError, UnauthorizedError } from "@app/lib/errors";
-import { AuthModeAccountRecoveryTokenPayload, AuthModeSignUpTokenPayload, AuthTokenType, MfaMethod } from "./auth-type";
+import { LoginMethod } from "../super-admin/super-admin-types";
+import {
+ AuthMethod,
+ AuthModeAccountRecoveryTokenPayload,
+ AuthModeSignUpTokenPayload,
+ AuthTokenType,
+ MfaMethod
+} from "./auth-type";
+
+const oauthLoginMethods = {
+ [AuthMethod.GITHUB]: {
+ loginMethod: LoginMethod.GITHUB,
+ disabledMessage: "Login with Github is disabled by administrator."
+ },
+ [AuthMethod.GOOGLE]: {
+ loginMethod: LoginMethod.GOOGLE,
+ disabledMessage: "Login with Google is disabled by administrator."
+ },
+ [AuthMethod.GITLAB]: {
+ loginMethod: LoginMethod.GITLAB,
+ disabledMessage: "Login with Gitlab is disabled by administrator."
+ }
+} as const;
+
+export type OAuthAuthMethod = keyof typeof oauthLoginMethods;
+
+export const isOAuthLoginMethodDisabled = (
+ authMethod: OAuthAuthMethod,
+ enabledLoginMethods?: readonly string[] | null
+) => Boolean(enabledLoginMethods && !enabledLoginMethods.includes(oauthLoginMethods[authMethod].loginMethod));
+
+export const assertOAuthLoginMethodEnabled = ({
+ authMethod,
+ enabledLoginMethods,
+ canBypass = false
+}: {
+ authMethod: OAuthAuthMethod;
+ enabledLoginMethods?: readonly string[] | null;
+ canBypass?: boolean;
+}) => {
+ if (!isOAuthLoginMethodDisabled(authMethod, enabledLoginMethods) || canBypass) return;
+
+ throw new BadRequestError({
+ message: oauthLoginMethods[authMethod].disabledMessage,
+ name: "Oauth 2 login"
+ });
+};
/*
* Determines whether MFA is required and which method applies, based on org enforcement vs user
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index 2c2ae17511..e9b3d3f77f 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -52,7 +52,14 @@ import { TUserDALFactory } from "../user/user-dal";
import { TUserAliasDALFactory } from "../user-alias/user-alias-dal";
import { ensureSsoAccountVerified, isStaleSsoAlias } from "../user-alias/user-alias-fns";
import { UserAliasType } from "../user-alias/user-alias-types";
-import { enforceUserLockStatus, getRequiredMfaMethod, verifyCaptcha } from "./auth-fns";
+import {
+ assertOAuthLoginMethodEnabled,
+ enforceUserLockStatus,
+ getRequiredMfaMethod,
+ isOAuthLoginMethodDisabled,
+ OAuthAuthMethod,
+ verifyCaptcha
+} from "./auth-fns";
import {
TLoginClientProofDTO,
TLoginGenServerPublicKeyDTO,
@@ -812,52 +819,21 @@ export const authLoginServiceFactory = ({
const serverCfg = await getServerCfg();
- if (serverCfg.enabledLoginMethods && user) {
- switch (authMethod) {
- case AuthMethod.GITHUB: {
- if (!serverCfg.enabledLoginMethods.includes(LoginMethod.GITHUB)) {
- // bypass server configuration when user is an organization admin - this is to prevent lockout
- const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
- if (!userOrgs.some((org) => org.userRole === OrgMembershipRole.Admin)) {
- throw new BadRequestError({
- message: "Login with Github is disabled by administrator.",
- name: "Oauth 2 login"
- });
- }
- }
- break;
- }
- case AuthMethod.GOOGLE: {
- if (!serverCfg.enabledLoginMethods.includes(LoginMethod.GOOGLE)) {
- // bypass server configuration when user is an organization admin - this is to prevent lockout
- const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
- if (!userOrgs.some((org) => org.userRole === OrgMembershipRole.Admin)) {
- throw new BadRequestError({
- message: "Login with Google is disabled by administrator.",
- name: "Oauth 2 login"
- });
- }
- }
- break;
- }
- case AuthMethod.GITLAB: {
- if (!serverCfg.enabledLoginMethods.includes(LoginMethod.GITLAB)) {
- // bypass server configuration when user is an organization admin - this is to prevent lockout
- const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
- if (!userOrgs.some((org) => org.userRole === OrgMembershipRole.Admin)) {
- throw new BadRequestError({
- message: "Login with Gitlab is disabled by administrator.",
- name: "Oauth 2 login"
- });
- }
- }
- break;
- }
- default:
- break;
- }
+ const oauthAuthMethod = authMethod as OAuthAuthMethod;
+ let canBypassDisabledLoginMethod = false;
+
+ if (user && isOAuthLoginMethodDisabled(oauthAuthMethod, serverCfg.enabledLoginMethods)) {
+ // Existing organization admins retain access to prevent account lockout.
+ const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
+ canBypassDisabledLoginMethod = userOrgs.some((org) => org.userRole === OrgMembershipRole.Admin);
}
+ assertOAuthLoginMethodEnabled({
+ authMethod: oauthAuthMethod,
+ enabledLoginMethods: serverCfg.enabledLoginMethods,
+ canBypass: canBypassDisabledLoginMethod
+ });
+
const appCfg = getConfig();
let orgId = "";
diff --git a/docker/keycloak/realm-infisical.json b/docker/keycloak/realm-infisical.json
index 221570f0e1..f8a686394a 100644
--- a/docker/keycloak/realm-infisical.json
+++ b/docker/keycloak/realm-infisical.json
@@ -56,6 +56,7 @@
]
},
{
+ "id": "00000000-0000-4000-8000-000000000003",
"username": "admin",
"email": "[email protected]",
"firstName": "OIDC",
diff --git a/frontend/CLAUDE.md b/frontend/CLAUDE.md
index 870904356a..be22656b67 100644
--- a/frontend/CLAUDE.md
+++ b/frontend/CLAUDE.md
@@ -72,7 +72,7 @@ CASL-based (`@casl/ability`). Contexts: `OrgPermissionContext` and `ProjectPermi
### Styling
-Tailwind CSS v4 with PostCSS. Dark theme configured via CSS custom properties in `src/index.css` (@theme directive). Custom breakpoint `dashboard: 1100px`. Font: Inter. Color palette: primary (blue), mineshaft (dark gray), bunker (darker bg), success/warning/danger/info.
+Tailwind CSS v4 with PostCSS. Dark theme configured via CSS custom properties in `src/index.css` (`@theme` directive). Custom breakpoint `dashboard: 1100px`. Typography roles: Inter is the default product UI face, Alliance is the display face, `font-mono` remains the functional application mono, and `font-jetbrains-mono` is reserved for decorative technical microcopy. See the root `DESIGN.md` before assigning a non-default face. Color palette: primary (blue), mineshaft (dark gray), bunker (darker bg), success/warning/danger/info.
### Layouts
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 2a458c2d05..1fb7143fb3 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -23,6 +23,7 @@
"@dnd-kit/react": "^0.3.0",
"@dnd-kit/sortable": "^10.0.0",
"@fontsource/inter": "^5.1.0",
+ "@fontsource/jetbrains-mono": "^5.2.8",
"@fortawesome/fontawesome-svg-core": "^6.7.1",
"@fortawesome/free-brands-svg-icons": "^6.7.1",
"@fortawesome/free-regular-svg-icons": "^6.7.1",
@@ -1498,6 +1499,15 @@
"integrity": "sha512-zKZR3kf1G0noIes1frLfOHP5EXVVm0M7sV/l9f/AaYf+M/DId35FO4LkigWjqWYjTJZGgplhdv4cB+ssvCqr5A==",
"license": "OFL-1.1"
},
+ "node_modules/@fontsource/jetbrains-mono": {
+ "version": "5.2.8",
+ "resolved": "https://registry.npmjs.org/@fontsource/jetbrains-mono/-/jetbrains-mono-5.2.8.tgz",
+ "integrity": "sha512-6w8/SG4kqvIMu7xd7wt6x3idn1Qux3p9N62s6G3rfldOUYHpWcc2FKrqf+Vo44jRvqWj2oAtTHrZXEP23oSKwQ==",
+ "license": "OFL-1.1",
+ "funding": {
+ "url": "https://github.com/sponsors/ayuhito"
+ }
+ },
"node_modules/@fortawesome/fontawesome-common-types": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.7.1.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 14add30266..48672351c0 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -54,6 +54,7 @@
"@dnd-kit/react": "^0.3.0",
"@dnd-kit/sortable": "^10.0.0",
"@fontsource/inter": "^5.1.0",
+ "@fontsource/jetbrains-mono": "^5.2.8",
"@fortawesome/fontawesome-svg-core": "^6.7.1",
"@fortawesome/free-brands-svg-icons": "^6.7.1",
"@fortawesome/free-regular-svg-icons": "^6.7.1",
diff --git a/frontend/public/images/logotransparent.png b/frontend/public/images/logotransparent.png
index f6e4822b7b..ecadbfe499 100644
Binary files a/frontend/public/images/logotransparent.png and b/frontend/public/images/logotransparent.png differ
diff --git a/frontend/src/components/auth/AuthPageBackground.tsx b/frontend/src/components/auth/AuthPageBackground.tsx
index 775a072256..3eefb73eaf 100644
--- a/frontend/src/components/auth/AuthPageBackground.tsx
+++ b/frontend/src/components/auth/AuthPageBackground.tsx
@@ -1,91 +1,92 @@
/* eslint-disable react/no-array-index-key */
export const AuthPageBackground = () => (
- <div className="pointer-events-none absolute inset-0 flex flex-1 items-center justify-center overflow-hidden">
+ <div className="pointer-events-none absolute inset-0 overflow-hidden">
<svg
viewBox="0 0 800 800"
- className="h-[900px] w-[900px] opacity-[0.06]"
+ className="absolute top-1/2 -left-[360px] h-[720px] w-[720px] -translate-y-1/2 opacity-[0.06] xl:-left-[400px] xl:h-[800px] xl:w-[800px]"
fill="none"
xmlns="http://www.w3.org/2000/svg"
+ aria-hidden="true"
>
- <circle cx="400" cy="400" r="380" stroke="white" strokeWidth="2" />
- <circle cx="400" cy="400" r="370" stroke="white" strokeWidth="0.5" />
- {Array.from({ length: 24 }).map((_, i) => {
- const angle = (i * 15 * Math.PI) / 180;
- const x = 400 + 375 * Math.cos(angle);
- const y = 400 + 375 * Math.sin(angle);
- return <circle key={`bolt-${i}`} cx={x} cy={y} r="4" fill="white" />;
- })}
- <circle cx="400" cy="400" r="300" stroke="white" strokeWidth="1.5" />
- <circle cx="400" cy="400" r="290" stroke="white" strokeWidth="0.5" />
- {Array.from({ length: 60 }).map((_, i) => {
- const angle = (i * 6 * Math.PI) / 180;
- const innerR = i % 5 === 0 ? 280 : 285;
- const x1 = 400 + innerR * Math.cos(angle);
- const y1 = 400 + innerR * Math.sin(angle);
- const x2 = 400 + 290 * Math.cos(angle);
- const y2 = 400 + 290 * Math.sin(angle);
- return (
- <line
- key={`tick-${i}`}
- x1={x1}
- y1={y1}
- x2={x2}
- y2={y2}
- stroke="white"
- strokeWidth={i % 5 === 0 ? "1.5" : "0.5"}
- />
- );
- })}
- <circle cx="400" cy="400" r="200" stroke="white" strokeWidth="1" />
- <circle cx="400" cy="400" r="195" stroke="white" strokeWidth="0.3" />
- {Array.from({ length: 8 }).map((_, i) => {
- const angle = (i * 45 * Math.PI) / 180;
- const x1 = 400 + 200 * Math.cos(angle);
- const y1 = 400 + 200 * Math.sin(angle);
- const x2 = 400 + 300 * Math.cos(angle);
- const y2 = 400 + 300 * Math.sin(angle);
- return (
- <line
- key={`spoke-${i}`}
- x1={x1}
- y1={y1}
- x2={x2}
- y2={y2}
- stroke="white"
- strokeWidth="3"
- strokeLinecap="round"
- />
- );
- })}
- <circle cx="400" cy="400" r="100" stroke="white" strokeWidth="2" />
- <circle cx="400" cy="400" r="80" stroke="white" strokeWidth="0.5" />
- <circle cx="400" cy="400" r="15" fill="white" />
- <line
- x1="320"
- y1="400"
- x2="480"
- y2="400"
- stroke="white"
- strokeWidth="4"
- strokeLinecap="round"
- />
- <line
- x1="400"
- y1="320"
- x2="400"
- y2="480"
- stroke="white"
- strokeWidth="4"
- strokeLinecap="round"
- />
- <line x1="50" y1="50" x2="150" y2="50" stroke="white" strokeWidth="1" />
- <line x1="50" y1="50" x2="50" y2="150" stroke="white" strokeWidth="1" />
- <line x1="750" y1="50" x2="650" y2="50" stroke="white" strokeWidth="1" />
- <line x1="750" y1="50" x2="750" y2="150" stroke="white" strokeWidth="1" />
- <line x1="50" y1="750" x2="150" y2="750" stroke="white" strokeWidth="1" />
- <line x1="50" y1="750" x2="50" y2="650" stroke="white" strokeWidth="1" />
- <line x1="750" y1="750" x2="650" y2="750" stroke="white" strokeWidth="1" />
- <line x1="750" y1="750" x2="750" y2="650" stroke="white" strokeWidth="1" />
+ <g className="[transform-origin:400px_400px] motion-safe:animate-[spin_140s_linear_infinite]">
+ <circle cx="400" cy="400" r="380" stroke="white" strokeWidth="2" />
+ <circle cx="400" cy="400" r="370" stroke="white" strokeWidth="0.5" />
+ {Array.from({ length: 24 }).map((_, i) => {
+ const angle = (i * 15 * Math.PI) / 180;
+ const x = 400 + 375 * Math.cos(angle);
+ const y = 400 + 375 * Math.sin(angle);
+ return <circle key={`bolt-${i}`} cx={x} cy={y} r="4" fill="white" />;
+ })}
+ </g>
+ <g className="[transform-origin:400px_400px] motion-safe:animate-[spin_95s_linear_infinite_reverse]">
+ <circle cx="400" cy="400" r="300" stroke="white" strokeWidth="1.5" />
+ <circle cx="400" cy="400" r="290" stroke="white" strokeWidth="0.5" />
+ {Array.from({ length: 60 }).map((_, i) => {
+ const angle = (i * 6 * Math.PI) / 180;
+ const innerR = i % 5 === 0 ? 280 : 285;
+ const x1 = 400 + innerR * Math.cos(angle);
+ const y1 = 400 + innerR * Math.sin(angle);
+ const x2 = 400 + 290 * Math.cos(angle);
+ const y2 = 400 + 290 * Math.sin(angle);
+ return (
+ <line
+ key={`tick-${i}`}
+ x1={x1}
+ y1={y1}
+ x2={x2}
+ y2={y2}
+ stroke="white"
+ strokeWidth={i % 5 === 0 ? "1.5" : "0.5"}
+ />
+ );
+ })}
+ </g>
+ <g className="[transform-origin:400px_400px] motion-safe:animate-[spin_70s_linear_infinite]">
+ <circle cx="400" cy="400" r="200" stroke="white" strokeWidth="1" />
+ <circle cx="400" cy="400" r="195" stroke="white" strokeWidth="0.3" />
+ {Array.from({ length: 8 }).map((_, i) => {
+ const angle = (i * 45 * Math.PI) / 180;
+ const x1 = 400 + 200 * Math.cos(angle);
+ const y1 = 400 + 200 * Math.sin(angle);
+ const x2 = 400 + 300 * Math.cos(angle);
+ const y2 = 400 + 300 * Math.sin(angle);
+ return (
+ <line
+ key={`spoke-${i}`}
+ x1={x1}
+ y1={y1}
+ x2={x2}
+ y2={y2}
+ stroke="white"
+ strokeWidth="3"
+ strokeLinecap="round"
+ />
+ );
+ })}
+ </g>
+ <g className="[transform-origin:400px_400px] motion-safe:animate-[spin_45s_linear_infinite_reverse]">
+ <circle cx="400" cy="400" r="100" stroke="white" strokeWidth="2" />
+ <circle cx="400" cy="400" r="80" stroke="white" strokeWidth="0.5" />
+ <circle cx="400" cy="400" r="15" fill="white" />
+ <line
+ x1="320"
+ y1="400"
+ x2="480"
+ y2="400"
+ stroke="white"
+ strokeWidth="4"
+ strokeLinecap="round"
+ />
+ <line
+ x1="400"
+ y1="320"
+ x2="400"
+ y2="480"
+ stroke="white"
+ strokeWidth="4"
+ strokeLinecap="round"
+ />
+ </g>
</svg>
</div>
);
diff --git a/frontend/src/components/auth/AuthPageFooter.tsx b/frontend/src/components/auth/AuthPageFooter.tsx
index 7f28f4ea22..bd11fc6541 100644
--- a/frontend/src/components/auth/AuthPageFooter.tsx
+++ b/frontend/src/components/auth/AuthPageFooter.tsx
@@ -1,13 +1,17 @@
export const AuthPageFooter = () => (
- <footer className="relative z-10 mt-[14px] py-6 text-center">
- <div className="mb-3 flex items-center justify-center gap-4">
+ <footer className="mt-5 flex flex-col-reverse items-center justify-between gap-3 border-t border-border pt-5 text-center sm:flex-row sm:text-left">
+ <p className="text-[11px] text-muted">
+ &copy; {new Date().getFullYear()} Infisical Inc. All rights reserved.
+ </p>
+ <nav aria-label="Infisical social links" className="flex items-center justify-center gap-3">
<a
href="https://x.com/infisical"
target="_blank"
rel="noopener noreferrer"
- className="text-mineshaft-400 transition-colors hover:text-white"
+ aria-label="Infisical on X"
+ className="text-muted transition-colors hover:text-foreground"
>
- <svg className="size-4" fill="currentColor" viewBox="0 0 24 24">
+ <svg className="size-3.5" fill="currentColor" viewBox="0 0 24 24">
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" />
</svg>
</a>
@@ -15,9 +19,10 @@ export const AuthPageFooter = () => (
href="https://www.linkedin.com/company/infisical/"
target="_blank"
rel="noopener noreferrer"
- className="text-mineshaft-400 transition-colors hover:text-white"
+ aria-label="Infisical on LinkedIn"
+ className="text-muted transition-colors hover:text-foreground"
>
- <svg className="size-4" fill="currentColor" viewBox="0 0 24 24">
+ <svg className="size-3.5" fill="currentColor" viewBox="0 0 24 24">
<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" />
</svg>
</a>
@@ -25,15 +30,13 @@ export const AuthPageFooter = () => (
href="https://www.youtube.com/@infisical_os"
target="_blank"
rel="noopener noreferrer"
- className="text-mineshaft-400 transition-colors hover:text-white"
+ aria-label="Infisical on YouTube"
+ className="text-muted transition-colors hover:text-foreground"
>
- <svg className="size-4" fill="currentColor" viewBox="0 0 24 24">
+ <svg className="size-3.5" fill="currentColor" viewBox="0 0 24 24">
<path d="M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z" />
</svg>
</a>
- </div>
- <p className="text-xs text-mineshaft-400">
- &copy; {new Date().getFullYear()} Infisical Inc. All rights reserved.
- </p>
+ </nav>
</footer>
);
diff --git a/frontend/src/components/auth/AuthPageLayout.tsx b/frontend/src/components/auth/AuthPageLayout.tsx
new file mode 100644
index 0000000000..ff1f3ea05c
--- /dev/null
+++ b/frontend/src/components/auth/AuthPageLayout.tsx
@@ -0,0 +1,87 @@
+import { ReactNode } from "react";
+import { BookOpen } from "lucide-react";
+
+import { Button } from "@app/components/v3";
+import { cn } from "@app/components/v3/utils";
+
+import { AuthPageBackground } from "./AuthPageBackground";
+import { AuthPageFooter } from "./AuthPageFooter";
+import { AuthPageHeader } from "./AuthPageHeader";
+
+type Props = {
+ bottomContent?: ReactNode;
+ children: ReactNode;
+ contentClassName?: string;
+ headerAction?: ReactNode;
+ showFooter?: boolean;
+ variant?: "focused" | "split";
+};
+
+export const AuthPageLayout = ({
+ bottomContent,
+ children,
+ contentClassName,
+ headerAction,
+ showFooter = true,
+ variant = "split"
+}: Props) => {
+ const isSplit = variant === "split";
+
+ return (
+ <div
+ className={cn(
+ "min-h-screen bg-linear-to-r from-card to-bunker-900 to-75%",
+ isSplit &&
+ "lg:grid lg:grid-cols-[minmax(440px,44%)_minmax(0,1fr)] xl:grid-cols-[minmax(520px,40%)_minmax(0,1fr)]"
+ )}
+ data-variant={variant}
+ >
+ <section
+ className={cn(
+ "flex h-screen min-h-0 min-w-0 flex-col overflow-y-auto px-5 sm:px-8 lg:px-10 xl:px-14",
+ isSplit && "lg:border-r lg:border-border"
+ )}
+ >
+ <AuthPageHeader>{headerAction}</AuthPageHeader>
+ <main className="flex flex-1 items-center justify-center py-10">
+ <div className={cn("w-full max-w-md", contentClassName)}>{children}</div>
+ </main>
+ {(bottomContent || showFooter) && (
+ <div className="relative z-10 pb-6 text-center">
+ {bottomContent}
+ {showFooter && <AuthPageFooter />}
+ </div>
+ )}
+ </section>
+
+ {isSplit && (
+ <aside className="relative hidden h-screen min-w-0 overflow-hidden lg:sticky lg:top-0 lg:flex lg:flex-col">
+ <AuthPageBackground />
+ <div className="relative z-10 flex h-16 items-center justify-end px-8 xl:px-12">
+ <Button asChild variant="outline" size="sm">
+ <a href="https://infisical.com/docs" target="_blank" rel="noopener noreferrer">
+ <BookOpen />
+ Documentation
+ </a>
+ </Button>
+ </div>
+
+ <div className="relative z-10 flex flex-1 items-center justify-center px-10 pb-16 xl:px-20">
+ <div className="max-w-xl">
+ <p className="mb-4 font-jetbrains-mono text-xs tracking-[0.02em] text-project uppercase">
+ Trusted by 400,000+ developers
+ </p>
+ <h2 className="font-alliance text-3xl leading-tight font-normal text-foreground xl:text-4xl">
+ The <span className="text-highlight">all-in-one</span> security stack for developers
+ and AI agents.
+ </h2>
+ <p className="mt-4 max-w-lg font-alliance text-sm leading-relaxed text-label xl:text-base">
+ One place to audit every credential your apps and agents use.
+ </p>
+ </div>
+ </div>
+ </aside>
+ )}
+ </div>
+ );
+};
diff --git a/frontend/src/components/auth/AuthPagePanel.tsx b/frontend/src/components/auth/AuthPagePanel.tsx
new file mode 100644
index 0000000000..4a89cedaff
--- /dev/null
+++ b/frontend/src/components/auth/AuthPagePanel.tsx
@@ -0,0 +1,16 @@
+import { ComponentProps } from "react";
+
+import { Card } from "@app/components/v3";
+import { cn } from "@app/components/v3/utils";
+
+type AuthPagePanelProps = ComponentProps<typeof Card>;
+
+export const AuthPagePanel = ({ className, ...props }: AuthPagePanelProps) => (
+ <Card
+ className={cn(
+ "mx-auto w-full max-w-none items-stretch gap-0 border-0 bg-transparent p-0 shadow-none",
+ className
+ )}
+ {...props}
+ />
+);
diff --git a/frontend/src/components/auth/CodeInputStep.tsx b/frontend/src/components/auth/CodeInputStep.tsx
index 7e88f87283..07471d6ed6 100644
--- a/frontend/src/components/auth/CodeInputStep.tsx
+++ b/frontend/src/components/auth/CodeInputStep.tsx
@@ -1,62 +1,33 @@
-/* eslint-disable react/jsx-props-no-spreading */
-import { useEffect, useRef, useState } from "react";
-import ReactCodeInput from "react-code-input";
+import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
-import { Link } from "@tanstack/react-router";
import axios from "axios";
-import { Button, Card, CardContent, CardHeader, CardTitle, FieldError } from "@app/components/v3";
+import {
+ Button,
+ CardContent,
+ VerificationCodeForm,
+ VerificationCodeHeader,
+ VerificationCodeResend
+} from "@app/components/v3";
import { useSendVerificationEmail, useVerifySignupEmailVerificationCode } from "@app/hooks/api";
import SecurityClient from "../utilities/SecurityClient";
-
-const codeInputStyle = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "55px",
- borderRadius: "6px",
- fontSize: "24px",
- height: "55px",
- paddingLeft: "7",
- backgroundColor: "transparent",
- color: "#ebebeb",
- border: "1px solid #2b2c30",
- textAlign: "center",
- outlineColor: "#2d2f33",
- borderColor: "#2b2c30"
- }
-} as const;
-const codeInputStylePhone = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "40px",
- borderRadius: "6px",
- fontSize: "24px",
- height: "40px",
- paddingLeft: "7",
- backgroundColor: "transparent",
- color: "#ebebeb",
- border: "1px solid #2b2c30",
- textAlign: "center",
- outlineColor: "#2d2f33",
- borderColor: "#2b2c30"
- }
-} as const;
+import { AuthPagePanel } from "./AuthPagePanel";
interface CodeInputStepProps {
email: string;
onComplete: () => void;
- initialCooldown: number;
+ onChangeEmail: () => void;
+ resendCooldownEndTime: number;
+ onResendCooldownChange: (endTime: number) => void;
}
export default function CodeInputStep({
email,
onComplete,
- initialCooldown
+ onChangeEmail,
+ resendCooldownEndTime,
+ onResendCooldownChange
}: CodeInputStepProps): JSX.Element {
const { mutateAsync: resendEmail, isPending: isResending } = useSendVerificationEmail();
const {
@@ -69,7 +40,6 @@ export default function CodeInputStep({
const [code, setCode] = useState("");
- const endTimeRef = useRef<number>(initialCooldown > 0 ? Date.now() + initialCooldown * 1000 : 0);
const [, forceRender] = useState(0);
// Tick every second
@@ -81,9 +51,7 @@ export default function CodeInputStep({
return () => clearInterval(timer);
}, []);
- const remainingCooldown = Math.max(0, Math.ceil((endTimeRef.current - Date.now()) / 1000));
-
- const isCooldownActive = endTimeRef.current > Date.now();
+ const remainingCooldown = Math.max(0, Math.ceil((resendCooldownEndTime - Date.now()) / 1000));
const handleVerify = async () => {
const { token } = await verifyCode({ email, code });
@@ -94,97 +62,57 @@ export default function CodeInputStep({
const handleResend = async () => {
try {
const { cooldownSeconds } = await resendEmail({ email });
- endTimeRef.current = Date.now() + cooldownSeconds * 1000;
+ onResendCooldownChange(Date.now() + cooldownSeconds * 1000);
} catch (err) {
if (axios.isAxiosError(err)) {
const remaining = err.response?.data?.details?.cooldownSeconds;
if (typeof remaining === "number") {
- endTimeRef.current = Date.now() + remaining * 1000;
+ onResendCooldownChange(Date.now() + remaining * 1000);
}
}
}
};
- let resendLabel = t("signup.step2-resend-submit");
- if (isResending) {
- resendLabel = t("signup.step2-resend-progress");
- } else if (remainingCooldown > 0) {
- resendLabel = `${t("signup.step2-resend-submit")} (${remainingCooldown}s)`;
- }
-
return (
<div className="mx-auto flex w-full flex-col items-center justify-center">
- <Card className="mx-auto w-full max-w-md items-stretch gap-0 p-6">
- <CardHeader className="mb-2 gap-2">
- <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-[1.55rem] font-medium text-transparent">
- {t("signup.step2-message")}
- </CardTitle>
- </CardHeader>
+ <AuthPagePanel>
+ <VerificationCodeHeader
+ title={t("signup.step2-message")}
+ recipient={email}
+ action={
+ <button
+ aria-label={`Change email address from ${email}`}
+ className="shrink-0 cursor-pointer text-sm text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ onClick={onChangeEmail}
+ type="button"
+ >
+ Change
+ </button>
+ }
+ />
<CardContent>
- <p className="text-md my-1 flex justify-center font-medium text-foreground">{email}</p>
- <div className="mx-auto hidden w-max min-w-[20rem] md:block">
- <ReactCodeInput
- name=""
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setCode}
- {...codeInputStyle}
- className="code-input-v3 mt-6 mb-2"
+ <VerificationCodeForm
+ name="verification-code"
+ value={code}
+ onChange={setCode}
+ onSubmit={handleVerify}
+ submitLabel={String(t("signup.verify"))}
+ isPending={isVerifying}
+ error={isCodeError ? t("signup.step2-code-error") : undefined}
+ >
+ <VerificationCodeResend
+ isResending={isResending}
+ remainingSeconds={remainingCooldown}
+ onResend={handleResend}
/>
- </div>
- <div className="mx-auto mt-4 block w-max md:hidden">
- <ReactCodeInput
- name=""
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setCode}
- {...codeInputStylePhone}
- className="code-input-v3 mt-2 mb-2"
- />
- </div>
- {isCodeError && <FieldError>{t("signup.step2-code-error")}</FieldError>}
- <div className="mt-4 w-full">
- <Button
- type="submit"
- onClick={handleVerify}
- variant="project"
- size="lg"
- isFullWidth
- isPending={isVerifying}
- isDisabled={isVerifying}
- >
- {String(t("signup.verify"))}
- </Button>
- </div>
- <div className="mt-6 flex flex-col items-center gap-2 text-xs text-label">
- <div className="flex flex-row items-baseline gap-1">
- <button
- disabled={isResending || isCooldownActive}
- onClick={handleResend}
- type="button"
- >
- <span
- className={
- remainingCooldown > 0
- ? "text-label/60"
- : "cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2"
- }
- >
- {t("signup.step2-resend-alert")} {resendLabel}
- </span>
- </button>
- </div>
- <Link
- to="/login"
- className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2"
- >
- Have an account? Log in
- </Link>
- </div>
+ {import.meta.env.DEV && (
+ <Button variant="ghost" size="sm" isFullWidth onClick={onComplete}>
+ Preview next step (development only)
+ </Button>
+ )}
+ </VerificationCodeForm>
</CardContent>
- </Card>
+ </AuthPagePanel>
</div>
);
}
diff --git a/frontend/src/components/auth/EnterEmailStep.tsx b/frontend/src/components/auth/EnterEmailStep.tsx
index 732bfdbfbb..da2f933fcd 100644
--- a/frontend/src/components/auth/EnterEmailStep.tsx
+++ b/frontend/src/components/auth/EnterEmailStep.tsx
@@ -3,17 +3,11 @@ import { useTranslation } from "react-i18next";
import { Link } from "@tanstack/react-router";
import { z } from "zod";
-import {
- Button,
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- FieldError,
- Input
-} from "@app/components/v3";
+import { Button, CardContent, CardHeader, CardTitle, FieldError, Input } from "@app/components/v3";
import { useSendVerificationEmail } from "@app/hooks/api";
+import { AuthPagePanel } from "./AuthPagePanel";
+
interface DownloadBackupPDFStepProps {
incrementStep: () => void;
email: string;
@@ -61,14 +55,14 @@ export default function EnterEmailStep({
return (
<div className="mx-auto flex w-full flex-col items-center justify-center">
- <Card className="mx-auto w-full max-w-sm items-stretch gap-0 p-6">
+ <AuthPagePanel>
<CardHeader className="mb-4 gap-4">
<CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.65rem] font-medium text-transparent">
{t("signup.step1-start")}
</CardTitle>
</CardHeader>
- <CardContent>
- <div className="w-full">
+ <CardContent className="flex flex-col gap-4">
+ <div className="flex w-full flex-col gap-2">
<Input
placeholder="Enter your email address..."
onChange={(e) => setEmail(e.target.value)}
@@ -80,20 +74,18 @@ export default function EnterEmailStep({
/>
{emailError && <FieldError>Please enter a valid email.</FieldError>}
</div>
- <div className="mt-4 w-full">
- <Button
- type="submit"
- onClick={emailCheck}
- variant="project"
- size="lg"
- isFullWidth
- isDisabled={isPending}
- isPending={isPending}
- >
- {String(t("signup.step1-submit"))}
- </Button>
- </div>
- <div className="mt-6 flex w-full justify-center text-xs text-label">
+ <Button
+ type="submit"
+ onClick={emailCheck}
+ variant="project"
+ size="lg"
+ isFullWidth
+ isDisabled={isPending}
+ isPending={isPending}
+ >
+ {String(t("signup.step1-submit"))}
+ </Button>
+ <div className="flex w-full justify-center text-xs text-label">
<Link to="/login">
<span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
{t("signup.already-have-account")}
@@ -101,7 +93,7 @@ export default function EnterEmailStep({
</Link>
</div>
</CardContent>
- </Card>
+ </AuthPagePanel>
</div>
);
}
diff --git a/frontend/src/components/auth/InitialSignupStep.tsx b/frontend/src/components/auth/InitialSignupStep.tsx
index 2d467d9db4..2621ed93fb 100644
--- a/frontend/src/components/auth/InitialSignupStep.tsx
+++ b/frontend/src/components/auth/InitialSignupStep.tsx
@@ -3,18 +3,18 @@ import { useTranslation } from "react-i18next";
import { faGithub, faGitlab, faGoogle } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link } from "@tanstack/react-router";
-import { CircleChevronRightIcon } from "lucide-react";
import { z } from "zod";
import { RegionSelect } from "@app/components/navigation/RegionSelect";
import {
Button,
- Card,
+ ButtonBadge,
CardAction,
CardContent,
+ CardDescription,
CardHeader,
CardTitle,
- FieldError,
+ FieldSeparator,
Input
} from "@app/components/v3";
import { useServerConfig } from "@app/context";
@@ -22,22 +22,28 @@ import { preserveHubSpotUtk } from "@app/helpers/utmTracking";
import { useSendVerificationEmail } from "@app/hooks/api";
import { LoginMethod } from "@app/hooks/api/admin/types";
+import { AuthPagePanel } from "./AuthPagePanel";
+
interface InitialSignupStepProps {
email: string;
setEmail: (value: string) => void;
-
- incrementStep: (cooldownSeconds: number) => void;
+ incrementStep: (email: string, cooldownSeconds: number) => void;
+ pendingVerificationEmail?: string;
+ onResumeVerification: () => void;
}
export default function InitialSignupStep({
email,
setEmail,
- incrementStep
+ incrementStep,
+ pendingVerificationEmail,
+ onResumeVerification
}: InitialSignupStepProps) {
const { t } = useTranslation();
const { config } = useServerConfig();
const { mutateAsync, isPending } = useSendVerificationEmail();
const [emailError, setEmailError] = useState(false);
+ const isEmailValid = z.string().email().safeParse(email).success;
const shouldDisplaySignupMethod = (method: LoginMethod) =>
!config.enabledLoginMethods || config.enabledLoginMethods.includes(method);
@@ -56,9 +62,16 @@ export default function InitialSignupStep({
}
setEmailError(false);
- const { cooldownSeconds } = await mutateAsync({ email: email.toLowerCase() });
- setEmail(email.toLowerCase());
- incrementStep(cooldownSeconds);
+ const normalizedEmail = email.toLowerCase();
+
+ if (normalizedEmail === pendingVerificationEmail) {
+ setEmail(normalizedEmail);
+ onResumeVerification();
+ return;
+ }
+
+ const { cooldownSeconds } = await mutateAsync({ email: normalizedEmail });
+ incrementStep(normalizedEmail, cooldownSeconds);
};
const handleSocialSignup = (method: LoginMethod) => {
@@ -71,27 +84,31 @@ export default function InitialSignupStep({
return (
<div className="mx-auto flex w-full flex-col items-center justify-center">
- <Card className="mx-auto w-full max-w-sm items-stretch gap-0 p-6">
- <CardHeader className="mb-4 gap-4">
- <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.65rem] font-medium text-transparent">
- {t("signup.initial-title")}
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2">
+ <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
+ Sign up
</CardTitle>
+ <CardDescription className="ml-0.5 text-base">
+ Create your Infisical account
+ </CardDescription>
<CardAction className="-mr-2">
<RegionSelect compact />
</CardAction>
</CardHeader>
- <CardContent>
+ <CardContent className="flex flex-col gap-4">
<div className="flex w-full flex-col gap-2">
{shouldDisplaySignupMethod(LoginMethod.GITHUB) && (
<Button
aria-label="Continue with GitHub"
- variant="project"
+ variant="outline"
size="lg"
isFullWidth
onClick={() => handleSocialSignup(LoginMethod.GITHUB)}
>
- <FontAwesomeIcon icon={faGithub} className="!size-4" />
+ <FontAwesomeIcon icon={faGithub} />
Continue with GitHub
+ <ButtonBadge variant="project">Recommended</ButtonBadge>
</Button>
)}
{shouldDisplaySignupMethod(LoginMethod.GOOGLE) && (
@@ -102,7 +119,7 @@ export default function InitialSignupStep({
isFullWidth
onClick={() => handleSocialSignup(LoginMethod.GOOGLE)}
>
- <FontAwesomeIcon icon={faGoogle} className="!size-4" />
+ <FontAwesomeIcon icon={faGoogle} />
{t("signup.continue-with-google")}
</Button>
)}
@@ -114,93 +131,51 @@ export default function InitialSignupStep({
isFullWidth
onClick={() => handleSocialSignup(LoginMethod.GITLAB)}
>
- <FontAwesomeIcon icon={faGitlab} className="!size-4" />
+ <FontAwesomeIcon icon={faGitlab} />
Continue with GitLab
</Button>
)}
</div>
{hasSsoSignupMethod && shouldDisplaySignupMethod(LoginMethod.EMAIL) && (
- <div className="my-4 flex w-full flex-row items-center py-2">
- <div className="w-full border-t border-mineshaft-400/60" />
- <span className="mx-2 text-xs text-mineshaft-400">or</span>
- <div className="w-full border-t border-mineshaft-400/60" />
- </div>
+ <FieldSeparator>or</FieldSeparator>
)}
{shouldDisplaySignupMethod(LoginMethod.EMAIL) && (
- <>
- <div className="w-full">
- <Input
- value={email}
- onChange={(e) => setEmail(e.target.value)}
- type="email"
- placeholder="Enter your email..."
- required
- autoComplete="username"
- className="h-10"
- isError={emailError}
- />
- {emailError && <FieldError>Please enter a valid email.</FieldError>}
- </div>
- <div className="mt-4 w-full">
- <Button
- type="submit"
- onClick={handleEmailSignup}
- variant="outline"
- size="lg"
- isFullWidth
- isDisabled={isPending}
- isPending={isPending}
- >
- Continue with Email
- </Button>
- </div>
- </>
+ <div className="flex w-full flex-col gap-4">
+ <Input
+ value={email}
+ onChange={(e) => {
+ setEmail(e.target.value);
+ setEmailError(false);
+ }}
+ type="email"
+ placeholder="[email protected]"
+ required
+ autoComplete="username"
+ className="h-10"
+ isError={emailError}
+ />
+ <Button
+ type="submit"
+ onClick={handleEmailSignup}
+ variant="project"
+ size="lg"
+ isFullWidth
+ isDisabled={!isEmailValid || isPending}
+ isPending={isPending}
+ >
+ Continue with Email
+ </Button>
+ </div>
)}
- <p className="mt-4 text-center text-xs text-pretty text-label">
- By signing up, you agree to our{" "}
- <a
- href="https://infisical.com/terms/cloud"
- target="_blank"
- rel="noopener noreferrer"
- className="cursor-pointer underline underline-offset-2 duration-200 hover:text-foreground hover:decoration-project/45"
- >
- Terms of Service
- </a>{" "}
- and{" "}
- <a
- href="https://infisical.com/privacy"
- target="_blank"
- rel="noopener noreferrer"
- className="cursor-pointer underline underline-offset-2 duration-200 hover:text-foreground hover:decoration-project/45"
- >
- Privacy Policy
- </a>
- .
- </p>
</CardContent>
- </Card>
- <div className="mt-6 w-full max-w-sm rounded-lg bg-background">
- <a
- href="https://infisical.com/talk-to-us?utm_source=signup&utm_medium=referral"
- target="_blank"
- rel="noopener noreferrer"
- className="flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg border border-project/35 bg-project/10 px-4 py-3 text-foreground transition-colors hover:border-project/40 hover:bg-project/15"
- >
- <span className="min-w-0 flex-1 text-xs text-foreground/75">
- Have a complex company use case?{" "}
- <span className="font-medium">
- Get <span className="text-white/90">Enterprise grade</span> assistance
- </span>
- </span>
- <CircleChevronRightIcon className="size-4.5 opacity-75" />
- </a>
- </div>
- <div className="mt-4 flex flex-row items-center justify-center gap-1.5 text-sm">
+ </AuthPagePanel>
+ <div className="mt-3 flex items-center justify-center gap-1.5 text-sm">
<span className="text-label">Already have an account?</span>
- <Link to="/login">
- <span className="cursor-pointer text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project">
- Log in
- </span>
+ <Link
+ to="/login"
+ className="text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ >
+ Log in
</Link>
</div>
</div>
diff --git a/frontend/src/components/auth/Mfa.tsx b/frontend/src/components/auth/Mfa.tsx
index e76f0b0c9e..d309fefa8b 100644
--- a/frontend/src/components/auth/Mfa.tsx
+++ b/frontend/src/components/auth/Mfa.tsx
@@ -1,14 +1,21 @@
-import React, { useEffect, useRef, useState } from "react";
-import ReactCodeInput from "react-code-input";
+import { useEffect, useRef, useState } from "react";
import { startAuthentication } from "@simplewebauthn/browser";
-import { Link, useNavigate } from "@tanstack/react-router";
+import { useNavigate } from "@tanstack/react-router";
import { t } from "i18next";
import Error from "@app/components/basic/Error";
import { MfaEnrollment } from "@app/components/mfa/MfaEnrollment";
import { createNotification } from "@app/components/notifications";
import SecurityClient from "@app/components/utilities/SecurityClient";
-import { Button, Tooltip } from "@app/components/v2";
+import { Tooltip } from "@app/components/v2";
+import {
+ Button,
+ CardContent,
+ useClientResendDelay,
+ VerificationCodeForm,
+ VerificationCodeHeader,
+ VerificationCodeResend
+} from "@app/components/v3";
import { isInfisicalCloud } from "@app/helpers/platform";
import { useActivateMfa, useLogoutUser, useSendMfaToken } from "@app/hooks/api";
import {
@@ -23,59 +30,26 @@ import { fetchUserDetails } from "@app/hooks/api/users/queries";
import { useGenerateAuthenticationOptions, useVerifyAuthentication } from "@app/hooks/api/webauthn";
import { RecoveryCodesStep } from "../mfa/setup";
+import { AuthPageLayout } from "./AuthPageLayout";
+import { AuthPagePanel } from "./AuthPagePanel";
const MAX_MFA_ATTEMPTS = 5;
-
-// The style for the verification code input
-const codeInputProps = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "55px",
- borderRadius: "5px",
- fontSize: "24px",
- height: "55px",
- paddingLeft: "7",
- backgroundColor: "#0d1117",
- color: "white",
- border: "1px solid #2d2f33",
- textAlign: "center",
- outlineColor: "#8ca542",
- borderColor: "#2d2f33"
- }
-} as const;
-
-const codeInputPropsPhone = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "40px",
- borderRadius: "5px",
- fontSize: "24px",
- height: "40px",
- paddingLeft: "7",
- backgroundColor: "#0d1117",
- color: "white",
- border: "1px solid #2d2f33",
- textAlign: "center",
- outlineColor: "#8ca542",
- borderColor: "#2d2f33"
- }
-} as const;
+const CLIENT_RESEND_DELAY_SECONDS = 20;
type Props = {
successCallback: () => void | Promise<void>;
closeMfa?: () => void;
- hideLogo?: boolean;
email: string;
method: MfaMethod;
+ onChangeAccount?: () => void | Promise<void>;
};
-export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Props) => {
+export const Mfa = ({ successCallback, closeMfa, email, method, onChangeAccount }: Props) => {
const [mfaCode, setMfaCode] = useState("");
const [showRecoveryCodeInput, setShowRecoveryCodeInput] = useState(false);
+ const resendDelay = useClientResendDelay(
+ method === MfaMethod.EMAIL ? CLIENT_RESEND_DELAY_SECONDS : 0
+ );
const navigate = useNavigate();
const [isLoading, setIsLoading] = useState(false);
const [isLoadingResend, setIsLoadingResend] = useState(false);
@@ -172,9 +146,7 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
await completeLogin();
};
- const verifyMfa = async (event: React.FormEvent<HTMLFormElement>) => {
- event.preventDefault();
-
+ const verifyMfa = async () => {
if (!mfaCode.trim() || !isCodeComplete) return;
setIsLoading(true);
@@ -223,6 +195,7 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
try {
setIsLoadingResend(true);
await sendMfaToken.mutateAsync({ email });
+ resendDelay.restartDelay();
setIsLoadingResend(false);
} catch (err) {
console.error(err);
@@ -310,28 +283,30 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
if (newRecoveryCodes) {
return (
- <div className="mx-auto flex w-full max-w-md flex-col gap-4 pt-4 pb-4 md:mb-16 md:px-8">
- <RecoveryCodesStep
- recoveryCodes={newRecoveryCodes}
- acknowledgment={{
- isAcknowledged: hasSavedRecoveryCodes,
- onAcknowledgedChange: setHasSavedRecoveryCodes,
- confirmLabel: "Continue",
- isConfirmPending: isLoading,
- labelClassName: "text-bunker-200",
- onConfirm: async () => {
- setIsLoading(true);
- await completeLogin();
- }
- }}
- />
- </div>
+ <AuthPageLayout variant="focused" showFooter={false}>
+ <div className="mx-auto flex w-full max-w-md flex-col gap-4">
+ <RecoveryCodesStep
+ recoveryCodes={newRecoveryCodes}
+ acknowledgment={{
+ isAcknowledged: hasSavedRecoveryCodes,
+ onAcknowledgedChange: setHasSavedRecoveryCodes,
+ confirmLabel: "Continue",
+ isConfirmPending: isLoading,
+ labelClassName: "text-bunker-200",
+ onConfirm: async () => {
+ setIsLoading(true);
+ await completeLogin();
+ }
+ }}
+ />
+ </div>
+ </AuthPageLayout>
);
}
if (shouldShowTotpRegistration || shouldShowWebAuthnRegistration) {
return (
- <div className="mx-auto w-max pt-4 pb-4 md:mb-16 md:px-8">
+ <AuthPageLayout variant="focused" showFooter={false} contentClassName="max-w-xl">
<MfaEnrollment
method={method}
onComplete={async () => {
@@ -340,217 +315,141 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
await successCallback();
}}
/>
- </div>
+ </AuthPageLayout>
);
}
- return (
- <div className="mx-auto w-max pt-6 pb-6 md:mb-16 md:px-8">
- {!hideLogo && (
- <Link to="/">
- <div className="mb-4 flex justify-center">
- <img src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical logo" />
- </div>
- </Link>
- )}
- {method === MfaMethod.EMAIL &&
- (showRecoveryCodeInput ? (
- <div className="mb-8 text-center">
- <h2 className="mb-3 text-xl font-medium text-bunker-100">Two-Factor Authentication</h2>
- <p className="mx-auto max-w-md text-sm leading-relaxed text-bunker-300">
- Enter one of your backup recovery codes
- </p>
- </div>
- ) : (
- <>
- <p className="text-l flex justify-center text-bunker-300">{t("mfa.step2-message")}</p>
- <p className="text-l my-1 flex justify-center font-medium text-bunker-300">{email}</p>
- </>
- ))}
- {method === MfaMethod.TOTP && (
- <div className="mb-8 text-center">
- <h2 className="mb-3 text-xl font-medium text-bunker-100">Two-Factor Authentication</h2>
- <p className="mx-auto max-w-md text-sm leading-relaxed text-bunker-300">
- {showRecoveryCodeInput
- ? "Enter one of your backup recovery codes"
- : "Enter the verification code from your authenticator app"}
- </p>
- </div>
- )}
- {method === MfaMethod.WEBAUTHN && (
- <div className="mb-8 text-center">
- <h2 className="mb-3 text-xl font-medium text-bunker-100">Passkey Authentication</h2>
- <p className="mx-auto max-w-md text-sm leading-relaxed text-bunker-300">
- {showRecoveryCodeInput
- ? "Enter one of your backup recovery codes"
- : "Use your registered passkey to complete two-factor authentication"}
- </p>
- </div>
- )}
- {method === MfaMethod.WEBAUTHN && !showRecoveryCodeInput ? (
- <>
- {typeof triesLeft === "number" && (
- <Error text={`Failed authentication. You have ${triesLeft} attempt(s) remaining.`} />
- )}
- <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">
- <Button
- size="md"
- onClick={handleWebAuthnVerification}
- isFullWidth
- className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"
- colorSchema="primary"
- variant="outline_bg"
- isLoading={isLoading}
- isDisabled={typeof triesLeft === "number" && triesLeft <= 0}
- >
- Authenticate with Passkey
- </Button>
- </div>
- </>
+ let headerTitle = "Two-factor authentication";
+ let headerDescription: string | undefined;
+ let headerRecipient: string | undefined;
+
+ if (showRecoveryCodeInput) {
+ headerDescription = "Enter one of your backup recovery codes.";
+ } else if (method === MfaMethod.EMAIL) {
+ headerTitle = String(t("mfa.step2-message"));
+ headerRecipient = email;
+ } else if (method === MfaMethod.TOTP) {
+ headerDescription = "Enter the verification code from your authenticator app.";
+ } else if (method === MfaMethod.WEBAUTHN) {
+ headerTitle = "Passkey authentication";
+ headerDescription = "Use your registered passkey to continue.";
+ }
+
+ const recoveryActions = (
+ <div className="flex flex-wrap items-center gap-x-4 gap-y-2 text-sm">
+ {showRecoveryCodeInput ? (
+ <Tooltip
+ position="bottom"
+ content={
+ <div className="max-w-xs text-center text-xs">
+ {isInfisicalCloud() ? (
+ <>
+ <div className="mb-2">Account Recovery Required</div>
+ <div className="mb-2 text-gray-300">
+ Contact support with valid proof of account ownership to initiate recovery
+ </div>
+ <div className="mt-1">[email protected]</div>
+ </>
+ ) : (
+ <>
+ <div className="mb-2">Account Recovery Required</div>
+ <div className="text-gray-300">
+ Contact your instance administrator with valid proof of account ownership to
+ initiate recovery
+ </div>
+ </>
+ )}
+ </div>
+ }
+ >
+ <span className="cursor-help text-label transition-colors duration-200 hover:text-foreground">
+ Lost your recovery codes?
+ </span>
+ </Tooltip>
) : (
- <form onSubmit={verifyMfa}>
- <div className="mx-auto hidden md:block" style={{ minWidth: "600px" }}>
- {method === MfaMethod.EMAIL && (
- <div className="flex justify-center">
- <ReactCodeInput
- key={showRecoveryCodeInput ? "recovery" : "email"}
- name=""
- inputMode="tel"
- type="text"
- fields={showRecoveryCodeInput ? 8 : 6}
- onChange={setMfaCode}
- className="mt-6 mb-2"
- {...codeInputProps}
- />
- </div>
- )}
- {(method === MfaMethod.TOTP || method === MfaMethod.WEBAUTHN) && (
- <div className="mt-8 mb-6 flex justify-center">
- <ReactCodeInput
- key={showRecoveryCodeInput ? "recovery" : "totp"}
- name=""
- inputMode="tel"
- type="text"
- fields={showRecoveryCodeInput ? 8 : 6}
- onChange={setMfaCode}
- className="mb-2"
- {...codeInputProps}
- />
- </div>
- )}
- </div>
- <div className="mx-auto mt-4 block md:hidden" style={{ minWidth: "400px" }}>
- {method === MfaMethod.EMAIL && (
- <div className="flex justify-center">
- <ReactCodeInput
- key={showRecoveryCodeInput ? "recovery-mobile" : "email-mobile"}
- name=""
- inputMode="tel"
- type="text"
- fields={showRecoveryCodeInput ? 8 : 6}
- onChange={setMfaCode}
- className="mt-2 mb-2"
- {...codeInputPropsPhone}
- />
- </div>
- )}
- {(method === MfaMethod.TOTP || method === MfaMethod.WEBAUTHN) && (
- <div className="mt-4 mb-6 flex justify-center">
- <ReactCodeInput
- key={showRecoveryCodeInput ? "recovery-mobile" : "totp-mobile"}
- name=""
- inputMode="tel"
- type="text"
- fields={showRecoveryCodeInput ? 8 : 6}
- onChange={setMfaCode}
- className="mb-2"
- {...codeInputPropsPhone}
- />
- </div>
- )}
- </div>
- {typeof triesLeft === "number" && (
- <Error text={`Invalid code. You have ${triesLeft} attempt(s) remaining.`} />
- )}
- <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">
- <Button
- size="md"
- type="submit"
- isFullWidth
- className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"
- colorSchema="primary"
- variant="outline_bg"
- isLoading={isLoading}
- isDisabled={!isCodeComplete || (typeof triesLeft === "number" && triesLeft <= 0)}
- >
- {String(t("mfa.verify"))}
- </Button>
- </div>
- </form>
+ method === MfaMethod.EMAIL && (
+ <VerificationCodeResend
+ isResending={isLoadingResend}
+ remainingSeconds={resendDelay.remainingSeconds}
+ onResend={handleResendMfaCode}
+ />
+ )
)}
- {method === MfaMethod.EMAIL && !showRecoveryCodeInput && (
- <div className="mx-auto flex max-h-24 w-full max-w-md flex-col items-center justify-center pt-2">
- <div className="flex flex-row items-baseline gap-1 text-sm">
- <span className="text-bunker-400">{t("signup.step2-resend-alert")}</span>
- <div className="text-md mt-2 flex flex-row text-bunker-400">
- <button disabled={isLoadingResend} onClick={handleResendMfaCode} type="button">
- <span className="cursor-pointer duration-200 hover:text-bunker-200 hover:underline hover:decoration-primary-700 hover:underline-offset-4">
- {isLoadingResend
- ? t("signup.step2-resend-progress")
- : t("signup.step2-resend-submit")}
- </span>
+ <button
+ type="button"
+ onClick={() => {
+ setShowRecoveryCodeInput(!showRecoveryCodeInput);
+ setMfaCode("");
+ }}
+ className="ml-auto cursor-pointer text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ >
+ {getRecoveryToggleLabel()}
+ </button>
+ </div>
+ );
+
+ return (
+ <AuthPageLayout variant="focused" showFooter={false}>
+ <AuthPagePanel>
+ <VerificationCodeHeader
+ title={headerTitle}
+ recipient={headerRecipient}
+ description={headerDescription}
+ action={
+ onChangeAccount ? (
+ <button
+ aria-label={`Sign out ${email}`}
+ className="shrink-0 cursor-pointer text-sm text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ onClick={onChangeAccount}
+ type="button"
+ >
+ Sign out
</button>
+ ) : undefined
+ }
+ />
+ <CardContent>
+ {method === MfaMethod.WEBAUTHN && !showRecoveryCodeInput ? (
+ <div className="flex flex-col gap-5">
+ {typeof triesLeft === "number" && (
+ <Error
+ text={`Failed authentication. You have ${triesLeft} attempt(s) remaining.`}
+ />
+ )}
+ <Button
+ size="lg"
+ onClick={handleWebAuthnVerification}
+ isFullWidth
+ variant="project"
+ isPending={isLoading}
+ isDisabled={typeof triesLeft === "number" && triesLeft <= 0}
+ >
+ Authenticate with passkey
+ </Button>
+ {recoveryActions}
</div>
- </div>
- <p className="pb-2 text-sm text-bunker-400">{t("signup.step2-spam-alert")}</p>
- </div>
- )}
- {(method === MfaMethod.EMAIL ||
- method === MfaMethod.TOTP ||
- method === MfaMethod.WEBAUTHN) && (
- <div className="mt-6 flex flex-col items-center gap-4 text-sm">
- <button
- type="button"
- onClick={() => {
- setShowRecoveryCodeInput(!showRecoveryCodeInput);
- setMfaCode("");
- }}
- className="text-bunker-400 transition-colors duration-200 hover:text-bunker-200 hover:underline hover:decoration-primary-700 hover:underline-offset-4"
- >
- {getRecoveryToggleLabel()}
- </button>
- <div className="text-center text-sm">
- <Tooltip
- position="bottom"
- content={
- <div className="max-w-xs text-center text-xs">
- {isInfisicalCloud() ? (
- <>
- <div className="mb-2">Account Recovery Required</div>
- <div className="mb-2 text-gray-300">
- Contact support with valid proof of account ownership to initiate recovery
- </div>
- <div className="mt-1">[email protected]</div>
- </>
- ) : (
- <>
- <div className="mb-2">Account Recovery Required</div>
- <div className="text-gray-300">
- Contact your instance administrator with valid proof of account ownership to
- initiate recovery
- </div>
- </>
- )}
- </div>
+ ) : (
+ <VerificationCodeForm
+ key={showRecoveryCodeInput ? "recovery" : method}
+ name="mfa-code"
+ fields={showRecoveryCodeInput ? 8 : 6}
+ value={mfaCode}
+ onChange={setMfaCode}
+ onSubmit={verifyMfa}
+ submitLabel={String(t("mfa.verify"))}
+ isPending={isLoading}
+ isDisabled={typeof triesLeft === "number" && triesLeft <= 0}
+ error={
+ typeof triesLeft === "number"
+ ? `Invalid code. You have ${triesLeft} attempt(s) remaining.`
+ : undefined
}
>
- <span className="cursor-help text-bunker-400 transition-colors duration-200 hover:text-bunker-200">
- Lost your recovery codes?
- </span>
- </Tooltip>
- </div>
- </div>
- )}
- </div>
+ {recoveryActions}
+ </VerificationCodeForm>
+ )}
+ </CardContent>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/components/auth/PasswordField.tsx b/frontend/src/components/auth/PasswordField.tsx
new file mode 100644
index 0000000000..e9390d3394
--- /dev/null
+++ b/frontend/src/components/auth/PasswordField.tsx
@@ -0,0 +1,114 @@
+import { useMemo, useState } from "react";
+import { FieldError as ReactHookFormFieldError, UseFormRegisterReturn } from "react-hook-form";
+import { Check, Eye, EyeOff, LoaderCircle, X } from "lucide-react";
+
+import { getPasswordRequirements } from "@app/components/utilities/checks/password/passwordPolicy";
+import { PasswordBreachCheckStatus } from "@app/components/utilities/checks/password/usePasswordBreachCheck";
+import {
+ AnimatedCollapse,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput
+} from "@app/components/v3";
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
+
+type PasswordFieldProps = {
+ id: string;
+ value: string;
+ policy: TPasswordPolicy;
+ breachStatus: PasswordBreachCheckStatus;
+ registration: UseFormRegisterReturn;
+ placeholder?: string;
+ error?: ReactHookFormFieldError;
+ submitCount: number;
+};
+
+export const PasswordField = ({
+ id,
+ value,
+ policy,
+ breachStatus,
+ registration,
+ placeholder,
+ error,
+ submitCount
+}: PasswordFieldProps) => {
+ const [isFocused, setIsFocused] = useState(false);
+ const [showPassword, setShowPassword] = useState(false);
+ const requirements = useMemo(() => getPasswordRequirements(value, policy), [policy, value]);
+ const visibleRequirements = requirements.filter(({ isMet, isPrimary }) => isPrimary || !isMet);
+ const showRequirements = value.length > 0;
+
+ const requirementsId = `${id}-requirements`;
+
+ return (
+ <Field data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor={id}>Password</FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ {...registration}
+ id={id}
+ type={showPassword ? "text" : "password"}
+ placeholder={placeholder}
+ autoComplete="new-password"
+ aria-invalid={Boolean(error)}
+ aria-describedby={showRequirements ? requirementsId : undefined}
+ onFocus={() => setIsFocused(true)}
+ onBlur={(event) => {
+ registration.onBlur(event);
+ setIsFocused(false);
+ }}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ onClick={() => setShowPassword((current) => !current)}
+ aria-label={showPassword ? "Hide password" : "Show password"}
+ >
+ {showPassword ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ <AnimatedCollapse isOpen={showRequirements}>
+ <div id={requirementsId} className="flex flex-col gap-1 pt-1" aria-live="polite">
+ {visibleRequirements.map(({ code, isMet, message }) => (
+ <div className="flex items-start gap-2 text-xs" key={code}>
+ {isMet ? (
+ <Check className="mt-0.5 size-3.5 shrink-0 text-success" />
+ ) : (
+ <X
+ className={`mt-0.5 size-3.5 shrink-0 ${
+ !isFocused && submitCount > 0 ? "text-danger" : "text-muted"
+ }`}
+ />
+ )}
+ <span className={isMet ? "text-muted" : "text-accent"}>{message}</span>
+ </div>
+ ))}
+ {breachStatus === "checking" && (
+ <FieldDescription className="flex items-center gap-2">
+ <LoaderCircle className="size-3.5 animate-spin" /> Checking known data breaches…
+ </FieldDescription>
+ )}
+ {breachStatus === "safe" && (
+ <FieldDescription className="flex items-center gap-2 text-success">
+ <Check className="size-3.5" /> No known data breach matches found.
+ </FieldDescription>
+ )}
+ {breachStatus === "breached" && (
+ <FieldError>This password was found in a known data breach.</FieldError>
+ )}
+ {breachStatus === "unavailable" && (
+ <FieldDescription>
+ Breach check unavailable. Other requirements still apply.
+ </FieldDescription>
+ )}
+ </div>
+ </AnimatedCollapse>
+ </Field>
+ );
+};
diff --git a/frontend/src/components/auth/TeamInviteStep.tsx b/frontend/src/components/auth/TeamInviteStep.tsx
index 1871e4a368..f53ecca2b7 100644
--- a/frontend/src/components/auth/TeamInviteStep.tsx
+++ b/frontend/src/components/auth/TeamInviteStep.tsx
@@ -5,10 +5,10 @@ import { z } from "zod";
import {
Button,
- Card,
CardContent,
CardHeader,
CardTitle,
+ Field,
FieldError,
TextArea
} from "@app/components/v3";
@@ -17,6 +17,7 @@ import { useFetchServerStatus } from "@app/hooks/api/serverDetails";
import { usePopUp } from "@app/hooks/usePopUp";
import { EmailServiceSetupModal } from "../v2";
+import { AuthPagePanel } from "./AuthPagePanel";
/**
* This is the last step of the signup flow. People can optionally invite their teammates here.
@@ -75,14 +76,14 @@ export default function TeamInviteStep(): JSX.Element {
return (
<div className="mx-auto flex w-full flex-col items-center justify-center">
- <Card className="mx-auto w-full max-w-md items-stretch gap-0 p-6">
+ <AuthPagePanel>
<CardHeader className="mb-4 gap-2">
- <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.65rem] font-medium text-transparent">
+ <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
{t("signup.step5-invite-team")}
</CardTitle>
</CardHeader>
- <CardContent className="flex flex-col gap-y-4">
- <div className="w-full">
+ <CardContent className="flex flex-col gap-4">
+ <Field data-invalid={Boolean(validationError)}>
<TextArea
className="min-h-20"
value={emails}
@@ -91,9 +92,10 @@ export default function TeamInviteStep(): JSX.Element {
if (validationError) setValidationError("");
}}
+ isError={Boolean(validationError)}
/>
{validationError && <FieldError>{validationError}</FieldError>}
- </div>
+ </Field>
<Button
onClick={() => {
if (serverDetails?.emailConfigured) {
@@ -120,7 +122,7 @@ export default function TeamInviteStep(): JSX.Element {
{t("signup.step5-skip") ?? "Skip"}
</Button>
</CardContent>
- </Card>
+ </AuthPagePanel>
<EmailServiceSetupModal
isOpen={popUp.setUpEmail?.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("setUpEmail", isOpen)}
diff --git a/frontend/src/components/auth/UserInfoStep.tsx b/frontend/src/components/auth/UserInfoStep.tsx
index 2db0c863a3..c9e49b9375 100644
--- a/frontend/src/components/auth/UserInfoStep.tsx
+++ b/frontend/src/components/auth/UserInfoStep.tsx
@@ -1,64 +1,56 @@
-import { useCallback, useRef, useState } from "react";
-import { useForm } from "react-hook-form";
+import { useState } from "react";
+import { SubmitErrorHandler, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { zodResolver } from "@hookform/resolvers/zod";
-import { Eye, EyeOff, X } from "lucide-react";
+import { Check, Eye, EyeOff, X } from "lucide-react";
import { z } from "zod";
+import { PasswordField } from "@app/components/auth/PasswordField";
+import { createPasswordSchema } from "@app/components/utilities/checks/password/passwordPolicy";
+import { usePasswordBreachCheck } from "@app/components/utilities/checks/password/usePasswordBreachCheck";
import {
+ AnimatedCollapse,
Button,
- Card,
CardContent,
CardHeader,
CardTitle,
+ Field,
FieldError,
- IconButton,
+ FieldLabel,
Input,
InputGroup,
InputGroupAddon,
+ InputGroupButton,
InputGroupInput,
TextArea
} from "@app/components/v3";
import { EXAMPLE_PROJECT_NAME } from "@app/const";
+import { useServerConfig } from "@app/context";
import { isInfisicalCloud } from "@app/helpers/platform";
import { initProjectHelper } from "@app/helpers/project";
import { getHubSpotUtk } from "@app/helpers/utmTracking";
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
import { useCompleteAccountSignup } from "@app/hooks/api/auth/queries";
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
+import { GenericResourceNameSchema } from "@app/lib/schemas";
-import { checkIsPasswordBreached } from "../utilities/checks/password/checkIsPasswordBreached";
-import {
- escapeCharRegex,
- letterCharRegex,
- lowEntropyRegexes,
- numAndSpecialCharRegex,
- repeatedCharRegex
-} from "../utilities/checks/password/passwordRegexes";
import SecurityClient from "../utilities/SecurityClient";
+import { AuthPagePanel } from "./AuthPagePanel";
-const passwordSchema = z
- .string()
- .min(1, "Password is required")
- .min(14, "at least 14 characters")
- .max(100, "at most 100 characters")
- .regex(letterCharRegex, "at least 1 letter character")
- .regex(numAndSpecialCharRegex, "at least 1 number or special character")
- .refine((pwd) => !repeatedCharRegex.test(pwd), "at most 3 repeated, consecutive characters")
- .refine((pwd) => !escapeCharRegex.test(pwd), "No escape characters allowed")
- .refine(
- (pwd) => !lowEntropyRegexes.some((regex) => regex.test(pwd)),
- "Password contains personal info"
- );
-
-const createUserInfoFormSchema = (isInvite: boolean) =>
- z.object({
- name: z.string().min(1, "Please, specify your name"),
- organizationName: isInvite
- ? z.string().optional()
- : z.string().min(1, "Please, specify your organization name").max(64),
- password: passwordSchema,
- attributionSource: z.string().optional()
- });
+const createUserInfoFormSchema = (isInvite: boolean, passwordPolicy: TPasswordPolicy) =>
+ z
+ .object({
+ firstName: z.string().trim().min(1, "First name is required"),
+ lastName: z.string().trim().optional(),
+ organizationName: isInvite ? z.string().optional() : GenericResourceNameSchema,
+ password: createPasswordSchema(passwordPolicy),
+ confirmPassword: z.string().min(1, "Please confirm your password"),
+ attributionSource: z.string().optional()
+ })
+ .refine(({ password, confirmPassword }) => password === confirmPassword, {
+ message: "Passwords do not match",
+ path: ["confirmPassword"]
+ });
type UserInfoFormData = z.infer<ReturnType<typeof createUserInfoFormSchema>>;
@@ -68,60 +60,61 @@ interface UserInfoStepProps {
isInvite?: boolean;
}
-const BREACH_CHECK_DEBOUNCE_MS = 1000;
-
export default function UserInfoStep({
onComplete,
email,
isInvite = false
}: UserInfoStepProps): JSX.Element {
- const [showPassword, setShowPassword] = useState(false);
- const [breachWarning, setBreachWarning] = useState<string | null>(null);
- const breachTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
+ const [isAttributionStep, setIsAttributionStep] = useState(false);
+ const { config } = useServerConfig();
const { mutateAsync: completeSignup, isPending: isLoading } = useCompleteAccountSignup();
const { t } = useTranslation();
const {
register,
handleSubmit,
+ setError,
watch,
- formState: { errors }
+ formState: { dirtyFields, errors, submitCount }
} = useForm<UserInfoFormData>({
- resolver: zodResolver(createUserInfoFormSchema(isInvite)),
- criteriaMode: "all",
+ resolver: zodResolver(createUserInfoFormSchema(isInvite, config.passwordPolicy)),
+ mode: "onChange",
defaultValues: {
- name: "",
+ firstName: "",
+ lastName: "",
organizationName: "",
password: "",
+ confirmPassword: "",
attributionSource: ""
}
});
const passwordValue = watch("password");
- const passwordIssues = errors.password?.types
- ? (Object.values(errors.password.types).flat().filter(Boolean) as string[])
- : [];
-
- const debouncedBreachCheck = useCallback((pwd: string) => {
- if (breachTimerRef.current) {
- clearTimeout(breachTimerRef.current);
- }
- if (pwd.length < 14) {
- setBreachWarning(null);
- return;
- }
- breachTimerRef.current = setTimeout(async () => {
- const isBreached = await checkIsPasswordBreached(pwd);
- setBreachWarning(isBreached ? "Password was found in a data breach" : null);
- }, BREACH_CHECK_DEBOUNCE_MS);
- }, []);
+ const { breachStatus: passwordBreachStatus, validatePassword } = usePasswordBreachCheck({
+ password: passwordValue,
+ policy: config.passwordPolicy
+ });
+ const confirmPasswordValue = watch("confirmPassword");
+ const showDangerState = submitCount > 0;
+ const showOrganizationNameError =
+ (showDangerState || Boolean(dirtyFields.organizationName)) && Boolean(errors.organizationName);
+ const doPasswordsMatch =
+ confirmPasswordValue.length > 0 && passwordValue === confirmPasswordValue;
+ const isPasswordValidated =
+ passwordBreachStatus === "safe" || passwordBreachStatus === "unavailable";
+ const canSubmit = isPasswordValidated && !isLoading;
+ const accountStepTitle = isInvite ? "Set up your account" : t("signup.step3-message");
+ const stepTitle = isAttributionStep ? "One last thing" : accountStepTitle;
const onSubmit = async (formData: UserInfoFormData) => {
- // Run breach check synchronously on submit if not already checked
- const isBreached = await checkIsPasswordBreached(formData.password);
- if (isBreached) {
- setBreachWarning("Password was found in a data breach");
+ const latestBreachStatus = await validatePassword(formData.password);
+ if (latestBreachStatus === "breached") {
+ setError("password", {
+ type: "validate",
+ message: "This password was found in a known data breach."
+ });
return;
}
@@ -129,8 +122,8 @@ export default function UserInfoStep({
type: "email",
email,
password: formData.password,
- firstName: formData.name.split(" ")[0],
- lastName: formData.name.split(" ").slice(1).join(" "),
+ firstName: formData.firstName,
+ lastName: formData.lastName ?? "",
organizationName: formData.organizationName || undefined,
attributionSource: formData.attributionSource,
hubspotUtk: getHubSpotUtk()
@@ -160,106 +153,192 @@ export default function UserInfoStep({
onComplete();
};
- const allIssues = [...passwordIssues, ...(breachWarning ? [breachWarning] : [])];
+ const onInvalidSubmit: SubmitErrorHandler<UserInfoFormData> = (formErrors) => {
+ if (formErrors.organizationName) {
+ setIsAttributionStep(false);
+ }
+ };
return (
<div className="mx-auto flex w-full flex-col items-center justify-center">
- <Card className="mx-auto w-full max-w-sm items-stretch gap-0 p-6">
+ <AuthPagePanel>
<CardHeader className="mb-4 gap-2">
- <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.65rem] font-medium text-transparent">
- {isInvite ? "Set up your account" : t("signup.step3-message")}
+ <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
+ {stepTitle}
</CardTitle>
</CardHeader>
- <CardContent>
- <div className="flex w-full flex-col items-stretch py-2">
- <p className="mb-1 ml-1 text-sm font-medium text-bunker-300">Your Name</p>
- <Input
- {...register("name")}
- placeholder="Jane Doe"
- autoComplete="given-name"
- isError={!!errors.name}
- />
- {errors.name && <FieldError>{errors.name.message}</FieldError>}
- </div>
- {!isInvite && (
+ <CardContent className="flex flex-col gap-4">
+ {!isAttributionStep && (
<>
- <div className="flex w-full flex-col items-stretch py-2">
- <p className="mb-1 ml-1 text-sm font-medium text-bunker-300">Organization Name</p>
- <Input
- {...register("organizationName")}
- placeholder="Infisical"
- maxLength={64}
- isError={!!errors.organizationName}
- />
- {errors.organizationName && (
- <FieldError>{errors.organizationName.message}</FieldError>
- )}
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <Field data-invalid={showDangerState && Boolean(errors.firstName)}>
+ <FieldLabel className="sr-only" htmlFor="signup-first-name">
+ First Name
+ </FieldLabel>
+ <Input
+ {...register("firstName")}
+ id="signup-first-name"
+ placeholder="First Name"
+ autoComplete="given-name"
+ isError={showDangerState && Boolean(errors.firstName)}
+ />
+ {showDangerState && errors.firstName ? (
+ <FieldError>{errors.firstName.message}</FieldError>
+ ) : null}
+ </Field>
+ <Field data-invalid={showDangerState && Boolean(errors.lastName)}>
+ <FieldLabel className="sr-only" htmlFor="signup-last-name">
+ Last Name
+ </FieldLabel>
+ <Input
+ {...register("lastName")}
+ id="signup-last-name"
+ placeholder="Last Name"
+ autoComplete="family-name"
+ isError={showDangerState && Boolean(errors.lastName)}
+ />
+ {showDangerState && errors.lastName ? (
+ <FieldError>{errors.lastName.message}</FieldError>
+ ) : null}
+ </Field>
</div>
- <div className="flex w-full flex-col items-stretch py-2">
- <p className="mb-1 ml-1 text-sm font-medium text-bunker-300">
- Where did you hear about us? <span className="font-light">(optional)</span>
- </p>
- <TextArea {...register("attributionSource")} placeholder="" rows={2} />
- </div>
- </>
- )}
- <div className="flex w-full flex-col items-stretch py-2">
- <p className="mb-1 ml-1 text-sm font-medium text-bunker-300">
- {t("section.password.password")}
- </p>
- <InputGroup className="h-10">
- <InputGroupInput
- {...register("password", {
- onChange(e) {
- setBreachWarning(null);
- debouncedBreachCheck(e.target.value);
- }
- })}
- type={showPassword ? "text" : "password"}
- placeholder="Enter a strong password..."
- autoComplete="new-password"
+ {!isInvite && (
+ <Field data-invalid={showOrganizationNameError}>
+ <FieldLabel className="sr-only" htmlFor="signup-organization-name">
+ Organization Name
+ </FieldLabel>
+ <Input
+ {...register("organizationName")}
+ id="signup-organization-name"
+ placeholder="Organization Name"
+ maxLength={64}
+ autoComplete="organization"
+ isError={showOrganizationNameError}
+ />
+ {showOrganizationNameError && errors.organizationName ? (
+ <FieldError>{errors.organizationName.message}</FieldError>
+ ) : null}
+ </Field>
+ )}
+ <PasswordField
id="new-password"
+ value={passwordValue}
+ policy={config.passwordPolicy}
+ breachStatus={passwordBreachStatus}
+ placeholder="••••••••"
+ registration={register("password")}
+ error={showDangerState ? errors.password : undefined}
+ submitCount={submitCount}
/>
- <InputGroupAddon align="inline-end">
- <IconButton
+ <AnimatedCollapse
+ isOpen={isPasswordValidated}
+ contentClassName={isPasswordValidated ? "overflow-visible" : undefined}
+ >
+ <Field data-invalid={showDangerState && Boolean(errors.confirmPassword)}>
+ <FieldLabel htmlFor="confirm-password">Confirm Password</FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ {...register("confirmPassword")}
+ id="confirm-password"
+ type={showConfirmPassword ? "text" : "password"}
+ placeholder="••••••••"
+ autoComplete="new-password"
+ aria-invalid={showDangerState && Boolean(errors.confirmPassword)}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ onClick={() => setShowConfirmPassword((current) => !current)}
+ aria-label={
+ showConfirmPassword
+ ? "Hide password confirmation"
+ : "Show password confirmation"
+ }
+ >
+ {showConfirmPassword ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ <AnimatedCollapse isOpen={confirmPasswordValue.length > 0}>
+ <div className="flex items-start gap-2 pt-1 text-xs" aria-live="polite">
+ {doPasswordsMatch ? (
+ <Check className="mt-0.5 size-3.5 shrink-0 text-success" />
+ ) : (
+ <X className="mt-0.5 size-3.5 shrink-0 text-danger" />
+ )}
+ <span className={doPasswordsMatch ? "text-muted" : "text-danger"}>
+ {doPasswordsMatch ? "Passwords match" : "Passwords do not match"}
+ </span>
+ </div>
+ </AnimatedCollapse>
+ {showDangerState && errors.confirmPassword ? (
+ <FieldError>{errors.confirmPassword.message}</FieldError>
+ ) : null}
+ </Field>
+ </AnimatedCollapse>
+ {isInvite ? (
+ <Button
+ type="submit"
+ onClick={handleSubmit(onSubmit)}
+ variant="project"
+ size="lg"
+ isFullWidth
+ isPending={isLoading}
+ isDisabled={!canSubmit}
+ >
+ {String(t("signup.signup"))}
+ </Button>
+ ) : (
+ <Button
+ variant="project"
+ size="lg"
+ isFullWidth
+ isDisabled={!canSubmit}
+ onClick={handleSubmit(() => setIsAttributionStep(true))}
+ >
+ Continue
+ </Button>
+ )}
+ </>
+ )}
+ {isAttributionStep && (
+ <>
+ <Field>
+ <FieldLabel className="sr-only" htmlFor="signup-attribution-source">
+ Where did you hear about us? <span className="font-light">(optional)</span>
+ </FieldLabel>
+ <TextArea
+ {...register("attributionSource")}
+ id="signup-attribution-source"
+ placeholder="Where did you hear about us? (optional)"
+ rows={3}
+ autoFocus
+ />
+ </Field>
+ <div className="flex flex-col gap-2">
+ <Button
+ type="submit"
+ onClick={handleSubmit(onSubmit, onInvalidSubmit)}
+ variant="project"
+ size="lg"
+ isFullWidth
+ isPending={isLoading}
+ isDisabled={!canSubmit}
+ >
+ {String(t("signup.signup"))}
+ </Button>
+ <Button
variant="ghost"
- size="xs"
- onClick={() => setShowPassword((prev) => !prev)}
- aria-label={showPassword ? "Hide password" : "Show password"}
+ size="sm"
+ isFullWidth
+ onClick={() => setIsAttributionStep(false)}
>
- {showPassword ? <EyeOff /> : <Eye />}
- </IconButton>
- </InputGroupAddon>
- </InputGroup>
- {allIssues.length > 0 && passwordValue.length > 0 && (
- <div className="mt-4 flex w-full flex-col items-start rounded-md border border-border bg-container px-3 py-2.5">
- <div className="mb-1 text-sm text-gray-400">
- {t("section.password.validate-base")}
- </div>
- {allIssues.map((issue) => (
- <div className="items-top flex flex-row justify-start" key={issue}>
- <X className="mt-0.5 mr-2 size-4 shrink-0 text-danger" />
- <p className="text-sm text-gray-400">{issue}</p>
- </div>
- ))}
+ Back
+ </Button>
</div>
- )}
- </div>
- <div className="mt-4 w-full">
- <Button
- type="submit"
- onClick={handleSubmit(onSubmit)}
- variant="project"
- size="lg"
- isFullWidth
- isPending={isLoading}
- isDisabled={isLoading}
- >
- {String(t("signup.signup"))}
- </Button>
- </div>
+ </>
+ )}
</CardContent>
- </Card>
+ </AuthPagePanel>
</div>
);
}
diff --git a/frontend/src/components/mfa/setup/VerifyStep.tsx b/frontend/src/components/mfa/setup/VerifyStep.tsx
index b2d2004f25..bf88180869 100644
--- a/frontend/src/components/mfa/setup/VerifyStep.tsx
+++ b/frontend/src/components/mfa/setup/VerifyStep.tsx
@@ -4,7 +4,7 @@ import QRCode from "qrcode";
import { createNotification } from "@app/components/notifications";
import { ContentLoader } from "@app/components/v2";
-import { Button, Input } from "@app/components/v3";
+import { Button, Input, VerificationCodeForm } from "@app/components/v3";
import { MfaMethod } from "@app/hooks/api/auth/types";
import { useEnrollMfa, useGetUserTotpRegistration } from "@app/hooks/api/users";
import { useRegisterPasskey } from "@app/hooks/api/webauthn";
@@ -63,20 +63,14 @@ const TotpVerify = ({ onVerified }: { onVerified: Props["onVerified"] }) => {
</code>
</p>
)}
- <Input
+ <VerificationCodeForm
+ name="totp-enrollment-code"
value={totp}
- onChange={(e) => setTotp(e.target.value.replace(/\D/g, "").slice(0, 6))}
- placeholder="Enter 6-digit code"
- maxLength={6}
- />
- <Button
- variant="org"
+ onChange={(value) => setTotp(value.replace(/\D/g, "").slice(0, 6))}
+ onSubmit={handleVerify}
+ submitLabel="Verify code"
isPending={isVerifying}
- isDisabled={totp.trim().length !== 6}
- onClick={handleVerify}
- >
- Verify Code
- </Button>
+ />
</div>
);
};
diff --git a/frontend/src/components/utilities/checks/password/PasswordCheck.ts b/frontend/src/components/utilities/checks/password/PasswordCheck.ts
index fb51862205..a644612f9d 100644
--- a/frontend/src/components/utilities/checks/password/PasswordCheck.ts
+++ b/frontend/src/components/utilities/checks/password/PasswordCheck.ts
@@ -2,7 +2,6 @@ import { checkIsPasswordBreached } from "./checkIsPasswordBreached";
import {
escapeCharRegex,
letterCharRegex,
- lowEntropyRegexes,
numAndSpecialCharRegex,
repeatedCharRegex
} from "./passwordRegexes";
@@ -15,7 +14,6 @@ interface PasswordCheckProps {
setPasswordErrorNoNumOrSpecialChar: (value: boolean) => void;
setPasswordErrorRepeatedChar: (value: boolean) => void;
setPasswordErrorEscapeChar: (value: boolean) => void;
- setPasswordErrorLowEntropy: (value: boolean) => void;
setPasswordErrorBreached: (value: boolean) => void;
}
@@ -27,7 +25,6 @@ const passwordCheck = async ({
setPasswordErrorNoNumOrSpecialChar,
setPasswordErrorRepeatedChar,
setPasswordErrorEscapeChar,
- setPasswordErrorLowEntropy,
setPasswordErrorBreached
}: PasswordCheckProps) => {
let errorCheck = false;
@@ -61,11 +58,6 @@ const passwordCheck = async ({
name: "escapeChar",
validator: (pwd: string) => !escapeCharRegex.test(pwd),
setError: setPasswordErrorEscapeChar
- },
- {
- name: "lowEntropy",
- validator: (pwd: string) => !lowEntropyRegexes.some((regex) => regex.test(pwd)),
- setError: setPasswordErrorLowEntropy
}
];
diff --git a/frontend/src/components/utilities/checks/password/checkIsPasswordBreached.ts b/frontend/src/components/utilities/checks/password/checkIsPasswordBreached.ts
index 3e2500260f..4bcccc4e20 100644
--- a/frontend/src/components/utilities/checks/password/checkIsPasswordBreached.ts
+++ b/frontend/src/components/utilities/checks/password/checkIsPasswordBreached.ts
@@ -37,7 +37,11 @@ function bufferToHex(buffer: ArrayBuffer): string {
// • Context-specific words, such as the name of the service, the username, and derivatives
// thereof."
-export const checkIsPasswordBreached = async (password: string): Promise<boolean> => {
+export type PasswordBreachStatus = "safe" | "breached" | "unavailable";
+
+export const checkPasswordBreachStatus = async (
+ password: string
+): Promise<PasswordBreachStatus> => {
const HAVE_I_BEEN_PWNED_API_URL = "https://api.pwnedpasswords.com";
const maxRetryAttempts = 3;
@@ -75,7 +79,7 @@ export const checkIsPasswordBreached = async (password: string): Promise<boolean
const responseData = response.data.toUpperCase();
// check the last 35 hash chars to see if there's a match
const isBreachedPassword: boolean = responseData.includes(hashedPwd.slice(5, 40));
- return isBreachedPassword;
+ return isBreachedPassword ? "breached" : "safe";
}
retryAttempt += 1;
} catch (err) {
@@ -91,10 +95,10 @@ export const checkIsPasswordBreached = async (password: string): Promise<boolean
response ? response.status : "unknown"
}) from the Pwnd Passwords API`
);
- return false;
+ return "unavailable";
} catch (err: any) {
console.error("An unexpected error has occurred:", err.message);
- return false;
+ return "unavailable";
} finally {
// Clear the UTF-8 encoded password from memory
@@ -111,3 +115,6 @@ export const checkIsPasswordBreached = async (password: string): Promise<boolean
}
}
};
+
+export const checkIsPasswordBreached = async (password: string): Promise<boolean> =>
+ (await checkPasswordBreachStatus(password)) === "breached";
diff --git a/frontend/src/components/utilities/checks/password/checkPassword.ts b/frontend/src/components/utilities/checks/password/checkPassword.ts
index 68d81b9a1f..028373279f 100644
--- a/frontend/src/components/utilities/checks/password/checkPassword.ts
+++ b/frontend/src/components/utilities/checks/password/checkPassword.ts
@@ -2,7 +2,6 @@ import { checkIsPasswordBreached } from "./checkIsPasswordBreached";
import {
escapeCharRegex,
letterCharRegex,
- lowEntropyRegexes,
numAndSpecialCharRegex,
repeatedCharRegex
} from "./passwordRegexes";
@@ -14,7 +13,6 @@ type Errors = {
noNumOrSpecialChar?: string;
repeatedChar?: string;
escapeChar?: string;
- lowEntropy?: string;
breached?: string;
};
@@ -31,7 +29,6 @@ interface CheckPasswordParams {
* - Contains at least 1 number (0-9) or special character (emojis included)
* - Does not contain 3 repeat, consecutive characters
* - Does not contain any escape characters/sequences
- * - Does not contain PII and/or low entropy data (eg. email address, URL, SSN)
* - Is not in a database of breached passwords
*
* The function returns whether or not the password [password]
@@ -76,11 +73,6 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
name: "escapeChar",
validator: (pwd: string) => !escapeCharRegex.test(pwd),
errorText: "No escape characters allowed"
- },
- {
- name: "lowEntropy",
- validator: (pwd: string) => !lowEntropyRegexes.some((regex) => regex.test(pwd)),
- errorText: "Password contains personal info"
}
];
diff --git a/frontend/src/components/utilities/checks/password/passwordPolicy.ts b/frontend/src/components/utilities/checks/password/passwordPolicy.ts
new file mode 100644
index 0000000000..4e0b1a7397
--- /dev/null
+++ b/frontend/src/components/utilities/checks/password/passwordPolicy.ts
@@ -0,0 +1,55 @@
+import { z } from "zod";
+
+import { TPasswordPolicy, TPasswordPolicyRequirement } from "@app/hooks/api/admin/types";
+
+const hasMoreThanMaxConsecutiveCharacters = (
+ password: string,
+ maxConsecutiveCharacters: number
+) => {
+ let previousCharacter: string | undefined;
+ let consecutiveCharacterCount = 0;
+
+ return Array.from(password).some((character) => {
+ if (character === previousCharacter) {
+ consecutiveCharacterCount += 1;
+ } else {
+ previousCharacter = character;
+ consecutiveCharacterCount = 1;
+ }
+
+ return consecutiveCharacterCount > maxConsecutiveCharacters;
+ });
+};
+
+export const doesPasswordMeetRequirement = (
+ password: string,
+ requirement: TPasswordPolicyRequirement
+) => {
+ const matches =
+ requirement.patterns.some((pattern) => new RegExp(pattern, requirement.flags).test(password)) ||
+ (requirement.maxConsecutiveCharacters !== undefined &&
+ hasMoreThanMaxConsecutiveCharacters(password, requirement.maxConsecutiveCharacters));
+
+ return matches === requirement.shouldMatch;
+};
+
+export const getPasswordRequirements = (password: string, policy: TPasswordPolicy) =>
+ policy.requirements.map((requirement) => ({
+ ...requirement,
+ isMet: doesPasswordMeetRequirement(password, requirement)
+ }));
+
+export const createPasswordSchema = (policy: TPasswordPolicy) =>
+ z
+ .string()
+ .min(1, "Password is required")
+ .superRefine((password, context) => {
+ policy.requirements.forEach((requirement) => {
+ if (!doesPasswordMeetRequirement(password, requirement)) {
+ context.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: requirement.message
+ });
+ }
+ });
+ });
diff --git a/frontend/src/components/utilities/checks/password/passwordRegexes.ts b/frontend/src/components/utilities/checks/password/passwordRegexes.ts
index 1e2367b491..60b138a2b1 100644
--- a/frontend/src/components/utilities/checks/password/passwordRegexes.ts
+++ b/frontend/src/components/utilities/checks/password/passwordRegexes.ts
@@ -11,15 +11,3 @@ export const repeatedCharRegex = /(.)\1\1\1|\s{4,}/;
// This regex covers the escape sequences as a precaution
export const escapeCharRegex = /[\n\t\r\\]/;
-
-// This regex covers some PII and/or low entropy data
-export const lowEntropyRegexes = [
- // Email address
- /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/,
-
- // URL (incl. subdomains, paths, top-level domains & query params)
- /^(?:(?:https?|ftp):\/\/)?(?:\w+\.)?[a-zA-Z0-9.-]+\.(?:com|org|net|edu)(?:\/\S*)?(?:\?\S*)?$/,
-
- // US social security number
- /\b\d{3}[-\s]?\d{2}[-\s]?\d{4}\b/
-];
diff --git a/frontend/src/components/utilities/checks/password/usePasswordBreachCheck.ts b/frontend/src/components/utilities/checks/password/usePasswordBreachCheck.ts
new file mode 100644
index 0000000000..ee35790b06
--- /dev/null
+++ b/frontend/src/components/utilities/checks/password/usePasswordBreachCheck.ts
@@ -0,0 +1,98 @@
+import { useCallback, useEffect, useRef, useState } from "react";
+
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
+
+import { checkPasswordBreachStatus, PasswordBreachStatus } from "./checkIsPasswordBreached";
+import { getPasswordRequirements } from "./passwordPolicy";
+
+export type PasswordBreachCheckStatus = PasswordBreachStatus | "idle" | "checking";
+
+type PasswordBreachResult = {
+ password: string;
+ status: PasswordBreachStatus;
+};
+
+type PasswordBreachRequest = {
+ password: string;
+ promise: Promise<PasswordBreachStatus>;
+};
+
+export const usePasswordBreachCheck = ({
+ password,
+ policy,
+ debounceMs = 800
+}: {
+ password: string;
+ policy: TPasswordPolicy;
+ debounceMs?: number;
+}) => {
+ const [status, setStatus] = useState<PasswordBreachCheckStatus>("idle");
+ const latestRequestRef = useRef(0);
+ const lastResultRef = useRef<PasswordBreachResult>();
+ const activeRequestRef = useRef<PasswordBreachRequest>();
+
+ const getBreachStatus = useCallback((value: string) => {
+ if (activeRequestRef.current?.password === value) {
+ return activeRequestRef.current.promise;
+ }
+
+ const promise = checkPasswordBreachStatus(value).finally(() => {
+ if (activeRequestRef.current?.promise === promise) {
+ activeRequestRef.current = undefined;
+ }
+ });
+ activeRequestRef.current = { password: value, promise };
+
+ return promise;
+ }, []);
+
+ const validatePassword = useCallback(
+ async (value: string) => {
+ if (lastResultRef.current?.password === value) {
+ setStatus(lastResultRef.current.status);
+ return lastResultRef.current.status;
+ }
+
+ const requestId = latestRequestRef.current + 1;
+ latestRequestRef.current = requestId;
+ setStatus("checking");
+
+ const nextStatus = await getBreachStatus(value);
+ lastResultRef.current = { password: value, status: nextStatus };
+
+ if (latestRequestRef.current === requestId) {
+ setStatus(nextStatus);
+ }
+
+ return nextStatus;
+ },
+ [getBreachStatus]
+ );
+
+ useEffect(() => {
+ const meetsPolicy = getPasswordRequirements(password, policy).every(({ isMet }) => isMet);
+
+ if (!password || !meetsPolicy) {
+ latestRequestRef.current += 1;
+ setStatus("idle");
+ return undefined;
+ }
+
+ if (lastResultRef.current?.password === password) {
+ setStatus(lastResultRef.current.status);
+ return undefined;
+ }
+
+ setStatus("checking");
+ const timeout = window.setTimeout(() => {
+ validatePassword(password).catch(() => setStatus("unavailable"));
+ }, debounceMs);
+
+ return () => {
+ window.clearTimeout(timeout);
+ latestRequestRef.current += 1;
+ };
+ }, [debounceMs, password, policy, validatePassword]);
+
+ return { breachStatus: status, validatePassword };
+};
diff --git a/frontend/src/components/v3/generic/AnimatedCollapse/AnimatedCollapse.stories.tsx b/frontend/src/components/v3/generic/AnimatedCollapse/AnimatedCollapse.stories.tsx
new file mode 100644
index 0000000000..74b7faf96c
--- /dev/null
+++ b/frontend/src/components/v3/generic/AnimatedCollapse/AnimatedCollapse.stories.tsx
@@ -0,0 +1,38 @@
+import { useState } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+
+import { Button } from "../Button";
+import { AnimatedCollapse } from "./AnimatedCollapse";
+
+const meta = {
+ title: "Generic/AnimatedCollapse",
+ component: AnimatedCollapse,
+ tags: ["autodocs"]
+} satisfies Meta<typeof AnimatedCollapse>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const Default: Story = {
+ name: "Example: Conditional Content",
+ args: {
+ isOpen: false
+ },
+ render: function Render(args) {
+ const [isOpen, setIsOpen] = useState(false);
+
+ return (
+ <div className="flex w-80 flex-col gap-2">
+ <Button onClick={() => setIsOpen((current) => !current)}>
+ {isOpen ? "Hide Content" : "Show Content"}
+ </Button>
+ <AnimatedCollapse {...args} isOpen={isOpen}>
+ <div className="rounded-md border border-border bg-container p-4 text-sm text-foreground">
+ Conditionally displayed content expands and collapses without requiring an accordion
+ trigger.
+ </div>
+ </AnimatedCollapse>
+ </div>
+ );
+ }
+};
diff --git a/frontend/src/components/v3/generic/AnimatedCollapse/AnimatedCollapse.tsx b/frontend/src/components/v3/generic/AnimatedCollapse/AnimatedCollapse.tsx
new file mode 100644
index 0000000000..0ede529303
--- /dev/null
+++ b/frontend/src/components/v3/generic/AnimatedCollapse/AnimatedCollapse.tsx
@@ -0,0 +1,39 @@
+/* eslint-disable react/prop-types */
+
+import * as React from "react";
+
+import { cn } from "../../utils";
+
+type AnimatedCollapseProps = React.ComponentProps<"div"> & {
+ isOpen: boolean;
+ contentClassName?: string;
+};
+
+function AnimatedCollapse({
+ children,
+ className,
+ contentClassName,
+ isOpen,
+ ...props
+}: AnimatedCollapseProps) {
+ return (
+ <div
+ {...props}
+ data-slot="animated-collapse"
+ data-state={isOpen ? "open" : "closed"}
+ aria-hidden={!isOpen}
+ // React 18 does not type the inert attribute yet.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ {...(!isOpen ? { inert: "" as any } : {})}
+ className={cn(
+ "grid transition-[grid-template-rows,opacity] duration-200 ease-in-out motion-reduce:transition-none",
+ isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0",
+ className
+ )}
+ >
+ <div className={cn("min-h-0 overflow-hidden", contentClassName)}>{children}</div>
+ </div>
+ );
+}
+
+export { AnimatedCollapse, type AnimatedCollapseProps };
diff --git a/frontend/src/components/v3/generic/AnimatedCollapse/index.ts b/frontend/src/components/v3/generic/AnimatedCollapse/index.ts
new file mode 100644
index 0000000000..7a99a60fc7
--- /dev/null
+++ b/frontend/src/components/v3/generic/AnimatedCollapse/index.ts
@@ -0,0 +1 @@
+export * from "./AnimatedCollapse";
diff --git a/frontend/src/components/v3/generic/Button/Button.stories.tsx b/frontend/src/components/v3/generic/Button/Button.stories.tsx
index e21d0a16d8..a272cc6cf4 100644
--- a/frontend/src/components/v3/generic/Button/Button.stories.tsx
+++ b/frontend/src/components/v3/generic/Button/Button.stories.tsx
@@ -14,6 +14,7 @@ import {
} from "lucide-react";
import { Button } from "./Button";
+import { ButtonBadge } from "./ButtonBadge";
/**
* Buttons trigger actions or events when clicked or pressed.
@@ -88,6 +89,35 @@ export const Outline: Story = {
}
};
+export const WithCornerBadge: Story = {
+ name: "Composition: Corner Badge",
+ render: () => (
+ <div className="flex flex-col items-start gap-6">
+ <Button variant="outline" size="lg">
+ <LogInIcon />
+ Continue with GitHub
+ <ButtonBadge variant="project">Last used</ButtonBadge>
+ </Button>
+ <Button variant="outline" size="lg">
+ Explore feature
+ <ButtonBadge variant="info">New</ButtonBadge>
+ </Button>
+ <Button variant="outline" size="lg">
+ Use recommended setup
+ <ButtonBadge variant="success">Recommended</ButtonBadge>
+ </Button>
+ </div>
+ ),
+ parameters: {
+ docs: {
+ description: {
+ story:
+ "Place `ButtonBadge` inside a `Button` for short contextual flags such as Last used, New, or Recommended. It inherits Badge typography, sizing, radius, and casing while adding corner positioning and an opaque semantic tint. Choose an existing semantic variant or an intentionally branded project variant, and keep the label concise."
+ }
+ }
+ }
+};
+
export const Neutral: Story = {
name: "Variant: Neutral",
args: {
diff --git a/frontend/src/components/v3/generic/Button/Button.tsx b/frontend/src/components/v3/generic/Button/Button.tsx
index 4987a442c0..6f9ec6bebf 100644
--- a/frontend/src/components/v3/generic/Button/Button.tsx
+++ b/frontend/src/components/v3/generic/Button/Button.tsx
@@ -8,10 +8,11 @@ import { cn } from "@app/components/v3/utils";
const buttonVariants = cva(
cn(
- "inline-flex items-center rounded-md active:scale-[0.99] justify-center border cursor-pointer whitespace-nowrap",
+ "relative inline-flex items-center overflow-visible rounded-md active:scale-[0.99] justify-center border cursor-pointer whitespace-nowrap",
" text-sm transition-all disabled:pointer-events-none disabled:opacity-50 shrink-0",
"[&>svg]:pointer-events-none [&>svg]:shrink-0",
- "focus-visible:ring-ring outline-0 focus-visible:ring-2 select-none"
+ "focus-visible:ring-ring outline-0 focus-visible:ring-2 select-none",
+ "has-[[data-slot=button-badge]]:my-1.5 has-[[data-slot=button-badge]]:outline-1 has-[[data-slot=button-badge]]:outline-offset-4 has-[[data-slot=button-badge]]:outline-accent/60 has-[[data-slot=button-badge]]:outline-solid"
),
{
variants: {
@@ -37,10 +38,10 @@ const buttonVariants = cva(
pam: "border-product-pam/30 bg-product-pam/25 text-foreground hover:bg-product-pam/30 hover:border-product-pam/35 data-[state=open]:bg-product-pam/30 data-[state=open]:border-product-pam/35"
},
size: {
- xs: "h-7 px-2 text-xs rounded-sm [&>svg]:size-3 gap-1.5",
- sm: "h-8 px-2.5 text-sm [&>svg]:size-3 gap-1.5",
- md: "h-9 px-3 text-sm [&>svg]:size-3.5 gap-1.5",
- lg: "h-10 px-3 text-sm [&>svg]:size-3.5 gap-1.5"
+ xs: "h-7 gap-2 rounded-sm px-2 text-xs [&>svg]:size-3",
+ sm: "h-8 gap-2 px-2.5 text-sm [&>svg]:size-3",
+ md: "h-9 gap-2 px-3 text-sm [&>svg]:size-3.5",
+ lg: "h-10 gap-2 px-3 text-sm [&>svg]:size-4"
},
isPending: {
true: "text-transparent"
diff --git a/frontend/src/components/v3/generic/Button/ButtonBadge.tsx b/frontend/src/components/v3/generic/Button/ButtonBadge.tsx
new file mode 100644
index 0000000000..73eb1a249b
--- /dev/null
+++ b/frontend/src/components/v3/generic/Button/ButtonBadge.tsx
@@ -0,0 +1,51 @@
+import { forwardRef } from "react";
+import { cva, type VariantProps } from "cva";
+
+import { cn } from "../../utils";
+import { Badge, type TBadgeProps } from "../Badge";
+
+const buttonBadgeBackgrounds: Partial<Record<NonNullable<TBadgeProps["variant"]>, string>> = {
+ neutral: "bg-[color-mix(in_srgb,var(--color-neutral)_15%,var(--color-card))]",
+ success: "bg-[color-mix(in_srgb,var(--color-success)_15%,var(--color-card))]",
+ info: "bg-[color-mix(in_srgb,var(--color-info)_15%,var(--color-card))]",
+ warning: "bg-[color-mix(in_srgb,var(--color-warning)_15%,var(--color-card))]",
+ danger: "bg-[color-mix(in_srgb,var(--color-danger)_15%,var(--color-card))]",
+ project: "bg-[color-mix(in_srgb,var(--color-project)_15%,var(--color-card))]",
+ org: "bg-[color-mix(in_srgb,var(--color-org)_15%,var(--color-card))]",
+ "sub-org": "bg-[color-mix(in_srgb,var(--color-sub-org)_15%,var(--color-card))]",
+ pam: "bg-[color-mix(in_srgb,var(--color-product-pam)_15%,var(--color-card))]"
+};
+
+const buttonBadgeVariants = cva("pointer-events-none absolute z-10", {
+ variants: {
+ position: {
+ "top-right": "-top-3 -right-4",
+ "top-left": "-top-3 -left-2"
+ }
+ },
+ defaultVariants: {
+ position: "top-right"
+ }
+});
+
+type ButtonBadgeProps = TBadgeProps & VariantProps<typeof buttonBadgeVariants>;
+
+const ButtonBadge = forwardRef<HTMLSpanElement, ButtonBadgeProps>(
+ ({ className, position = "top-right", variant = "default", ...props }, ref) => (
+ <Badge
+ ref={ref}
+ data-slot="button-badge"
+ variant={variant}
+ className={cn(
+ buttonBadgeVariants({ position }),
+ variant && buttonBadgeBackgrounds[variant],
+ className
+ )}
+ {...props}
+ />
+ )
+);
+
+ButtonBadge.displayName = "ButtonBadge";
+
+export { ButtonBadge, type ButtonBadgeProps, buttonBadgeVariants };
diff --git a/frontend/src/components/v3/generic/Button/index.ts b/frontend/src/components/v3/generic/Button/index.ts
index e22c29adcf..169a030254 100644
--- a/frontend/src/components/v3/generic/Button/index.ts
+++ b/frontend/src/components/v3/generic/Button/index.ts
@@ -1 +1,2 @@
export * from "./Button";
+export * from "./ButtonBadge";
diff --git a/frontend/src/components/v3/generic/Field/Field.tsx b/frontend/src/components/v3/generic/Field/Field.tsx
index 3565b8ffe9..f284c48a98 100644
--- a/frontend/src/components/v3/generic/Field/Field.tsx
+++ b/frontend/src/components/v3/generic/Field/Field.tsx
@@ -92,7 +92,7 @@ function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
const fieldLabelVariants = cva(
cn(
- "group/field-label peer/field-label flex w-fit items-center gap-1.5 border-border text-xs leading-snug text-accent transition-colors duration-75 group-data-[disabled=true]/field:opacity-50",
+ "group/field-label peer/field-label flex w-fit items-center gap-1.5 border-border text-xs leading-snug text-accent transition-colors duration-75 group-data-[invalid=true]/field:text-danger group-data-[disabled=true]/field:opacity-50",
"has-[>[data-slot=field]]:cursor-pointer has-[>[data-slot=field]]:rounded-md",
"has-[>[data-slot=field]]:border has-[>[data-slot=field]]:bg-transparent has-[>[data-slot=field]]:hover:bg-container-hover [&>*]:data-[slot=field]:p-2.5 [&>svg]:size-3",
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
@@ -171,7 +171,7 @@ function FieldSeparator({
data-slot="field-separator"
data-content={!!children}
className={cn(
- "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
+ "relative my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
className
)}
{...props}
diff --git a/frontend/src/components/v3/generic/Input/Input.tsx b/frontend/src/components/v3/generic/Input/Input.tsx
index 15fd32c7f5..6948d920b2 100644
--- a/frontend/src/components/v3/generic/Input/Input.tsx
+++ b/frontend/src/components/v3/generic/Input/Input.tsx
@@ -10,9 +10,9 @@ const Input = forwardRef<HTMLInputElement, React.ComponentProps<"input"> & { isE
type={type}
data-slot="input"
className={cn(
- "h-9 w-full min-w-0 rounded-md border border-border bg-transparent px-3 py-1 text-sm text-foreground shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
- "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
- "aria-invalid:border-danger aria-invalid:ring-danger/40",
+ "h-9 w-full min-w-0 rounded-md border border-border bg-transparent px-3 py-1 text-sm text-foreground shadow-xs outline-1 outline-offset-4 outline-transparent transition-colors outline-solid file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
+ "hover:border-foreground/20 focus-visible:border-accent focus-visible:outline-accent/60",
+ "aria-invalid:border-danger aria-invalid:focus-visible:outline-danger/60",
"selection:bg-foreground selection:text-background",
className
)}
diff --git a/frontend/src/components/v3/generic/InputGroup/InputGroup.tsx b/frontend/src/components/v3/generic/InputGroup/InputGroup.tsx
index f9314ad6b0..c8b67cb0db 100644
--- a/frontend/src/components/v3/generic/InputGroup/InputGroup.tsx
+++ b/frontend/src/components/v3/generic/InputGroup/InputGroup.tsx
@@ -13,8 +13,9 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
data-slot="input-group"
role="group"
className={cn(
- "group/input-group dark:bg-input/30 relative flex w-full items-center rounded-md border border-border shadow-xs transition-[color,box-shadow] outline-none",
+ "group/input-group dark:bg-input/30 relative flex w-full items-center rounded-md border border-border shadow-xs outline-1 outline-offset-4 outline-transparent transition-colors outline-solid",
"h-9 min-w-0 has-[>textarea]:h-auto",
+ "[&_[data-slot=icon-button]:focus-visible]:ring-0",
// Variants based on alignment.
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
@@ -22,11 +23,14 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
+ // Hover state.
+ "hover:border-foreground/20",
+
// Focus state.
- "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50",
+ "has-[:focus-visible]:border-accent has-[:focus-visible]:outline-accent/60",
// Error state.
- "has-[[data-slot][aria-invalid=true]]:border-danger has-[[data-slot][aria-invalid=true]]:ring-danger/40",
+ "has-[[data-slot][aria-invalid=true]]:border-danger has-[[data-slot][aria-invalid=true]]:outline-danger/60",
className
)}
@@ -40,8 +44,8 @@ const inputGroupAddonVariants = cva(
{
variants: {
align: {
- "inline-start": "order-first pl-2.5 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
- "inline-end": "order-last pr-2.5 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
+ "inline-start": "order-first pl-2.5 has-[>button]:ml-[-5px] has-[>kbd]:ml-[-0.35rem]",
+ "inline-end": "order-last pr-2.5 has-[>button]:mr-[-5px] has-[>kbd]:mr-[-0.35rem]",
"block-start":
"order-first w-full justify-start px-2.5 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5",
"block-end":
@@ -128,7 +132,7 @@ const InputGroupInput = React.forwardRef<HTMLInputElement, React.ComponentProps<
ref={ref}
data-slot="input-group-control"
className={cn(
- "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
+ "flex-1 rounded-none border-0 bg-transparent shadow-none outline-none focus-visible:border-0 dark:bg-transparent",
className
)}
{...props}
@@ -148,7 +152,7 @@ const InputGroupTextArea = React.forwardRef<
ref={ref}
data-slot="input-group-control"
className={cn(
- "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none outline-none focus-visible:border-0 dark:bg-transparent",
className
)}
{...props}
diff --git a/frontend/src/components/v3/generic/Select/Select.tsx b/frontend/src/components/v3/generic/Select/Select.tsx
index 46474936ac..09319ac5b2 100644
--- a/frontend/src/components/v3/generic/Select/Select.tsx
+++ b/frontend/src/components/v3/generic/Select/Select.tsx
@@ -76,7 +76,7 @@ function SelectTrigger({
data-size={size}
aria-invalid={isError}
className={cn(
- "flex w-fit !cursor-pointer items-center justify-between gap-1.5 rounded-md border border-border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap text-foreground transition-[color,box-shadow] outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger aria-invalid:ring-danger/40 data-placeholder:text-muted data-[size=default]:h-9 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 *:data-[slot=select-value]:truncate [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&>span]:truncate",
+ "flex w-fit !cursor-pointer items-center justify-between gap-1.5 rounded-md border border-border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap text-foreground outline-1 outline-offset-4 outline-transparent transition-colors outline-solid select-none hover:border-foreground/20 focus-visible:border-accent focus-visible:outline-accent/60 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger aria-invalid:focus-visible:outline-danger/60 data-placeholder:text-muted data-[size=default]:h-9 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 *:data-[slot=select-value]:truncate [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&>span]:truncate",
className
)}
{...props}
diff --git a/frontend/src/components/v3/generic/TextArea/TextArea.tsx b/frontend/src/components/v3/generic/TextArea/TextArea.tsx
index 6c5f69a273..e8167a9a32 100644
--- a/frontend/src/components/v3/generic/TextArea/TextArea.tsx
+++ b/frontend/src/components/v3/generic/TextArea/TextArea.tsx
@@ -12,7 +12,7 @@ const TextArea = React.forwardRef<
ref={ref}
data-slot="textarea"
className={cn(
- "placeholder:text-muted-foreground flex min-h-16 thin-scrollbar w-full rounded-md border border-border bg-transparent px-3 py-2 text-base text-foreground shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger aria-invalid:ring-danger/40 md:text-sm",
+ "placeholder:text-muted-foreground flex min-h-16 thin-scrollbar w-full rounded-md border border-border bg-transparent px-3 py-2 text-base text-foreground shadow-xs outline-1 outline-offset-4 outline-transparent transition-colors outline-solid hover:border-foreground/20 focus-visible:border-accent focus-visible:outline-accent/60 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger aria-invalid:focus-visible:outline-danger/60 md:text-sm",
className
)}
aria-invalid={isError}
diff --git a/frontend/src/components/v3/generic/index.ts b/frontend/src/components/v3/generic/index.ts
index 9574c7b68e..6af5ea6e55 100644
--- a/frontend/src/components/v3/generic/index.ts
+++ b/frontend/src/components/v3/generic/index.ts
@@ -1,6 +1,7 @@
export * from "./Accordion";
export * from "./Alert";
export * from "./AlertDialog";
+export * from "./AnimatedCollapse";
export * from "./Badge";
export * from "./Breadcrumb";
export * from "./Button";
diff --git a/frontend/src/components/v3/platform/VerificationCode/VerificationCodeForm.stories.tsx b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeForm.stories.tsx
new file mode 100644
index 0000000000..e060beec0e
--- /dev/null
+++ b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeForm.stories.tsx
@@ -0,0 +1,93 @@
+import { useState } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
+
+import { CardContent } from "../../generic/Card";
+import { VerificationCodeForm, VerificationCodeHeader } from "./VerificationCodeForm";
+import { VerificationCodeResend } from "./VerificationCodeResend";
+
+const meta = {
+ title: "Authentication/VerificationCodeForm",
+ component: VerificationCodeForm,
+ parameters: {
+ layout: "centered"
+ },
+ decorators: [
+ (Story) => (
+ <div className="w-[28rem] max-w-[calc(100vw-2rem)]">
+ <Story />
+ </div>
+ )
+ ],
+ tags: ["autodocs"],
+ args: {
+ name: "verification-code",
+ onChange: () => undefined,
+ onSubmit: () => undefined,
+ value: ""
+ }
+} satisfies Meta<typeof VerificationCodeForm>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+const VerificationExample = ({
+ fields = 6,
+ error,
+ resendState = "ready"
+}: {
+ fields?: number;
+ error?: string;
+ resendState?: "ready" | "resending" | "delayed";
+}) => {
+ const [value, setValue] = useState("");
+
+ return (
+ <AuthPagePanel>
+ <VerificationCodeHeader
+ title={fields === 6 ? "We've sent a verification code to" : "Use a recovery code"}
+ recipient={fields === 6 ? "[email protected]" : undefined}
+ description={fields === 8 ? "Enter one of your backup recovery codes." : undefined}
+ />
+ <CardContent>
+ <VerificationCodeForm
+ name={`verification-story-${fields}`}
+ fields={fields}
+ value={value}
+ onChange={setValue}
+ onSubmit={() => undefined}
+ error={error}
+ >
+ {fields === 6 && (
+ <VerificationCodeResend
+ isResending={resendState === "resending"}
+ remainingSeconds={resendState === "delayed" ? 20 : 0}
+ onResend={() => undefined}
+ />
+ )}
+ </VerificationCodeForm>
+ </CardContent>
+ </AuthPagePanel>
+ );
+};
+
+export const EmailCode: Story = {
+ render: () => <VerificationExample />
+};
+
+export const InvalidCode: Story = {
+ render: () => <VerificationExample error="That code is invalid. Try again." />
+};
+
+export const Resending: Story = {
+ render: () => <VerificationExample resendState="resending" />
+};
+
+export const ResendDelayed: Story = {
+ render: () => <VerificationExample resendState="delayed" />
+};
+
+export const RecoveryCode: Story = {
+ render: () => <VerificationExample fields={8} />
+};
diff --git a/frontend/src/components/v3/platform/VerificationCode/VerificationCodeForm.tsx b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeForm.tsx
new file mode 100644
index 0000000000..d83536e668
--- /dev/null
+++ b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeForm.tsx
@@ -0,0 +1,122 @@
+import { ReactNode, useEffect, useState } from "react";
+
+import { AnimatedCollapse } from "../../generic/AnimatedCollapse";
+import { Button } from "../../generic/Button";
+import { CardDescription, CardHeader, CardTitle } from "../../generic/Card";
+import { FieldError } from "../../generic/Field";
+import { VerificationCodeInput } from "./VerificationCodeInput";
+
+type VerificationCodeHeaderProps = {
+ action?: ReactNode;
+ description?: ReactNode;
+ recipient?: string;
+ title: ReactNode;
+};
+
+export const VerificationCodeHeader = ({
+ action,
+ description,
+ recipient,
+ title
+}: VerificationCodeHeaderProps) => (
+ <CardHeader className="mb-6 gap-2">
+ {recipient ? (
+ <>
+ <CardDescription className="ml-0.5 text-base">{title}</CardDescription>
+ <div className="flex min-w-0 items-baseline justify-between gap-3">
+ <div
+ aria-label={recipient}
+ className="ml-0.5 min-w-0 flex-1 truncate font-alliance text-2xl font-normal text-foreground"
+ title={recipient}
+ >
+ {recipient}
+ </div>
+ {action && <div className="shrink-0">{action}</div>}
+ </div>
+ {description && <CardDescription className="ml-0.5">{description}</CardDescription>}
+ </>
+ ) : (
+ <>
+ <CardTitle className="font-alliance text-2xl font-normal">{title}</CardTitle>
+ {description && <CardDescription className="text-base">{description}</CardDescription>}
+ </>
+ )}
+ </CardHeader>
+);
+
+type VerificationCodeFormProps = {
+ children?: ReactNode;
+ error?: ReactNode;
+ fields?: number;
+ isDisabled?: boolean;
+ isPending?: boolean;
+ name: string;
+ onChange: (value: string) => void;
+ onSubmit: () => void | Promise<void>;
+ submitLabel?: ReactNode;
+ value: string;
+};
+
+export const VerificationCodeForm = ({
+ children,
+ error,
+ fields = 6,
+ isDisabled,
+ isPending,
+ name,
+ onChange,
+ onSubmit,
+ submitLabel = "Verify",
+ value
+}: VerificationCodeFormProps) => {
+ const isComplete = value.trim().length === fields;
+ const hasError = Boolean(error);
+ const [hasChangedSinceError, setHasChangedSinceError] = useState(false);
+
+ useEffect(() => {
+ if (hasError && !isPending) {
+ setHasChangedSinceError(false);
+ }
+ }, [hasError, isPending]);
+
+ const handleChange = (nextValue: string) => {
+ if (hasError) setHasChangedSinceError(true);
+ onChange(nextValue);
+ };
+
+ return (
+ <form
+ className="flex flex-col gap-5"
+ onSubmit={(event) => {
+ event.preventDefault();
+ if (!isComplete || isDisabled || isPending) return;
+ onSubmit();
+ }}
+ >
+ <div className="flex flex-col gap-2">
+ <VerificationCodeInput
+ key={`${name}-${fields}`}
+ name={name}
+ fields={fields}
+ onChange={handleChange}
+ value={value}
+ isError={hasError && !hasChangedSinceError}
+ />
+ {error && <FieldError>{error}</FieldError>}
+ </div>
+ <AnimatedCollapse isOpen={isComplete || Boolean(isPending)} contentClassName="px-1">
+ <Button
+ type="submit"
+ variant="project"
+ size="lg"
+ isFullWidth
+ isPending={isPending}
+ isDisabled={!isComplete || isDisabled || isPending}
+ >
+ {submitLabel}
+ </Button>
+ </AnimatedCollapse>
+ {children}
+ </form>
+ );
+};
diff --git a/frontend/src/components/v3/platform/VerificationCode/VerificationCodeInput.tsx b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeInput.tsx
new file mode 100644
index 0000000000..7b1d385e0d
--- /dev/null
+++ b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeInput.tsx
@@ -0,0 +1,48 @@
+/* eslint-disable react/jsx-props-no-spreading */
+import ReactCodeInput from "react-code-input";
+
+import { cn } from "../../utils";
+
+const codeInputStyle = {
+ inputStyle: {
+ fontFamily: "var(--font-jetbrains-mono)",
+ margin: "0",
+ MozAppearance: "textfield",
+ width: "100%",
+ borderRadius: "6px",
+ fontSize: "20px",
+ height: "68px",
+ padding: "0",
+ backgroundColor: "var(--color-container)",
+ color: "var(--color-foreground)",
+ border: "1px solid var(--color-border)",
+ textAlign: "center",
+ outlineColor: "transparent",
+ borderColor: "var(--color-border)"
+ }
+} as const;
+
+type Props = {
+ fields?: number;
+ isError?: boolean;
+ name: string;
+ onChange: (value: string) => void;
+ value?: string;
+};
+
+export const VerificationCodeInput = ({ fields = 6, isError, name, onChange, value }: Props) => (
+ <ReactCodeInput
+ name={name}
+ inputMode={fields === 6 ? "tel" : "latin"}
+ type="text"
+ fields={fields}
+ onChange={onChange}
+ value={value}
+ {...codeInputStyle}
+ className={cn(
+ "code-input-v3",
+ fields === 8 && "code-input-v3-recovery",
+ isError && "code-input-v3-error"
+ )}
+ />
+);
diff --git a/frontend/src/components/v3/platform/VerificationCode/VerificationCodeResend.tsx b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeResend.tsx
new file mode 100644
index 0000000000..61b7b6229e
--- /dev/null
+++ b/frontend/src/components/v3/platform/VerificationCode/VerificationCodeResend.tsx
@@ -0,0 +1,39 @@
+import { useTranslation } from "react-i18next";
+
+type VerificationCodeResendProps = {
+ isDisabled?: boolean;
+ isResending?: boolean;
+ onResend: () => void | Promise<void>;
+ remainingSeconds?: number;
+};
+
+export const VerificationCodeResend = ({
+ isDisabled = false,
+ isResending = false,
+ onResend,
+ remainingSeconds = 0
+}: VerificationCodeResendProps) => {
+ const { t } = useTranslation();
+ const normalizedRemainingSeconds = Math.max(0, Math.ceil(remainingSeconds));
+
+ let resendLabel = String(t("signup.step2-resend-submit"));
+ if (isResending) {
+ resendLabel = String(t("signup.step2-resend-progress"));
+ } else if (normalizedRemainingSeconds > 0) {
+ resendLabel = `${t("signup.step2-resend-submit")} (${normalizedRemainingSeconds}s)`;
+ }
+
+ return (
+ <div className="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-sm">
+ <span className="text-label">{t("signup.step2-resend-alert")}</span>
+ <button
+ className="cursor-pointer text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project disabled:cursor-not-allowed disabled:text-label/60 disabled:no-underline"
+ disabled={isDisabled || isResending || normalizedRemainingSeconds > 0}
+ onClick={onResend}
+ type="button"
+ >
+ {resendLabel}
+ </button>
+ </div>
+ );
+};
diff --git a/frontend/src/components/v3/platform/VerificationCode/index.ts b/frontend/src/components/v3/platform/VerificationCode/index.ts
new file mode 100644
index 0000000000..59a9177c11
--- /dev/null
+++ b/frontend/src/components/v3/platform/VerificationCode/index.ts
@@ -0,0 +1,4 @@
+export * from "./useClientResendDelay";
+export * from "./VerificationCodeForm";
+export * from "./VerificationCodeInput";
+export * from "./VerificationCodeResend";
diff --git a/frontend/src/components/v3/platform/VerificationCode/useClientResendDelay.ts b/frontend/src/components/v3/platform/VerificationCode/useClientResendDelay.ts
new file mode 100644
index 0000000000..7dc383afd8
--- /dev/null
+++ b/frontend/src/components/v3/platform/VerificationCode/useClientResendDelay.ts
@@ -0,0 +1,33 @@
+import { useCallback, useEffect, useState } from "react";
+
+// UX-only delay. This does not enforce throttling or replace server-side rate limits.
+export const useClientResendDelay = (delaySeconds: number) => {
+ const [delayEndTime, setDelayEndTime] = useState(() =>
+ delaySeconds > 0 ? Date.now() + delaySeconds * 1000 : 0
+ );
+ const [remainingSeconds, setRemainingSeconds] = useState(() =>
+ Math.max(0, Math.ceil((delayEndTime - Date.now()) / 1000))
+ );
+
+ useEffect(() => {
+ const updateRemainingSeconds = () => {
+ setRemainingSeconds(Math.max(0, Math.ceil((delayEndTime - Date.now()) / 1000)));
+ };
+
+ updateRemainingSeconds();
+ if (delayEndTime <= Date.now()) return undefined;
+
+ const timer = window.setInterval(() => {
+ const nextRemainingSeconds = Math.max(0, Math.ceil((delayEndTime - Date.now()) / 1000));
+ setRemainingSeconds(nextRemainingSeconds);
+ if (nextRemainingSeconds === 0) window.clearInterval(timer);
+ }, 1000);
+ return () => window.clearInterval(timer);
+ }, [delayEndTime]);
+
+ const restartDelay = useCallback(() => {
+ setDelayEndTime(Date.now() + delaySeconds * 1000);
+ }, [delaySeconds]);
+
+ return { remainingSeconds, restartDelay };
+};
diff --git a/frontend/src/components/v3/platform/index.ts b/frontend/src/components/v3/platform/index.ts
index 852fa48a4e..07c4573ddd 100644
--- a/frontend/src/components/v3/platform/index.ts
+++ b/frontend/src/components/v3/platform/index.ts
@@ -8,3 +8,4 @@ export * from "./PermissionActionSelect";
export * from "./ScopeIcons";
export * from "./SecretInput";
export * from "./SecretPathInput";
+export * from "./VerificationCode";
diff --git a/frontend/src/const.ts b/frontend/src/const.ts
index 7714e67482..a0897dfa37 100644
--- a/frontend/src/const.ts
+++ b/frontend/src/const.ts
@@ -7,6 +7,8 @@ export const publicPaths = [
"/signup/sso",
"/login",
"/login/ldap",
+ "/login/oidc",
+ "/login/saml",
"/blog",
"/docs",
"/changelog",
@@ -21,7 +23,6 @@ export const publicPaths = [
"/password-reset",
"/saml-sso",
"/login/provider/error",
- "/login/sso",
"/admin/signup",
"/shared/secret/[id]",
"/secret-request/secret/[id]",
diff --git a/frontend/src/hooks/api/admin/types.ts b/frontend/src/hooks/api/admin/types.ts
index d9c3977fdb..c47faccc7f 100644
--- a/frontend/src/hooks/api/admin/types.ts
+++ b/frontend/src/hooks/api/admin/types.ts
@@ -13,6 +13,21 @@ export enum LoginMethod {
OIDC = "oidc"
}
+export type TPasswordPolicyRequirement = {
+ code: string;
+ message: string;
+ validationMessage: string;
+ isPrimary: boolean;
+ patterns: string[];
+ flags?: string;
+ maxConsecutiveCharacters?: number;
+ shouldMatch: boolean;
+};
+
+export type TPasswordPolicy = {
+ requirements: TPasswordPolicyRequirement[];
+};
+
export type OrganizationWithProjects = Organization & {
members: {
user: {
@@ -60,6 +75,7 @@ export type TServerConfig = {
defaultAuthOrgAuthMethod?: string | null;
defaultAuthOrgAuthEnforced?: boolean | null;
enabledLoginMethods: LoginMethod[];
+ passwordPolicy: TPasswordPolicy;
authConsentContent?: string;
pageFrameContent?: string;
invalidatingCache: boolean;
diff --git a/frontend/src/hooks/api/auth/refresh.ts b/frontend/src/hooks/api/auth/refresh.ts
index 59ac07b01e..2d1e621480 100644
--- a/frontend/src/hooks/api/auth/refresh.ts
+++ b/frontend/src/hooks/api/auth/refresh.ts
@@ -20,6 +20,17 @@ if (tokenBroadcastChannel) {
// Shared promise to deduplicate concurrent refresh calls
let activeRefreshPromise: Promise<GetAuthTokenAPI> | null = null;
+export const shouldRetryAuthTokenFetch = (failureCount: number, error: unknown) => {
+ if (
+ axios.isAxiosError(error) &&
+ (error.response?.status === 401 || error.response?.status === 404)
+ ) {
+ return false;
+ }
+
+ return failureCount < 1;
+};
+
/**
* Refresh the auth token using the httpOnly refresh token cookie.
* If an in-memory token already exists (e.g. after selectOrganization),
diff --git a/frontend/src/hooks/api/users/queries.tsx b/frontend/src/hooks/api/users/queries.tsx
index 837712a9b2..90966270c4 100644
--- a/frontend/src/hooks/api/users/queries.tsx
+++ b/frontend/src/hooks/api/users/queries.tsx
@@ -4,6 +4,7 @@ import { AxiosError } from "axios";
import { apiRequest } from "@app/config/request";
import { SessionStorageKeys } from "@app/const";
+import { adminQueryKeys } from "@app/hooks/api/admin/queries";
import { getAuthToken, queryClient as qc } from "@app/hooks/api/reactQuery";
import { authKeys } from "../auth/queries";
@@ -331,6 +332,8 @@ export const logoutUser = async () => {
// Utility function to clear session storage and query cache
export const clearSession = () => {
+ const serverConfig = qc.getQueryData(adminQueryKeys.serverConfig());
+
setAuthToken(""); // Clear authentication token
localStorage.removeItem("protectedKey");
localStorage.removeItem("protectedKeyIV");
@@ -344,6 +347,12 @@ export const clearSession = () => {
sessionStorage.removeItem(SessionStorageKeys.CLI_TERMINAL_TOKEN);
qc.clear();
+
+ // Server configuration is public and required to render authentication routes.
+ // Preserve it so delayed logout cleanup cannot suspend and remount the login page.
+ if (serverConfig !== undefined) {
+ qc.setQueryData(adminQueryKeys.serverConfig(), serverConfig);
+ }
};
let logoutTimer: ReturnType<typeof setTimeout> | null = null;
diff --git a/frontend/src/hooks/useLastLogin.ts b/frontend/src/hooks/useLastLogin.ts
index e15586cae9..41da95885c 100644
--- a/frontend/src/hooks/useLastLogin.ts
+++ b/frontend/src/hooks/useLastLogin.ts
@@ -5,18 +5,66 @@ import { LoginMethod } from "@app/hooks/api/admin/types";
import { useLocalStorageState } from "./useLocalStorageState";
const LAST_LOGIN_KEY = "infisical.lastLogin";
+export const LEGACY_GENERIC_SSO_LOGIN_METHOD = "sso" as const;
-export type LastLogin = {
- method: LoginMethod;
+type SsoLoginMethod = LoginMethod.SAML | LoginMethod.OIDC;
+type DirectLoginMethod = Exclude<LoginMethod, SsoLoginMethod | LoginMethod.LDAP>;
+type LastLoginIdentifier = {
+ type: "email" | "orgSlug";
+ value: string;
+};
+
+export type LastLoginEntry =
+ | {
+ method: SsoLoginMethod;
+ identifier: LastLoginIdentifier;
+ }
+ | {
+ method: LoginMethod.LDAP;
+ organizationSlug?: string;
+ }
+ | {
+ method: DirectLoginMethod;
+ };
+
+export type LastLogin = LastLoginEntry & { timestamp: number };
+
+type LegacyLastLogin = {
+ identifierType?: LastLoginIdentifier["type"];
+ method: LoginMethod | typeof LEGACY_GENERIC_SSO_LOGIN_METHOD;
orgSlug?: string;
timestamp: number;
};
+export type StoredLastLogin = LastLogin | LegacyLastLogin;
+
+export const getLastLoginIdentifier = (
+ lastLogin: StoredLastLogin | null
+): LastLoginIdentifier | undefined => {
+ if (!lastLogin) return undefined;
+ if ("identifier" in lastLogin) return lastLogin.identifier;
+ if (!("identifierType" in lastLogin) || !lastLogin.identifierType || !lastLogin.orgSlug) {
+ return undefined;
+ }
+
+ return { type: lastLogin.identifierType, value: lastLogin.orgSlug };
+};
+
+export const getLastLoginOrganizationSlug = (lastLogin: StoredLastLogin | null) => {
+ if (lastLogin?.method !== LoginMethod.LDAP) return undefined;
+ if ("organizationSlug" in lastLogin) return lastLogin.organizationSlug;
+
+ return "orgSlug" in lastLogin ? lastLogin.orgSlug : undefined;
+};
+
export const useLastLogin = () => {
- const [lastLogin, setLastLogin] = useLocalStorageState<LastLogin | null>(LAST_LOGIN_KEY, null);
+ const [lastLogin, setLastLogin] = useLocalStorageState<StoredLastLogin | null>(
+ LAST_LOGIN_KEY,
+ null
+ );
const saveLastLogin = useCallback(
- (entry: Omit<LastLogin, "timestamp">) => {
+ (entry: LastLoginEntry) => {
setLastLogin({ ...entry, timestamp: Date.now() });
},
[setLastLogin]
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 8c5fd69f6d..8f91b979ad 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -3,6 +3,14 @@
@source not "../public";
+@font-face {
+ font-family: "Alliance No. 2";
+ src: url("/fonts/AllianceNo2-Regular.otf") format("opentype");
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+}
+
/*
The default border color has changed to `currentcolor` in Tailwind CSS v4,
so we've added these compatibility styles to make sure everything still
@@ -55,7 +63,9 @@
--breakpoint-dashboard: 1400px;
/* Fonts */
+ --font-alliance: "Alliance No. 2", sans-serif;
--font-inter: "Inter", sans-serif;
+ --font-jetbrains-mono: "JetBrains Mono", monospace;
--max-width-8xl: 88rem; /* 1408px */
/* Colors v2 */
@@ -230,6 +240,10 @@
height: inherit;
}
+@utility text-highlight {
+ @apply bg-project px-1.5 pt-1.5 pb-0.5 text-background;
+}
+
@utility secret-table {
width: 100%;
background: var(--color-mineshaft-800);
@@ -494,9 +508,54 @@ input[type="number"]::-webkit-outer-spin-button {
margin: 0;
}
-/* v3-style focus ring for ReactCodeInput */
+/* v3-style focus treatment for ReactCodeInput */
+.code-input-v3 {
+ display: grid !important;
+ width: 100%;
+ grid-template-columns: repeat(6, minmax(0, 1fr));
+ gap: 0.75rem;
+}
+
+.code-input-v3 input {
+ min-width: 0;
+ width: 100% !important;
+ outline: 1px solid transparent !important;
+ outline-offset: 4px;
+ transition:
+ border-color 150ms,
+ outline-color 150ms;
+}
+
+.code-input-v3 input:hover {
+ border-color: color-mix(in srgb, var(--color-foreground) 20%, transparent) !important;
+}
+
.code-input-v3 input:focus {
- outline: none;
- border-color: var(--color-ring) !important;
- box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-ring) 50%, transparent);
+ border-color: color-mix(in srgb, var(--color-project) 45%, var(--color-border)) !important;
+ outline-color: color-mix(in srgb, var(--color-project) 45%, transparent) !important;
+ box-shadow: none;
+}
+
+.code-input-v3-recovery {
+ grid-template-columns: repeat(8, minmax(0, 1fr));
+ gap: 0.5rem;
+}
+
+@media (width < 40rem) {
+ .code-input-v3 {
+ gap: 0.5rem;
+ }
+
+ .code-input-v3 input {
+ height: auto !important;
+ aspect-ratio: 1;
+ }
+
+ .code-input-v3-recovery {
+ gap: 0.375rem;
+ }
+}
+
+.code-input-v3-error input {
+ border-color: color-mix(in srgb, var(--color-danger) 55%, var(--color-border)) !important;
}
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
index 489a516106..7ace4ad0c7 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
@@ -292,14 +292,12 @@ export const Navbar = () => {
if (shouldShowMfa) {
return (
- <div className="flex max-h-screen min-h-screen flex-col items-center justify-center gap-2 overflow-y-auto bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <Mfa
- email={user.email as string}
- method={requiredMfaMethod}
- successCallback={mfaSuccessCallback}
- closeMfa={() => toggleShowMfa.off()}
- />
- </div>
+ <Mfa
+ email={user.email as string}
+ method={requiredMfaMethod}
+ successCallback={mfaSuccessCallback}
+ closeMfa={() => toggleShowMfa.off()}
+ />
);
}
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index af18f6debf..658cca56d8 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -15,6 +15,8 @@ import { routeTree } from "./routeTree.gen";
import "@fontsource/inter/400.css";
import "@fontsource/inter/500.css";
import "@fontsource/inter/600.css";
+import "@fontsource/jetbrains-mono/400.css";
+import "@fontsource/jetbrains-mono/500.css";
import "@xyflow/react/dist/style.css";
import "nprogress/nprogress.css";
import "@fortawesome/fontawesome-svg-core/styles.css";
diff --git a/frontend/src/pages/MfaSessionPage/MfaSessionPage.tsx b/frontend/src/pages/MfaSessionPage/MfaSessionPage.tsx
index 643e02b386..01e7a54217 100644
--- a/frontend/src/pages/MfaSessionPage/MfaSessionPage.tsx
+++ b/frontend/src/pages/MfaSessionPage/MfaSessionPage.tsx
@@ -1,11 +1,17 @@
-import { useEffect, useState } from "react";
-import ReactCodeInput from "react-code-input";
+import { ReactNode, useEffect, useState } from "react";
import { startAuthentication } from "@simplewebauthn/browser";
import { useParams } from "@tanstack/react-router";
-import Error from "@app/components/basic/Error";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { createNotification } from "@app/components/notifications";
-import { Button } from "@app/components/v2";
+import {
+ Button,
+ CardContent,
+ FieldError,
+ VerificationCodeForm,
+ VerificationCodeHeader
+} from "@app/components/v3";
import { isMfaLockoutError, stashMfaLockoutError } from "@app/helpers/mfaSession";
import { MfaMethod } from "@app/hooks/api/auth/types";
import {
@@ -15,43 +21,11 @@ import {
} from "@app/hooks/api/mfaSession";
import { useGenerateAuthenticationOptions, useVerifyAuthentication } from "@app/hooks/api/webauthn";
-const codeInputProps = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "55px",
- borderRadius: "5px",
- fontSize: "24px",
- height: "55px",
- paddingLeft: "7",
- backgroundColor: "#0d1117",
- color: "white",
- border: "1px solid #2d2f33",
- textAlign: "center",
- outlineColor: "#8ca542",
- borderColor: "#2d2f33"
- }
-} as const;
-
-const codeInputPropsPhone = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "40px",
- borderRadius: "5px",
- fontSize: "24px",
- height: "40px",
- paddingLeft: "7",
- backgroundColor: "#0d1117",
- color: "white",
- border: "1px solid #2d2f33",
- textAlign: "center",
- outlineColor: "#8ca542",
- borderColor: "#2d2f33"
- }
-} as const;
+const MfaAuthPage = ({ children }: { children: ReactNode }) => (
+ <AuthPageLayout variant="focused" showFooter={false}>
+ <AuthPagePanel>{children}</AuthPagePanel>
+ </AuthPageLayout>
+);
export const MfaSessionPage = () => {
const { mfaSessionId } = useParams({ strict: false }) as { mfaSessionId: string };
@@ -96,9 +70,7 @@ export const MfaSessionPage = () => {
const isCodeComplete = mfaCode.length === getExpectedCodeLength();
- const handleVerifyMfa = async (event: React.FormEvent<HTMLFormElement>) => {
- event.preventDefault();
-
+ const handleVerifyMfa = async () => {
if (!mfaCode.trim() || !isCodeComplete || !sessionStatus?.mfaMethod) return;
setIsLoading(true);
@@ -195,134 +167,77 @@ export const MfaSessionPage = () => {
if (isStatusError) {
return (
- <div className="flex min-h-screen flex-col items-center justify-center bg-bunker-800 bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <div className="mx-auto w-max pt-6 pb-6 md:mb-16 md:px-8">
- <div className="mb-4 flex justify-center">
- <img src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical logo" />
- </div>
- <div className="mb-6 text-center">
- <h2 className="mb-3 text-xl font-medium text-red-400">Session Expired</h2>
- <p className="text-bunker-300">
- This MFA session has expired or is invalid. Please try your action again.
- </p>
- </div>
- </div>
- </div>
+ <MfaAuthPage>
+ <VerificationCodeHeader
+ title={<span className="text-danger">Session expired</span>}
+ description="This MFA session has expired or is invalid. Please try your action again."
+ />
+ </MfaAuthPage>
);
}
if (!sessionStatus) {
return (
- <div className="flex min-h-screen flex-col items-center justify-center bg-bunker-800 bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <div className="text-center">
- <div className="mb-4 text-bunker-300">Loading...</div>
- </div>
- </div>
+ <MfaAuthPage>
+ <VerificationCodeHeader title="Loading verification…" />
+ </MfaAuthPage>
);
}
if (sessionStatus.status === MfaSessionStatus.ACTIVE) {
return (
- <div className="flex min-h-screen flex-col items-center justify-center bg-bunker-800 bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <div className="mx-auto w-max pt-6 pb-6 md:mb-16 md:px-8">
- <div className="mb-4 flex justify-center">
- <img src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical logo" />
- </div>
- <div className="mb-6 text-center">
- <h2 className="mb-3 text-xl font-medium text-bunker-50">Verification Complete</h2>
- <p className="text-bunker-300">This window will close automatically...</p>
- </div>
- </div>
- </div>
+ <MfaAuthPage>
+ <VerificationCodeHeader
+ title="Verification complete"
+ description="This window will close automatically…"
+ />
+ </MfaAuthPage>
);
}
return (
- <div className="flex min-h-screen flex-col items-center justify-center bg-bunker-800 bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <div className="mx-auto w-max pt-6 pb-6 md:mb-16 md:px-8">
- <div className="mb-4 flex justify-center">
- <img src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical logo" />
- </div>
-
- <div className="mb-8 text-center">
- <h2 className="mb-3 text-xl font-medium text-bunker-100">Two-Factor Authentication</h2>
- <p className="mx-auto max-w-md text-sm leading-relaxed text-bunker-300">
+ <MfaAuthPage>
+ <VerificationCodeHeader
+ title="Two-factor authentication"
+ description={
+ <>
{sessionStatus.mfaMethod === MfaMethod.EMAIL &&
- "Enter the verification code sent to your email"}
+ "Enter the verification code sent to your email."}
{sessionStatus.mfaMethod === MfaMethod.TOTP &&
- "Enter the verification code from your authenticator app"}
+ "Enter the verification code from your authenticator app."}
{sessionStatus.mfaMethod === MfaMethod.WEBAUTHN &&
- "Use your registered passkey to complete two-factor authentication"}
- </p>
- </div>
+ "Use your registered passkey to continue."}
+ </>
+ }
+ />
+ <CardContent className="flex flex-col gap-5">
{sessionStatus.mfaMethod === MfaMethod.WEBAUTHN ? (
- <>
- {error && <Error text={error} />}
- <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">
- <Button
- size="md"
- onClick={handleWebAuthnVerification}
- isFullWidth
- className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"
- colorSchema="primary"
- variant="outline_bg"
- isLoading={isLoading}
- >
- Authenticate with Passkey
- </Button>
- </div>
- </>
+ <div className="flex flex-col gap-2">
+ <Button
+ size="lg"
+ onClick={handleWebAuthnVerification}
+ isFullWidth
+ variant="project"
+ isPending={isLoading}
+ isDisabled={isLoading}
+ >
+ Authenticate with passkey
+ </Button>
+ {error && <FieldError>{error}</FieldError>}
+ </div>
) : (
- <form onSubmit={handleVerifyMfa}>
- <div className="mx-auto hidden md:block" style={{ minWidth: "600px" }}>
- <div className="mt-8 mb-6 flex justify-center">
- <ReactCodeInput
- key={`code-input-desktop-${codeInputKey}`}
- name=""
- inputMode="tel"
- type="text"
- fields={getExpectedCodeLength()}
- onChange={setMfaCode}
- value={mfaCode}
- className="mb-2"
- {...codeInputProps}
- />
- </div>
- </div>
- <div className="mx-auto mt-4 block md:hidden" style={{ minWidth: "400px" }}>
- <div className="mt-4 mb-6 flex justify-center">
- <ReactCodeInput
- key={`code-input-phone-${codeInputKey}`}
- name=""
- inputMode="tel"
- type="text"
- fields={getExpectedCodeLength()}
- onChange={setMfaCode}
- value={mfaCode}
- className="mb-2"
- {...codeInputPropsPhone}
- />
- </div>
- </div>
- {error && <Error text={error} />}
- <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">
- <Button
- size="md"
- type="submit"
- isFullWidth
- className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"
- colorSchema="primary"
- variant="outline_bg"
- isLoading={isLoading}
- isDisabled={!isCodeComplete}
- >
- Verify
- </Button>
- </div>
- </form>
+ <VerificationCodeForm
+ key={codeInputKey}
+ name="mfa-session-code"
+ value={mfaCode}
+ onChange={setMfaCode}
+ onSubmit={() => handleVerifyMfa()}
+ isPending={isLoading}
+ error={error}
+ />
)}
- </div>
- </div>
+ </CardContent>
+ </MfaAuthPage>
);
};
diff --git a/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx b/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx
index 52c8526f51..0d8a9eb722 100644
--- a/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx
+++ b/frontend/src/pages/admin/SignUpPage/SignUpPage.tsx
@@ -1,77 +1,29 @@
import { Helmet } from "react-helmet";
-import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
-import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
-import { AnimatePresence, motion } from "framer-motion";
-import { z } from "zod";
-// TODO(akhilmhdh): rewrite this into module functions in lib
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import SecurityClient from "@app/components/utilities/SecurityClient";
-import { Button, ContentLoader, FormControl, Input } from "@app/components/v2";
-import { useServerConfig } from "@app/context";
-import { useCreateAdminUser, useSelectOrganization } from "@app/hooks/api";
+import { CardContent, CardDescription, CardHeader, CardTitle } from "@app/components/v3";
+import { useSelectOrganization } from "@app/hooks/api";
-const formSchema = z
- .object({
- email: z.string().email().trim(),
- firstName: z.string().trim(),
- lastName: z.string().trim().optional(),
- password: z.string().trim().min(14).max(100),
- confirmPassword: z.string().trim()
- })
- .refine((data) => data.password === data.confirmPassword, {
- message: "Password don't match",
- path: ["confirmPassword"]
- });
-
-type TFormSchema = z.infer<typeof formSchema>;
+import { AdminSignUpForm } from "./components/AdminSignUpForm";
export const SignUpPage = () => {
const { t } = useTranslation();
const navigate = useNavigate();
- const {
- control,
- handleSubmit,
- formState: { isSubmitting }
- } = useForm<TFormSchema>({
- resolver: zodResolver(formSchema)
- });
-
- const { config } = useServerConfig();
- const { mutateAsync: createAdminUser } = useCreateAdminUser();
const { mutateAsync: selectOrganization } = useSelectOrganization();
- const handleFormSubmit = async ({ email, password, firstName, lastName }: TFormSchema) => {
- // avoid multi submission
- if (isSubmitting) return;
- const res = await createAdminUser({
- email,
- password,
- firstName,
- lastName
- });
-
- SecurityClient.setToken(res.token);
- await selectOrganization({ organizationId: res.organization.id });
-
- // TODO(akhilmhdh): This is such a confusing pattern and too unreliable
- // Will be refactored in next iteration to make it url based rather than local storage ones
- // Part of migration to nextjs 14
- localStorage.setItem("orgData.id", res.organization.id);
+ const handleSuccess = async (result: { token: string; organization: { id: string } }) => {
+ SecurityClient.setToken(result.token);
+ await selectOrganization({ organizationId: result.organization.id });
+ localStorage.setItem("orgData.id", result.organization.id);
navigate({ to: "/admin" });
};
- if (config?.initialized) {
- return (
- <div className="flex min-h-screen flex-col justify-center bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <ContentLoader text="Redirecting to admin page..." />
- </div>
- );
- }
-
return (
- <div className="flex max-h-screen min-h-screen flex-col justify-center overflow-y-auto bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700 px-6">
+ <AuthPageLayout variant="focused">
<Helmet>
<title>{t("common.head-title", { title: t("signup.title") })}</title>
<link rel="icon" href="/infisical.ico" />
@@ -79,101 +31,19 @@ export const SignUpPage = () => {
<meta property="og:title" content={t("signup.og-title") ?? ""} />
<meta name="og:description" content={t("signup.og-description") ?? ""} />
</Helmet>
- <div className="flex items-center justify-center">
- <AnimatePresence mode="wait">
- <motion.div
- className="text-mineshaft-200"
- key="panel-1"
- transition={{ duration: 0.15 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: 30 }}
- >
- <div className="flex flex-col items-center space-y-2 text-center">
- <img src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical logo" />
- <div className="pt-4 text-4xl">Welcome to Infisical</div>
- <div className="pb-4 text-bunker-300">Create your first Super Admin Account</div>
- </div>
- <form onSubmit={handleSubmit(handleFormSubmit)}>
- <div className="mt-8">
- <div className="flex items-center space-x-4">
- <Controller
- control={control}
- name="firstName"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="First name"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Input isFullWidth size="md" {...field} />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="lastName"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Last name"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Input isFullWidth size="md" {...field} />
- </FormControl>
- )}
- />
- </div>
- <Controller
- control={control}
- name="email"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Email" errorText={error?.message} isError={Boolean(error)}>
- <Input isFullWidth size="md" {...field} />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="password"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Password"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Input isFullWidth size="md" type="password" {...field} />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="confirmPassword"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Confirm password"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Input isFullWidth size="md" type="password" {...field} />
- </FormControl>
- )}
- />
- </div>
- <Button
- type="submit"
- colorSchema="primary"
- variant="outline_bg"
- isFullWidth
- className="mt-4"
- isLoading={isSubmitting}
- >
- Continue
- </Button>
- </form>
- </motion.div>
- </AnimatePresence>
- </div>
- </div>
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2">
+ <CardTitle className="font-alliance text-2xl font-normal">
+ Set up your Infisical instance
+ </CardTitle>
+ <CardDescription className="font-alliance text-base">
+ Create a local Super Admin account
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <AdminSignUpForm onSuccess={handleSuccess} />
+ </CardContent>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/admin/SignUpPage/adminSignUpSchema.ts b/frontend/src/pages/admin/SignUpPage/adminSignUpSchema.ts
new file mode 100644
index 0000000000..b51ce95bc2
--- /dev/null
+++ b/frontend/src/pages/admin/SignUpPage/adminSignUpSchema.ts
@@ -0,0 +1,20 @@
+import { z } from "zod";
+
+import { createPasswordSchema } from "@app/components/utilities/checks/password/passwordPolicy";
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
+
+export const createAdminSignUpSchema = (passwordPolicy: TPasswordPolicy) =>
+ z
+ .object({
+ firstName: z.string().trim().min(1, "First name is required"),
+ lastName: z.string().trim().optional(),
+ email: z.string().trim().min(1, "Email is required").email("Enter a valid email address"),
+ password: createPasswordSchema(passwordPolicy),
+ confirmPassword: z.string().min(1, "Please confirm your password")
+ })
+ .refine(({ confirmPassword, password }) => confirmPassword === password, {
+ message: "Passwords do not match",
+ path: ["confirmPassword"]
+ });
+
+export type AdminSignUpFormData = z.infer<ReturnType<typeof createAdminSignUpSchema>>;
diff --git a/frontend/src/pages/admin/SignUpPage/components/AdminSignUpForm.tsx b/frontend/src/pages/admin/SignUpPage/components/AdminSignUpForm.tsx
new file mode 100644
index 0000000000..474e33e3c1
--- /dev/null
+++ b/frontend/src/pages/admin/SignUpPage/components/AdminSignUpForm.tsx
@@ -0,0 +1,223 @@
+import { useState } from "react";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import axios from "axios";
+import { Check, Eye, EyeOff, X } from "lucide-react";
+
+import { PasswordField } from "@app/components/auth/PasswordField";
+import { usePasswordBreachCheck } from "@app/components/utilities/checks/password/usePasswordBreachCheck";
+import {
+ Alert,
+ AlertDescription,
+ AnimatedCollapse,
+ Button,
+ Field,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput
+} from "@app/components/v3";
+import { useServerConfig } from "@app/context";
+import { useCreateAdminUser } from "@app/hooks/api";
+
+import { AdminSignUpFormData, createAdminSignUpSchema } from "../adminSignUpSchema";
+
+type AdminSignUpResult = {
+ token: string;
+ organization: { id: string };
+};
+
+type AdminSignUpFormProps = {
+ onSuccess: (result: AdminSignUpResult) => Promise<void>;
+};
+
+export const AdminSignUpForm = ({ onSuccess }: AdminSignUpFormProps) => {
+ const [formError, setFormError] = useState<string>();
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
+ const { config } = useServerConfig();
+ const { mutateAsync: createAdminUser } = useCreateAdminUser();
+ const {
+ formState: { errors, isSubmitting, submitCount },
+ handleSubmit,
+ register,
+ setError,
+ watch
+ } = useForm<AdminSignUpFormData>({
+ resolver: zodResolver(createAdminSignUpSchema(config.passwordPolicy)),
+ mode: "onChange",
+ reValidateMode: "onChange",
+ defaultValues: {
+ firstName: "",
+ lastName: "",
+ email: "",
+ password: "",
+ confirmPassword: ""
+ }
+ });
+
+ const password = watch("password");
+ const { breachStatus: passwordBreachStatus, validatePassword } = usePasswordBreachCheck({
+ password,
+ policy: config.passwordPolicy
+ });
+ const confirmPassword = watch("confirmPassword");
+
+ const onSubmit = async ({ confirmPassword: _, ...values }: AdminSignUpFormData) => {
+ setFormError(undefined);
+ const latestBreachStatus = await validatePassword(values.password);
+
+ if (latestBreachStatus === "breached") {
+ setError("password", {
+ type: "validate",
+ message: "This password was found in a known data breach."
+ });
+ return;
+ }
+
+ try {
+ const result = await createAdminUser({
+ ...values,
+ lastName: values.lastName || undefined
+ });
+ await onSuccess(result);
+ } catch (error) {
+ const message = axios.isAxiosError<{ message?: string }>(error)
+ ? error.response?.data?.message
+ : undefined;
+ setFormError(message || "Unable to create the administrator account. Please try again.");
+ }
+ };
+
+ const showDangerState = submitCount > 0;
+ const isPasswordValidated =
+ passwordBreachStatus === "safe" || passwordBreachStatus === "unavailable";
+ const doPasswordsMatch = confirmPassword.length > 0 && password === confirmPassword;
+ const canSubmit = isPasswordValidated && !isSubmitting;
+
+ return (
+ <form className="flex flex-col gap-4" noValidate onSubmit={handleSubmit(onSubmit)}>
+ {formError && (
+ <Alert variant="danger">
+ <AlertDescription>{formError}</AlertDescription>
+ </Alert>
+ )}
+ <FieldGroup>
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <Field data-invalid={showDangerState && Boolean(errors.firstName)}>
+ <FieldLabel className="sr-only" htmlFor="admin-signup-first-name">
+ First Name
+ </FieldLabel>
+ <Input
+ {...register("firstName")}
+ id="admin-signup-first-name"
+ placeholder="First Name"
+ autoComplete="given-name"
+ isError={showDangerState && Boolean(errors.firstName)}
+ />
+ {showDangerState && errors.firstName ? (
+ <FieldError>{errors.firstName.message}</FieldError>
+ ) : null}
+ </Field>
+ <Field data-invalid={showDangerState && Boolean(errors.lastName)}>
+ <FieldLabel className="sr-only" htmlFor="admin-signup-last-name">
+ Last Name
+ </FieldLabel>
+ <Input
+ {...register("lastName")}
+ id="admin-signup-last-name"
+ placeholder="Last Name"
+ autoComplete="family-name"
+ isError={showDangerState && Boolean(errors.lastName)}
+ />
+ {showDangerState && errors.lastName ? (
+ <FieldError>{errors.lastName.message}</FieldError>
+ ) : null}
+ </Field>
+ </div>
+ <Field data-invalid={showDangerState && Boolean(errors.email)}>
+ <FieldLabel className="sr-only" htmlFor="admin-signup-email">
+ Email
+ </FieldLabel>
+ <Input
+ {...register("email")}
+ id="admin-signup-email"
+ type="email"
+ placeholder="Email"
+ autoComplete="email"
+ isError={showDangerState && Boolean(errors.email)}
+ />
+ {showDangerState && errors.email ? <FieldError>{errors.email.message}</FieldError> : null}
+ </Field>
+ <PasswordField
+ id="admin-signup-password"
+ value={password}
+ policy={config.passwordPolicy}
+ breachStatus={passwordBreachStatus}
+ placeholder="••••••••"
+ registration={register("password")}
+ error={showDangerState ? errors.password : undefined}
+ submitCount={submitCount}
+ />
+ <AnimatedCollapse
+ isOpen={isPasswordValidated}
+ contentClassName={isPasswordValidated ? "overflow-visible" : undefined}
+ >
+ <Field data-invalid={showDangerState && Boolean(errors.confirmPassword)}>
+ <FieldLabel htmlFor="admin-signup-confirm-password">Confirm Password</FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ {...register("confirmPassword")}
+ id="admin-signup-confirm-password"
+ type={showConfirmPassword ? "text" : "password"}
+ placeholder="••••••••"
+ autoComplete="new-password"
+ aria-invalid={showDangerState && Boolean(errors.confirmPassword)}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ onClick={() => setShowConfirmPassword((current) => !current)}
+ aria-label={
+ showConfirmPassword
+ ? "Hide password confirmation"
+ : "Show password confirmation"
+ }
+ >
+ {showConfirmPassword ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ <AnimatedCollapse isOpen={confirmPassword.length > 0}>
+ <div className="flex items-start gap-2 pt-1 text-xs" aria-live="polite">
+ {doPasswordsMatch ? (
+ <Check className="mt-0.5 size-3.5 shrink-0 text-success" />
+ ) : (
+ <X className="mt-0.5 size-3.5 shrink-0 text-danger" />
+ )}
+ <span className={doPasswordsMatch ? "text-muted" : "text-danger"}>
+ {doPasswordsMatch ? "Passwords match" : "Passwords do not match"}
+ </span>
+ </div>
+ </AnimatedCollapse>
+ {showDangerState && errors.confirmPassword ? (
+ <FieldError>{errors.confirmPassword.message}</FieldError>
+ ) : null}
+ </Field>
+ </AnimatedCollapse>
+ </FieldGroup>
+ <Button
+ type="submit"
+ variant="project"
+ size="lg"
+ isFullWidth
+ isPending={isSubmitting}
+ isDisabled={!canSubmit}
+ >
+ Create Super Admin
+ </Button>
+ </form>
+ );
+};
diff --git a/frontend/src/pages/auth/AccountRecoveryEmailPage/AccountRecoveryEmailPage.tsx b/frontend/src/pages/auth/AccountRecoveryEmailPage/AccountRecoveryEmailPage.tsx
index a965bb3ca9..28a1de2bb9 100644
--- a/frontend/src/pages/auth/AccountRecoveryEmailPage/AccountRecoveryEmailPage.tsx
+++ b/frontend/src/pages/auth/AccountRecoveryEmailPage/AccountRecoveryEmailPage.tsx
@@ -1,12 +1,12 @@
import { FormEvent, useState } from "react";
import { Helmet } from "react-helmet";
import { Link } from "@tanstack/react-router";
+import { MailCheck } from "lucide-react";
-import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";
-import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";
-import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { EmailServiceSetupModal } from "@app/components/v2";
-import { Button, Card, CardContent, CardHeader, CardTitle, Input } from "@app/components/v3";
+import { Button, CardContent, CardHeader, CardTitle, Input } from "@app/components/v3";
import { usePopUp } from "@app/hooks";
import { useSendAccountRecoveryEmail } from "@app/hooks/api";
import { useFetchServerStatus } from "@app/hooks/api/serverDetails";
@@ -44,8 +44,7 @@ export const AccountRecoveryEmailPage = () => {
};
return (
- <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4">
- <AuthPageBackground />
+ <AuthPageLayout variant="focused">
<Helmet>
<title>Account Recovery</title>
<link rel="icon" href="/infisical.ico" />
@@ -56,80 +55,74 @@ export const AccountRecoveryEmailPage = () => {
content="Infisical a simple end-to-end encrypted platform that enables teams to sync and manage their .env files."
/>
</Helmet>
- <AuthPageHeader>
- <Button asChild>
- <Link to="/login">Log In</Link>
- </Button>
- </AuthPageHeader>
- <div className="relative z-10 my-auto flex flex-col items-center py-10">
+ <div className="flex flex-col items-center">
{step === 1 && (
- <form onSubmit={onSubmit} className="mx-auto w-full max-w-sm">
- <Card className="w-full items-stretch gap-0 p-6">
- <CardHeader className="mb-4 gap-4">
- <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.35rem] font-medium text-transparent">
+ <form onSubmit={onSubmit} className="w-full">
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2">
+ <CardTitle className="font-alliance text-2xl font-normal">
Recover your account
</CardTitle>
</CardHeader>
- <CardContent>
- <p className="mb-4 text-sm text-label">
- Enter your email to start the recovery process. You will receive an email with
- instructions.
+ <CardContent className="flex flex-col gap-4">
+ <p className="text-sm text-label">
+ Enter your email to receive recovery instructions.
</p>
- <div className="w-full">
- <Input
- value={email}
- onChange={(e) => setEmail(e.target.value)}
- type="email"
- placeholder="Enter your email..."
- required
- autoComplete="username"
- className="h-10"
- />
- </div>
- <div className="mt-4 w-full">
- <Button type="submit" variant="project" size="lg" isFullWidth isPending={loading}>
- Continue
- </Button>
- </div>
- <div className="mt-6 flex flex-row justify-center text-xs text-label">
- <Link to="/login">
- <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
- Back to Login
- </span>
- </Link>
- </div>
+ <Input
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ type="email"
+ placeholder="Enter your email..."
+ required
+ autoComplete="username"
+ className="h-10"
+ />
+ <Button type="submit" variant="project" size="lg" isFullWidth isPending={loading}>
+ Continue
+ </Button>
+ <Link
+ to="/login"
+ className="self-center text-sm text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ >
+ Back to login
+ </Link>
</CardContent>
- </Card>
+ </AuthPagePanel>
</form>
)}
{step === 2 && (
- <Card className="mx-auto w-full max-w-sm items-stretch gap-0 p-6">
- <CardHeader className="mb-4 gap-4">
- <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.35rem] font-medium text-transparent">
+ <AuthPagePanel className="text-center">
+ <CardHeader className="mb-6 items-center gap-2 text-center">
+ <div
+ aria-hidden="true"
+ className="mb-4 flex size-12 items-center justify-center justify-self-center rounded-lg bg-card text-foreground/80"
+ >
+ <MailCheck className="size-5" strokeWidth={1.75} />
+ </div>
+ <CardTitle className="justify-center text-center font-alliance text-2xl font-normal">
Check your inbox
</CardTitle>
</CardHeader>
- <CardContent>
- <p className="text-center text-sm text-foreground">
- If the email is in our system, you will receive an email at{" "}
- <span className="italic">{email}</span> to initiate the account recovery process.
+ <CardContent className="flex flex-col items-center gap-4">
+ <p className="text-sm text-label">
+ If an account exists for{" "}
+ <span className="font-medium text-foreground">{email}</span>, you&apos;ll receive
+ recovery instructions shortly.
</p>
- <div className="mt-6 flex flex-row justify-center text-xs text-label">
- <Link to="/login">
- <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
- Back to Login
- </span>
- </Link>
- </div>
+ <Link
+ to="/login"
+ className="self-center text-sm text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ >
+ Back to login
+ </Link>
</CardContent>
- </Card>
+ </AuthPagePanel>
)}
</div>
- <AuthPageFooter />
<EmailServiceSetupModal
isOpen={popUp.setUpEmail?.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("setUpEmail", isOpen)}
/>
- </div>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx b/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
index c435242646..3ce7c51a5e 100644
--- a/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
+++ b/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
@@ -1,6 +1,7 @@
import { useState } from "react";
-import { Link, useNavigate, useSearch } from "@tanstack/react-router";
+import { useNavigate, useSearch } from "@tanstack/react-router";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
import { createNotification } from "@app/components/notifications";
import { ConfirmActionModal } from "@app/components/v2";
import { ROUTE_PATHS } from "@app/const/routes";
@@ -60,12 +61,7 @@ export const AccountRecoveryResetPage = () => {
};
return (
- <div className="flex min-h-screen flex-col justify-center bg-gradient-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700 px-6 pb-28">
- <Link to="/">
- <div className="mt-20 mb-4 flex justify-center">
- <img src="/images/gradientLogo.svg" className="h-[90px] w-[120px]" alt="Infisical Logo" />
- </div>
- </Link>
+ <AuthPageLayout variant="focused" contentClassName="max-w-2xl">
{step === Steps.ConfirmEmail && (
<ConfirmEmailStep
onComplete={(verifyToken, userEncryptionVersion, hasEmailAuth) => {
@@ -104,6 +100,6 @@ export const AccountRecoveryResetPage = () => {
onConfirmed={handleEnableEmailAuth}
buttonText="Enable"
/>
- </div>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx b/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx
index c81ca2e771..f8ba52ab6f 100644
--- a/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx
+++ b/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx
@@ -1,46 +1,39 @@
import { useState } from "react";
-import { faCheck, faXmark } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { ChevronLeft } from "lucide-react";
-
-import { checkIsPasswordBreached } from "@app/components/utilities/checks/password/checkIsPasswordBreached";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Check, ChevronLeft, Eye, EyeOff, X } from "lucide-react";
+import { z } from "zod";
+
+import { PasswordField } from "@app/components/auth/PasswordField";
+import { createPasswordSchema } from "@app/components/utilities/checks/password/passwordPolicy";
+import { usePasswordBreachCheck } from "@app/components/utilities/checks/password/usePasswordBreachCheck";
import {
- escapeCharRegex,
- letterCharRegex,
- lowEntropyRegexes,
- numAndSpecialCharRegex,
- repeatedCharRegex
-} from "@app/components/utilities/checks/password/passwordRegexes";
-import { FormControl, Input } from "@app/components/v2";
-import { Button } from "@app/components/v3";
+ AnimatedCollapse,
+ Button,
+ Field,
+ FieldError,
+ FieldLabel,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput
+} from "@app/components/v3";
+import { useServerConfig } from "@app/context";
import { useResetPasswordV2 } from "@app/hooks/api";
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
-type PasswordErrors = {
- tooShort: boolean;
- tooLong: boolean;
- noLetterChar: boolean;
- noNumOrSpecialChar: boolean;
- repeatedChar: boolean;
- escapeChar: boolean;
- lowEntropy: boolean;
- breached: boolean;
-};
+const createSchema = (passwordPolicy: TPasswordPolicy) =>
+ z
+ .object({
+ password: createPasswordSchema(passwordPolicy),
+ confirmPassword: z.string().min(1, "Please confirm your password")
+ })
+ .refine(({ confirmPassword, password }) => confirmPassword === password, {
+ message: "Passwords do not match",
+ path: ["confirmPassword"]
+ });
-const validatePassword = (password: string): Omit<PasswordErrors, "breached"> => {
- return {
- tooShort: password.length < 14,
- tooLong: password.length > 100,
- noLetterChar: !letterCharRegex.test(password),
- noNumOrSpecialChar: !numAndSpecialCharRegex.test(password),
- repeatedChar: repeatedCharRegex.test(password),
- escapeChar: escapeCharRegex.test(password),
- lowEntropy: lowEntropyRegexes.some((regex) => regex.test(password))
- };
-};
-
-const hasValidationErrors = (errors: PasswordErrors): boolean => {
- return Object.values(errors).some(Boolean);
-};
+type FormData = z.infer<ReturnType<typeof createSchema>>;
type Props = {
verificationToken: string;
@@ -49,149 +42,125 @@ type Props = {
};
export const EnterPasswordStep = ({ verificationToken, onComplete, onBack }: Props) => {
- const [password, setPassword] = useState("");
- const [confirmPassword, setConfirmPassword] = useState("");
- const [passwordErrors, setPasswordErrors] = useState<PasswordErrors>({
- tooShort: false,
- tooLong: false,
- noLetterChar: false,
- noNumOrSpecialChar: false,
- repeatedChar: false,
- escapeChar: false,
- lowEntropy: false,
- breached: false
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
+ const { config } = useServerConfig();
+ const {
+ formState: { errors, isSubmitting, submitCount },
+ handleSubmit,
+ register,
+ setError,
+ watch
+ } = useForm<FormData>({
+ resolver: zodResolver(createSchema(config.passwordPolicy)),
+ mode: "onChange",
+ defaultValues: { password: "", confirmPassword: "" }
});
- const [isSubmitting, setIsSubmitting] = useState(false);
-
- const passwordsMatch = password === confirmPassword;
- const showConfirmError = confirmPassword.length > 0 && !passwordsMatch;
-
- const { mutateAsync: resetPasswordV2, isPending: isLoadingV2 } = useResetPasswordV2();
-
- const handlePasswordChange = (value: string) => {
- setPassword(value);
- const errors = validatePassword(value);
- setPasswordErrors((prev) => ({ ...prev, ...errors }));
- };
-
- const handleSubmit = async (e: React.FormEvent) => {
- e.preventDefault();
-
- // Validate and check for breached password on submit
- const errors = validatePassword(password);
- const isBreached = await checkIsPasswordBreached(password);
- const finalErrors = { ...errors, breached: isBreached };
- setPasswordErrors(finalErrors);
-
- if (hasValidationErrors(finalErrors) || !passwordsMatch) return;
-
- setIsSubmitting(true);
-
- try {
- await resetPasswordV2({
- newPassword: password,
- verificationToken
+ const password = watch("password");
+ const confirmPassword = watch("confirmPassword");
+ const { breachStatus, validatePassword } = usePasswordBreachCheck({
+ password,
+ policy: config.passwordPolicy
+ });
+ const { mutateAsync: resetPasswordV2, isPending } = useResetPasswordV2();
+
+ const handlePasswordReset = async ({ password: nextPassword }: FormData) => {
+ const latestBreachStatus = await validatePassword(nextPassword);
+ if (latestBreachStatus === "breached") {
+ setError("password", {
+ type: "validate",
+ message: "This password was found in a known data breach."
});
- onComplete();
- } finally {
- setIsSubmitting(false);
+ return;
}
- };
- const isPasswordError = hasValidationErrors(passwordErrors);
- const isFormLoading = isSubmitting || isLoadingV2;
+ await resetPasswordV2({
+ newPassword: nextPassword,
+ verificationToken
+ });
+ onComplete();
+ };
- const validationRules = [
- { key: "tooShort", label: "at least 14 characters", hasError: passwordErrors.tooShort },
- { key: "tooLong", label: "at most 100 characters", hasError: passwordErrors.tooLong },
- {
- key: "noLetterChar",
- label: "at least 1 letter character",
- hasError: passwordErrors.noLetterChar
- },
- {
- key: "noNumOrSpecialChar",
- label: "at least 1 number or special character",
- hasError: passwordErrors.noNumOrSpecialChar
- },
- {
- key: "repeatedChar",
- label: "at most 3 repeated, consecutive characters",
- hasError: passwordErrors.repeatedChar
- },
- {
- key: "escapeChar",
- label: "No escape characters allowed.",
- hasError: passwordErrors.escapeChar
- },
- {
- key: "lowEntropy",
- label: "Password contains personal info.",
- hasError: passwordErrors.lowEntropy
- },
- {
- key: "breached",
- label: "Password was found in a data breach.",
- hasError: passwordErrors.breached
- }
- ];
+ const isLoading = isSubmitting || isPending;
+ const showDangerState = submitCount > 0;
+ const isPasswordValidated = breachStatus === "safe" || breachStatus === "unavailable";
+ const doPasswordsMatch = confirmPassword.length > 0 && password === confirmPassword;
return (
<form
- onSubmit={handleSubmit}
- className="mx-auto flex w-full max-w-md flex-col items-center justify-center"
+ onSubmit={handleSubmit(handlePasswordReset)}
+ className="mx-auto flex w-full max-w-md flex-col items-center justify-center gap-y-4"
>
- <h1 className="mb-2 bg-gradient-to-b from-white to-bunker-200 bg-clip-text text-center text-xl font-medium text-transparent">
+ <h1 className="bg-gradient-to-b from-white to-bunker-200 bg-clip-text text-center text-xl font-medium text-transparent">
Enter new password
</h1>
<p className="w-max justify-center text-center text-sm text-gray-400">
Make sure you save it somewhere safe.
</p>
- <FormControl
- className="mt-8 w-full"
- label="New Password"
- isRequired
- isError={isPasswordError}
- >
- <Input
+ <div className="mt-8 w-full">
+ <PasswordField
+ id="account-recovery-password"
value={password}
- onChange={(e) => handlePasswordChange(e.target.value)}
- type="password"
+ policy={config.passwordPolicy}
+ breachStatus={breachStatus}
+ registration={register("password")}
+ error={errors.password}
+ submitCount={submitCount}
/>
- </FormControl>
- <FormControl
+ </div>
+ <AnimatedCollapse
+ isOpen={isPasswordValidated}
className="w-full"
- label="Confirm Password"
- isRequired
- isError={showConfirmError}
- errorText="Passwords do not match"
+ contentClassName={isPasswordValidated ? "overflow-visible" : undefined}
+ >
+ <Field data-invalid={showDangerState && Boolean(errors.confirmPassword)}>
+ <FieldLabel htmlFor="account-recovery-confirm-password">Confirm Password</FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ {...register("confirmPassword")}
+ id="account-recovery-confirm-password"
+ type={showConfirmPassword ? "text" : "password"}
+ placeholder="••••••••"
+ autoComplete="new-password"
+ aria-invalid={showDangerState && Boolean(errors.confirmPassword)}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ onClick={() => setShowConfirmPassword((current) => !current)}
+ aria-label={
+ showConfirmPassword ? "Hide password confirmation" : "Show password confirmation"
+ }
+ >
+ {showConfirmPassword ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ <AnimatedCollapse isOpen={confirmPassword.length > 0}>
+ <div className="flex items-start gap-2 pt-1 text-xs" aria-live="polite">
+ {doPasswordsMatch ? (
+ <Check className="mt-0.5 size-3.5 shrink-0 text-success" />
+ ) : (
+ <X className="mt-0.5 size-3.5 shrink-0 text-danger" />
+ )}
+ <span className={doPasswordsMatch ? "text-muted" : "text-danger"}>
+ {doPasswordsMatch ? "Passwords match" : "Passwords do not match"}
+ </span>
+ </div>
+ </AnimatedCollapse>
+ {showDangerState && errors.confirmPassword ? (
+ <FieldError>{errors.confirmPassword.message}</FieldError>
+ ) : null}
+ </Field>
+ </AnimatedCollapse>
+ <Button
+ type="submit"
+ isFullWidth
+ isPending={isLoading}
+ isDisabled={isLoading || breachStatus === "checking" || breachStatus === "breached"}
>
- <Input
- value={confirmPassword}
- onChange={(e) => setConfirmPassword(e.target.value)}
- type="password"
- />
- </FormControl>
- <Button type="submit" isFullWidth isPending={isFormLoading} isDisabled={isFormLoading}>
Change Password
</Button>
- <div className="mt-4 w-full rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-4 drop-shadow-sm">
- <div className="mb-1 ml-2 text-sm text-gray-300">Password requirements</div>
- {validationRules.map((rule) => (
- <div key={rule.key} className="mt-2 ml-2 flex flex-row items-center justify-start">
- {rule.hasError ? (
- <FontAwesomeIcon icon={faXmark} className="mr-2.5 text-lg text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-green" />
- )}
- <div className={`${rule.hasError ? "text-gray-400" : "text-gray-600"} text-sm`}>
- {rule.label}
- </div>
- </div>
- ))}
- </div>
<div>
- <Button variant="ghost" className="mt-6 text-mineshaft-300" onClick={onBack}>
+ <Button type="button" variant="ghost" className="mt-6 text-mineshaft-300" onClick={onBack}>
<ChevronLeft className="mr-2 h-4 w-4" />
<span className="text-sm">Back to recovery options</span>
</Button>
diff --git a/frontend/src/pages/auth/CliRedirectPage/CliRedirectPage.tsx b/frontend/src/pages/auth/CliRedirectPage/CliRedirectPage.tsx
index 263ecb2bbd..8d72aabfdf 100644
--- a/frontend/src/pages/auth/CliRedirectPage/CliRedirectPage.tsx
+++ b/frontend/src/pages/auth/CliRedirectPage/CliRedirectPage.tsx
@@ -2,6 +2,8 @@ import { Helmet } from "react-helmet";
import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { IconButton, SecretInput } from "@app/components/v2";
import { SessionStorageKeys } from "@app/const";
import { useTimedReset } from "@app/hooks";
@@ -35,22 +37,12 @@ export const CliRedirectPage = () => {
};
return (
- <div className="flex flex-col justify-between bg-bunker-800 md:h-screen">
+ <AuthPageLayout variant="focused" contentClassName="max-w-xl">
<Helmet>
<title>Infisical CLI | Login Successful!</title>
<link rel="icon" href="/infisical.ico" />
</Helmet>
- <div className="flex h-screen w-screen flex-col items-center justify-center space-y-4 text-gray-200">
- <div className="mb-4 flex justify-center">
- <img
- src="/images/gradientLogo.svg"
- style={{
- height: "90px",
- width: "120px"
- }}
- alt="Infisical Logo"
- />
- </div>
+ <AuthPagePanel className="flex flex-col items-center space-y-4 text-gray-200">
{cliToken ? (
<>
<div className="pb-4">
@@ -91,7 +83,7 @@ export const CliRedirectPage = () => {
</p>
</>
)}
- </div>
- </div>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/EmailNotVerifiedPage/EmailNotVerifiedPage.tsx b/frontend/src/pages/auth/EmailNotVerifiedPage/EmailNotVerifiedPage.tsx
index 0f7935058c..f4fc013c02 100644
--- a/frontend/src/pages/auth/EmailNotVerifiedPage/EmailNotVerifiedPage.tsx
+++ b/frontend/src/pages/auth/EmailNotVerifiedPage/EmailNotVerifiedPage.tsx
@@ -1,34 +1,30 @@
import { Helmet } from "react-helmet";
import { Link } from "@tanstack/react-router";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
+import { Button, CardContent, CardDescription, CardHeader, CardTitle } from "@app/components/v3";
+
export const EmailNotVerifiedPage = () => {
return (
- <div className="flex min-h-screen flex-col justify-center bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700 px-6 pb-28">
+ <AuthPageLayout variant="focused">
<Helmet>
- <title>Request a New Invite</title>
+ <title>Email Not Verified</title>
<link rel="icon" href="/infisical.ico" />
</Helmet>
- <Link to="/">
- <div className="mt-20 mb-4 flex justify-center">
- <img src="/images/gradientLogo.svg" className="h-[90px] w-[120px]" alt="Infisical Logo" />
- </div>
- </Link>
- <div className="mx-auto flex w-full flex-col items-center justify-center">
- <h1 className="mb-2 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-xl font-medium text-transparent">
- Your email was not verified
- </h1>
- <p className="w-max justify-center text-center text-sm text-gray-400">
- Please try again. <br /> Note: If it still doesn&apos;t work, please reach out to us at
- </p>
- <div className="mt-6 flex flex-row text-sm text-bunker-400">
- <Link to="/login">
- <span className="cursor-pointer duration-200 hover:text-bunker-200 hover:underline hover:decoration-primary-700 hover:underline-offset-4">
- Back to Login
- </span>
- </Link>
- </div>
- </div>
- </div>
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2 text-center">
+ <CardTitle>Your email was not verified</CardTitle>
+ <CardDescription>
+ Please try again. If the problem continues, contact [email protected].
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Button asChild variant="project" size="lg" isFullWidth>
+ <Link to="/login">Back to Login</Link>
+ </Button>
+ </CardContent>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx b/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx
index a9e32fcb7c..cf6451ffd3 100644
--- a/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx
+++ b/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx
@@ -1,36 +1,40 @@
import { useState } from "react";
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
-import { Link, useNavigate } from "@tanstack/react-router";
+import { useNavigate, useSearch } from "@tanstack/react-router";
+import { ChevronLeft } from "lucide-react";
-import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";
-import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";
-import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { createNotification } from "@app/components/notifications";
-import { Button, Card, CardContent, CardHeader, CardTitle, Input } from "@app/components/v3";
+import { Button, CardContent, CardHeader, CardTitle, IconButton, Input } from "@app/components/v3";
import { useServerConfig } from "@app/context";
import { LoginMethod } from "@app/hooks/api/admin/types";
import { loginLDAPRedirect } from "@app/hooks/api/auth/queries";
-import { useLastLogin } from "@app/hooks/useLastLogin";
+import { getLastLoginOrganizationSlug, useLastLogin } from "@app/hooks/useLastLogin";
export const LoginLdapPage = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const { config } = useServerConfig();
const { lastLogin, saveLastLogin } = useLastLogin();
- const queryParams = new URLSearchParams(window.location.search);
- const passedOrgSlug = queryParams.get("organizationSlug");
- const passedUsername = queryParams.get("username");
- const callbackPort = queryParams.get("callback_port");
+ const {
+ callback_port: callbackPort,
+ is_admin_login: isAdminLogin,
+ organizationSlug: passedOrgSlug,
+ username: passedUsername
+ } = useSearch({ from: "/_restrict-login-signup/login/ldap" });
- const lastLoginSlug =
- lastLogin?.method === LoginMethod.LDAP && lastLogin.orgSlug ? lastLogin.orgSlug : "";
+ const lastLoginSlug = getLastLoginOrganizationSlug(lastLogin) || "";
const [organizationSlug, setOrganizationSlug] = useState(
config.defaultAuthOrgSlug || passedOrgSlug || lastLoginSlug
);
const [username, setUsername] = useState(passedUsername || "");
const [password, setPassword] = useState("");
+ const isFormValid = Boolean(organizationSlug.trim() && username.trim() && password);
+
+ const handleBackToLogin = () => navigate({ to: isAdminLogin ? "/login/admin" : "/login" });
const handleSubmission = async (e: React.FormEvent) => {
e.preventDefault();
@@ -39,7 +43,7 @@ export const LoginLdapPage = () => {
organizationSlug,
username,
password,
- callbackPort: callbackPort ? Number(callbackPort) : undefined
+ callbackPort
});
if (!nextUrl) {
@@ -51,7 +55,7 @@ export const LoginLdapPage = () => {
return;
}
- saveLastLogin({ method: LoginMethod.LDAP, orgSlug: organizationSlug });
+ saveLastLogin({ method: LoginMethod.LDAP, organizationSlug });
createNotification({
text: "Successfully logged in",
@@ -69,8 +73,7 @@ export const LoginLdapPage = () => {
};
return (
- <div className="relative flex max-h-screen min-h-screen flex-col justify-center overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4">
- <AuthPageBackground />
+ <AuthPageLayout variant="focused">
<Helmet>
<title>{t("common.head-title", { title: t("login.title") })}</title>
<link rel="icon" href="/infisical.ico" />
@@ -78,71 +81,59 @@ export const LoginLdapPage = () => {
<meta property="og:title" content={t("login.og-title") ?? ""} />
<meta name="og:description" content={t("login.og-description") ?? ""} />
</Helmet>
- <AuthPageHeader>
- <Button asChild>
- <Link to="/signup">Sign Up</Link>
- </Button>
- </AuthPageHeader>
- <div className="relative z-10 my-auto flex flex-col items-center py-10">
- <form onSubmit={handleSubmission} className="mx-auto w-full max-w-sm">
- <Card className="w-full items-stretch gap-0 p-6">
- <CardHeader className="mb-4 gap-4">
- <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.35rem] font-medium text-transparent">
+ <form onSubmit={handleSubmission} className="mx-auto w-full max-w-sm">
+ <AuthPagePanel>
+ <CardHeader className="mb-4 gap-4">
+ <div className="flex items-center gap-1.5">
+ <IconButton
+ aria-label="Back to login"
+ variant="ghost-muted"
+ size="xs"
+ className="-ml-2"
+ onClick={handleBackToLogin}
+ >
+ <ChevronLeft />
+ </IconButton>
+ <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
LDAP Login
</CardTitle>
- </CardHeader>
- <CardContent>
- {!config.defaultAuthOrgSlug && !passedOrgSlug && (
- <div className="w-full">
- <Input
- value={organizationSlug}
- onChange={(e) => setOrganizationSlug(e.target.value)}
- type="text"
- placeholder="Enter your organization slug..."
- required
- className="h-10"
- />
- </div>
- )}
- <div className="mt-2 w-full">
- <Input
- value={username}
- onChange={(e) => setUsername(e.target.value)}
- type="text"
- placeholder="Enter your LDAP username..."
- required
- disabled={passedUsername !== null}
- className="h-10"
- />
- </div>
- <div className="mt-2 w-full">
- <Input
- value={password}
- onChange={(e) => setPassword(e.target.value)}
- type="password"
- placeholder="Enter your LDAP password..."
- required
- autoComplete="current-password"
- className="h-10"
- />
- </div>
- <div className="mt-4 w-full">
- <Button type="submit" variant="project" size="lg" isFullWidth>
- {t("login.login")}
- </Button>
- </div>
- <div className="mt-6 flex flex-row justify-center text-xs text-label">
- <button onClick={() => navigate({ to: "/login" })} type="button">
- <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
- {t("login.other-option")}
- </span>
- </button>
- </div>
- </CardContent>
- </Card>
- </form>
- </div>
- <AuthPageFooter />
- </div>
+ </div>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-4">
+ {!config.defaultAuthOrgSlug && !passedOrgSlug && (
+ <Input
+ value={organizationSlug}
+ onChange={(e) => setOrganizationSlug(e.target.value)}
+ type="text"
+ placeholder="Enter your organization slug..."
+ required
+ className="h-10"
+ />
+ )}
+ <Input
+ value={username}
+ onChange={(e) => setUsername(e.target.value)}
+ type="text"
+ placeholder="Enter your LDAP username..."
+ required
+ disabled={passedUsername !== undefined}
+ className="h-10"
+ />
+ <Input
+ value={password}
+ onChange={(e) => setPassword(e.target.value)}
+ type="password"
+ placeholder="Enter your LDAP password..."
+ required
+ autoComplete="current-password"
+ className="h-10"
+ />
+ <Button type="submit" variant="project" size="lg" isFullWidth isDisabled={!isFormValid}>
+ Continue with LDAP
+ </Button>
+ </CardContent>
+ </AuthPagePanel>
+ </form>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/LoginLdapPage/route.tsx b/frontend/src/pages/auth/LoginLdapPage/route.tsx
index aa2ff18c69..df21de0b85 100644
--- a/frontend/src/pages/auth/LoginLdapPage/route.tsx
+++ b/frontend/src/pages/auth/LoginLdapPage/route.tsx
@@ -5,13 +5,23 @@ import { z } from "zod";
import { LoginLdapPage } from "./LoginLDAPPage";
const LoginLdapPageQueryParamsSchema = z.object({
- organizationSlug: z.string().catch("")
+ callback_port: z.coerce.number().optional().catch(undefined),
+ is_admin_login: z.boolean().optional().catch(false),
+ organizationSlug: z.string().catch(""),
+ username: z.string().optional().catch(undefined)
});
export const Route = createFileRoute("/_restrict-login-signup/login/ldap")({
component: LoginLdapPage,
validateSearch: zodValidator(LoginLdapPageQueryParamsSchema),
search: {
- middlewares: [stripSearchParams({ organizationSlug: "" })]
+ middlewares: [
+ stripSearchParams({
+ callback_port: undefined,
+ is_admin_login: false,
+ organizationSlug: "",
+ username: undefined
+ })
+ ]
}
});
diff --git a/frontend/src/pages/auth/LoginOidcPage/LoginOidcPage.tsx b/frontend/src/pages/auth/LoginOidcPage/LoginOidcPage.tsx
new file mode 100644
index 0000000000..533f0c3a75
--- /dev/null
+++ b/frontend/src/pages/auth/LoginOidcPage/LoginOidcPage.tsx
@@ -0,0 +1,3 @@
+import { LoginSsoPage } from "../LoginSsoPage/LoginSsoPage";
+
+export const LoginOidcPage = () => <LoginSsoPage type="OIDC" />;
diff --git a/frontend/src/pages/auth/LoginOidcPage/route.tsx b/frontend/src/pages/auth/LoginOidcPage/route.tsx
new file mode 100644
index 0000000000..17be92b167
--- /dev/null
+++ b/frontend/src/pages/auth/LoginOidcPage/route.tsx
@@ -0,0 +1,25 @@
+import { createFileRoute, stripSearchParams } from "@tanstack/react-router";
+import { zodValidator } from "@tanstack/zod-adapter";
+import { z } from "zod";
+
+import { LoginOidcPage } from "./LoginOidcPage";
+
+const LoginOidcPageQueryParamsSchema = z.object({
+ callback_port: z.coerce.number().optional().catch(undefined),
+ is_admin_login: z.boolean().optional().catch(false),
+ organizationSlug: z.string().optional().catch(undefined)
+});
+
+export const Route = createFileRoute("/_restrict-login-signup/login/oidc")({
+ component: LoginOidcPage,
+ validateSearch: zodValidator(LoginOidcPageQueryParamsSchema),
+ search: {
+ middlewares: [
+ stripSearchParams({
+ callback_port: undefined,
+ is_admin_login: false,
+ organizationSlug: undefined
+ })
+ ]
+ }
+});
diff --git a/frontend/src/pages/auth/LoginPage/Login.utils.tsx b/frontend/src/pages/auth/LoginPage/Login.utils.tsx
index 59dfbc2281..b6546bd778 100644
--- a/frontend/src/pages/auth/LoginPage/Login.utils.tsx
+++ b/frontend/src/pages/auth/LoginPage/Login.utils.tsx
@@ -11,12 +11,6 @@ type NavigateUserToOrgParams = {
navigateTo?: string;
};
-export enum LoginSection {
- Initial = "initial",
- SAML = "saml",
- OIDC = "oidc"
-}
-
const navigateToOrg = (navigate: NavigateFn, organizationId: string, navigateTo?: string) => {
navigate({
to: navigateTo || ("/organizations/$orgId/projects" as const),
diff --git a/frontend/src/pages/auth/LoginPage/LoginPage.tsx b/frontend/src/pages/auth/LoginPage/LoginPage.tsx
index f27b98e2eb..6057462359 100644
--- a/frontend/src/pages/auth/LoginPage/LoginPage.tsx
+++ b/frontend/src/pages/auth/LoginPage/LoginPage.tsx
@@ -1,36 +1,37 @@
-import { useState } from "react";
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { Link } from "@tanstack/react-router";
-import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";
-import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";
-import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";
-import { Button } from "@app/components/v3";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { useServerConfig } from "@app/context";
+import { LoginMethod } from "@app/hooks/api/admin/types";
-import { InitialStep, SSOStep } from "./components";
-import { LoginSection } from "./Login.utils";
+import { InitialStep } from "./components";
export const LoginPage = ({ isAdmin }: { isAdmin?: boolean }) => {
const { t } = useTranslation();
- const [section, setSection] = useState<LoginSection>(LoginSection.Initial);
+ const { config } = useServerConfig();
- const renderView = () => {
- switch (section) {
- case LoginSection.Initial:
- return <InitialStep isAdmin={isAdmin} setSection={setSection} />;
- case LoginSection.SAML:
- return <SSOStep setSection={setSection} type="SAML" />;
- case LoginSection.OIDC:
- return <SSOStep setSection={setSection} type="OIDC" />;
- default:
- return <div />;
- }
- };
+ const shouldDisplayLoginMethod = (method: LoginMethod) =>
+ isAdmin || !config.enabledLoginMethods || config.enabledLoginMethods.includes(method);
return (
- <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4">
- <AuthPageBackground />
+ <AuthPageLayout
+ showFooter={false}
+ bottomContent={
+ shouldDisplayLoginMethod(LoginMethod.EMAIL) ? (
+ <div className="text-xs text-label">
+ Help me{" "}
+ <Link
+ to="/account-recovery"
+ className="underline underline-offset-2 transition-colors duration-200 hover:text-foreground hover:decoration-project/45"
+ >
+ recover my account
+ </Link>
+ </div>
+ ) : undefined
+ }
+ >
<Helmet>
<title>{t("common.head-title", { title: t("login.title") })}</title>
<link rel="icon" href="/infisical.ico" />
@@ -38,13 +39,7 @@ export const LoginPage = ({ isAdmin }: { isAdmin?: boolean }) => {
<meta property="og:title" content={t("login.og-title") ?? ""} />
<meta name="og:description" content={t("login.og-description") ?? ""} />
</Helmet>
- <AuthPageHeader>
- <Button asChild variant="project">
- <Link to="/signup">Sign Up</Link>
- </Button>
- </AuthPageHeader>
- <div className="relative z-10 my-auto flex flex-col items-center py-10">{renderView()}</div>
- <AuthPageFooter />
- </div>
+ <InitialStep isAdmin={isAdmin} />
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx b/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx
index 7c1f77e07f..483dde7ae9 100644
--- a/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx
+++ b/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from "react";
+import { Fragment, ReactNode, useEffect, useRef, useState } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { faGithub, faGitlab, faGoogle } from "@fortawesome/free-brands-svg-icons";
@@ -8,22 +8,25 @@ import { Link, useNavigate } from "@tanstack/react-router";
import { Eye, EyeOff } from "lucide-react";
import { z } from "zod";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import Error from "@app/components/basic/Error";
import { RegionSelect } from "@app/components/navigation/RegionSelect";
import { createNotification } from "@app/components/notifications";
import attemptLogin from "@app/components/utilities/attemptLogin";
import {
- Badge,
+ AnimatedCollapse,
Button,
- Card,
+ ButtonBadge,
CardAction,
CardContent,
+ CardDescription,
CardHeader,
CardTitle,
- IconButton,
+ FieldSeparator,
Input,
InputGroup,
InputGroupAddon,
+ InputGroupButton,
InputGroupInput
} from "@app/components/v3";
import { envConfig } from "@app/config/env";
@@ -31,10 +34,9 @@ import { useServerConfig } from "@app/context";
import { preserveHubSpotUtk } from "@app/helpers/utmTracking";
import { useFetchServerStatus } from "@app/hooks/api";
import { LoginMethod } from "@app/hooks/api/admin/types";
-import { AuthMethod } from "@app/hooks/api/users/types";
import { useLastLogin } from "@app/hooks/useLastLogin";
-import { LoginSection, useNavigateToSelectOrganization } from "../../Login.utils";
+import { useNavigateToSelectOrganization } from "../../Login.utils";
import { OrgLoginButton } from "../OrgLoginButton";
import { SocialLoginButton } from "../SocialLoginButton";
@@ -46,14 +48,21 @@ const loginFormSchema = z.object({
type LoginFormData = z.infer<typeof loginFormSchema>;
type Props = {
- setSection: (section: LoginSection) => void;
isAdmin?: boolean;
};
-export const InitialStep = ({ setSection, isAdmin }: Props) => {
- const navigate = useNavigate();
+type SocialLoginMethod = LoginMethod.GOOGLE | LoginMethod.GITHUB | LoginMethod.GITLAB;
+
+type LoginOptionDescriptor = {
+ id: string;
+ kind: "social" | "organization";
+ isLastUsed: boolean;
+ render: (showLastUsed: boolean, showLabel?: boolean) => ReactNode;
+};
+export const InitialStep = ({ isAdmin }: Props) => {
const { t } = useTranslation();
+ const navigate = useNavigate();
const [isLoading, setIsLoading] = useState(false);
const [loginError, setLoginError] = useState(false);
const { config } = useServerConfig();
@@ -61,7 +70,11 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
const [captchaToken, setCaptchaToken] = useState("");
const [shouldShowCaptcha, setShouldShowCaptcha] = useState(false);
const [showPassword, setShowPassword] = useState(false);
+ const [areMoreLoginOptionsVisible, setAreMoreLoginOptionsVisible] = useState(false);
+ const [areSsoOptionsVisible, setAreSsoOptionsVisible] = useState(false);
const captchaRef = useRef<HCaptcha>(null);
+ const additionalLoginOptionsRef = useRef<HTMLDivElement>(null);
+ const ssoLoginOptionsRef = useRef<HTMLDivElement>(null);
const { data: serverDetails } = useFetchServerStatus();
const { navigateToSelectOrganization } = useNavigateToSelectOrganization();
@@ -72,55 +85,93 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
const {
register,
handleSubmit,
- formState: { errors }
+ formState: { errors, isValid, submitCount }
} = useForm<LoginFormData>({
resolver: zodResolver(loginFormSchema),
+ mode: "onChange",
defaultValues: {
email: "",
password: ""
}
});
+ const showDangerState = submitCount > 0;
const redirectToSaml = (orgSlug: string) => {
- const redirectUrl = `/api/v1/sso/redirect/saml2/organizations/${orgSlug}${
+ const redirectUrl = `/api/v1/sso/redirect/saml2/organizations/${encodeURIComponent(orgSlug)}${
callbackPort ? `?callback_port=${encodeURIComponent(callbackPort)}` : ""
}`;
window.location.assign(redirectUrl);
};
const redirectToOidc = (orgSlug: string) => {
- const redirectUrl = `/api/v1/sso/oidc/login?orgSlug=${orgSlug}${
- callbackPort ? `&callbackPort=${encodeURIComponent(callbackPort)}` : ""
- }`;
- window.location.assign(redirectUrl);
+ const query = new URLSearchParams({ orgSlug });
+ if (callbackPort) query.set("callbackPort", callbackPort);
+ window.location.assign(`/api/v1/sso/oidc/login?${query.toString()}`);
};
useEffect(() => {
if (serverDetails?.samlDefaultOrgSlug && !isAdmin) {
- saveLastLogin({ method: LoginMethod.SAML, orgSlug: serverDetails.samlDefaultOrgSlug });
+ saveLastLogin({
+ method: LoginMethod.SAML,
+ identifier: { type: "orgSlug", value: serverDetails.samlDefaultOrgSlug }
+ });
redirectToSaml(serverDetails.samlDefaultOrgSlug);
}
}, [serverDetails?.samlDefaultOrgSlug]);
- const handleSaml = () => {
- if (config.defaultAuthOrgSlug) {
- saveLastLogin({ method: LoginMethod.SAML, orgSlug: config.defaultAuthOrgSlug });
- redirectToSaml(config.defaultAuthOrgSlug);
- } else {
- setSection(LoginSection.SAML);
+ useEffect(() => {
+ if (areMoreLoginOptionsVisible) {
+ additionalLoginOptionsRef.current?.querySelector<HTMLElement>("button, a")?.focus();
+ }
+ }, [areMoreLoginOptionsVisible]);
+
+ useEffect(() => {
+ if (areSsoOptionsVisible) {
+ ssoLoginOptionsRef.current?.querySelector<HTMLElement>("button, a")?.focus();
+ }
+ }, [areSsoOptionsVisible]);
+
+ const handleOrganizationLogin = (
+ method: LoginMethod.LDAP | LoginMethod.OIDC | LoginMethod.SAML
+ ) => {
+ if (method === LoginMethod.LDAP) {
+ navigate({
+ to: "/login/ldap",
+ search: {
+ callback_port: callbackPort ? Number(callbackPort) : undefined,
+ is_admin_login: isAdmin || undefined,
+ organizationSlug: config.defaultAuthOrgSlug || "",
+ username: undefined
+ }
+ });
+ return;
}
- };
- const handleOidc = () => {
if (config.defaultAuthOrgSlug) {
- saveLastLogin({ method: LoginMethod.OIDC, orgSlug: config.defaultAuthOrgSlug });
- redirectToOidc(config.defaultAuthOrgSlug);
- } else {
- setSection(LoginSection.OIDC);
+ saveLastLogin({
+ method,
+ identifier: { type: "orgSlug", value: config.defaultAuthOrgSlug }
+ });
+
+ if (method === LoginMethod.SAML) {
+ redirectToSaml(config.defaultAuthOrgSlug);
+ } else {
+ redirectToOidc(config.defaultAuthOrgSlug);
+ }
+ return;
}
+
+ navigate({
+ to: method === LoginMethod.OIDC ? "/login/oidc" : "/login/saml",
+ search: {
+ callback_port: callbackPort ? Number(callbackPort) : undefined,
+ is_admin_login: isAdmin || undefined,
+ organizationSlug: config.defaultAuthOrgSlug || undefined
+ }
+ });
};
- const handleSocialLogin = (method: LoginMethod) => {
+ const handleSocialLogin = (method: SocialLoginMethod) => {
preserveHubSpotUtk();
const searchParams = new URLSearchParams();
if (callbackPort) {
@@ -139,6 +190,66 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
const shouldDisplayLoginMethod = (method: LoginMethod) =>
isAdmin || !config.enabledLoginMethods || config.enabledLoginMethods.includes(method);
+ const socialLoginMethods = (
+ [
+ {
+ method: LoginMethod.GOOGLE,
+ icon: faGoogle,
+ label: t("login.continue-with-google")
+ },
+ {
+ method: LoginMethod.GITHUB,
+ icon: faGithub,
+ label: "Continue with GitHub"
+ },
+ {
+ method: LoginMethod.GITLAB,
+ icon: faGitlab,
+ label: "Continue with GitLab"
+ }
+ ] satisfies { method: SocialLoginMethod; icon: typeof faGoogle; label: string }[]
+ ).filter(({ method }) => shouldDisplayLoginMethod(method));
+
+ const loginOptions: LoginOptionDescriptor[] = [
+ ...socialLoginMethods.map(({ method, icon, label }) => ({
+ id: method,
+ kind: "social" as const,
+ isLastUsed: isLastUsedMethod(method),
+ render: (showLastUsed: boolean, showLabel = false) => (
+ <SocialLoginButton
+ icon={icon}
+ label={label}
+ onClick={() => handleSocialLogin(method)}
+ showLabel={showLabel}
+ showLastUsed={showLastUsed}
+ />
+ )
+ })),
+ ...([LoginMethod.LDAP, LoginMethod.OIDC, LoginMethod.SAML] as const)
+ .filter(shouldDisplayLoginMethod)
+ .map((method) => ({
+ id: method,
+ kind: "organization" as const,
+ isLastUsed: isLastUsedMethod(method),
+ render: (showLastUsed: boolean, showLabel = false) => (
+ <OrgLoginButton
+ label={method.toUpperCase()}
+ onClick={() => handleOrganizationLogin(method)}
+ showLabel={showLabel}
+ showLastUsed={showLastUsed}
+ />
+ )
+ }))
+ ];
+ const lastUsedLoginOption = loginOptions.find(({ isLastUsed }) => isLastUsed);
+ const orderedLoginOptions = lastUsedLoginOption
+ ? [lastUsedLoginOption, ...loginOptions.filter(({ id }) => id !== lastUsedLoginOption.id)]
+ : loginOptions;
+ const additionalLoginOptions = lastUsedLoginOption ? orderedLoginOptions.slice(1) : [];
+ const socialLoginOptions = loginOptions.filter(({ kind }) => kind === "social");
+ const organizationLoginOptions = loginOptions.filter(({ kind }) => kind === "organization");
+ const moreLoginOptionsCount = lastUsedLoginOption ? loginOptions.length - 1 : 0;
+ const hasButtonLoginMethod = loginOptions.length > 0;
const handleLoginFailure = () => {
setLoginError(true);
const errorMessage = callbackPort
@@ -208,9 +319,9 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
onSubmit={handleSubmit(handleEmailLogin)}
className="mx-auto flex w-full flex-col items-center justify-center"
>
- <Card className="mx-auto w-full max-w-sm items-stretch gap-0 p-6">
+ <AuthPagePanel>
<CardHeader className="mb-8 gap-2">
- <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.7rem] font-medium text-transparent">
+ <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
Log in to Infisical
</CardTitle>
<CardAction className="-mr-2">
@@ -218,14 +329,16 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
</CardAction>
</CardHeader>
<CardContent>
- {config.defaultAuthOrgAuthMethod === AuthMethod.SAML && (
- <OrgLoginButton label="Continue with SAML" onClick={handleSaml} />
- )}
- {config.defaultAuthOrgAuthMethod === AuthMethod.OIDC && (
- <OrgLoginButton label="Continue with OIDC" onClick={handleOidc} className="mt-2" />
- )}
+ <OrgLoginButton
+ label={config.defaultAuthOrgAuthMethod.toUpperCase()}
+ onClick={() =>
+ handleOrganizationLogin(
+ config.defaultAuthOrgAuthMethod === "saml" ? LoginMethod.SAML : LoginMethod.OIDC
+ )
+ }
+ />
</CardContent>
- </Card>
+ </AuthPagePanel>
</form>
);
}
@@ -235,57 +348,126 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
onSubmit={handleSubmit(handleEmailLogin)}
className="mx-auto flex w-full flex-col items-center justify-center"
>
- <Card className="mx-auto w-full max-w-sm items-stretch gap-0 p-6">
- <CardHeader className="mb-4 gap-4">
- <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.65rem] font-medium text-transparent">
- Log in to Infisical
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2">
+ <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
+ Welcome back
</CardTitle>
+ <CardDescription className="ml-0.5 text-base">
+ {isAdmin ? "Sign in to the Super Admin console" : "Sign in to your Infisical account"}
+ </CardDescription>
<CardAction className="-mr-2">
<RegionSelect compact />
</CardAction>
</CardHeader>
- <CardContent>
+ <CardContent className="flex flex-col gap-4">
+ {hasButtonLoginMethod && (
+ <div className="flex w-full flex-col">
+ {lastUsedLoginOption ? (
+ <>
+ {lastUsedLoginOption.render(true, true)}
+ {moreLoginOptionsCount > 0 && (
+ <AnimatedCollapse isOpen={!areMoreLoginOptionsVisible}>
+ <div className="pt-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ isFullWidth
+ className="text-accent hover:text-foreground"
+ aria-controls="additional-login-options"
+ aria-expanded={areMoreLoginOptionsVisible}
+ onClick={() => setAreMoreLoginOptionsVisible(true)}
+ >
+ + {moreLoginOptionsCount} more options
+ </Button>
+ </div>
+ </AnimatedCollapse>
+ )}
+ <AnimatedCollapse
+ id="additional-login-options"
+ isOpen={areMoreLoginOptionsVisible}
+ >
+ <div
+ ref={additionalLoginOptionsRef}
+ className="flex w-full flex-col gap-2 pt-2"
+ >
+ {additionalLoginOptions.map((option) => (
+ <Fragment key={option.id}>{option.render(false, true)}</Fragment>
+ ))}
+ </div>
+ </AnimatedCollapse>
+ </>
+ ) : (
+ <div className="flex w-full flex-col gap-2">
+ {socialLoginOptions.length > 0 && (
+ <div className="flex w-full gap-2">
+ {socialLoginOptions.map((option) => (
+ <Fragment key={option.id}>{option.render(false)}</Fragment>
+ ))}
+ </div>
+ )}
+ {organizationLoginOptions.length > 0 && (
+ <div className="w-full">
+ <AnimatedCollapse isOpen={!areSsoOptionsVisible}>
+ <Button
+ variant="ghost"
+ size="sm"
+ isFullWidth
+ className="text-accent hover:text-foreground"
+ aria-controls="sso-login-options"
+ aria-expanded={areSsoOptionsVisible}
+ onClick={() => setAreSsoOptionsVisible(true)}
+ >
+ View SSO options
+ </Button>
+ </AnimatedCollapse>
+ <AnimatedCollapse id="sso-login-options" isOpen={areSsoOptionsVisible}>
+ <div ref={ssoLoginOptionsRef} className="flex w-full flex-col gap-2">
+ {organizationLoginOptions.map((option) => (
+ <Fragment key={option.id}>{option.render(false, true)}</Fragment>
+ ))}
+ </div>
+ </AnimatedCollapse>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ )}
+ {hasButtonLoginMethod && shouldDisplayLoginMethod(LoginMethod.EMAIL) && (
+ <FieldSeparator>or</FieldSeparator>
+ )}
{shouldDisplayLoginMethod(LoginMethod.EMAIL) && (
- <>
- <div className="w-full">
- <Input
- {...register("email")}
- type="email"
- id="email"
- placeholder="Enter your email..."
- autoComplete="username"
- className="h-10"
+ <div className="flex w-full flex-col gap-4">
+ <Input
+ {...register("email", { onChange: () => setLoginError(false) })}
+ type="email"
+ id="email"
+ placeholder="[email protected]"
+ autoComplete="username"
+ className="h-10"
+ isError={(showDangerState && Boolean(errors.email)) || loginError}
+ />
+ <InputGroup className="h-10">
+ <InputGroupInput
+ {...register("password", { onChange: () => setLoginError(false) })}
+ type={showPassword ? "text" : "password"}
+ placeholder="••••••••"
+ autoComplete="current-password"
+ id="current-password"
+ aria-invalid={(showDangerState && Boolean(errors.password)) || loginError}
/>
- {errors.email && (
- <span className="mt-1 text-xs text-red-500">{errors.email.message}</span>
- )}
- </div>
- <div className="mt-2 w-full">
- <InputGroup className="h-10">
- <InputGroupInput
- {...register("password")}
- type={showPassword ? "text" : "password"}
- placeholder="Enter your password..."
- autoComplete="current-password"
- id="current-password"
- />
- <InputGroupAddon align="inline-end">
- <IconButton
- variant="ghost"
- size="xs"
- onClick={() => setShowPassword((prev) => !prev)}
- aria-label={showPassword ? "Hide password" : "Show password"}
- >
- {showPassword ? <EyeOff /> : <Eye />}
- </IconButton>
- </InputGroupAddon>
- </InputGroup>
- {errors.password && (
- <span className="mt-1 text-xs text-red-500">{errors.password.message}</span>
- )}
- </div>
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ onClick={() => setShowPassword((prev) => !prev)}
+ aria-label={showPassword ? "Hide password" : "Show password"}
+ >
+ {showPassword ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
{shouldShowCaptcha && envConfig.CAPTCHA_SITE_KEY && (
- <div className="mt-4 flex justify-center [&>div]:!w-full">
+ <div className="flex justify-center [&>div]:!w-full">
<HCaptcha
theme="dark"
sitekey={envConfig.CAPTCHA_SITE_KEY}
@@ -294,120 +476,40 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
/>
</div>
)}
- <div className="relative mt-4 w-full">
- <Button
- type="submit"
- variant="project"
- size="lg"
- isFullWidth
- isDisabled={(shouldShowCaptcha && captchaToken === "") || isLoading}
- isPending={isLoading}
- >
- Continue with Email
- </Button>
+ <Button
+ type="submit"
+ variant="project"
+ size="lg"
+ isFullWidth
+ isDisabled={!isValid || (shouldShowCaptcha && captchaToken === "") || isLoading}
+ isPending={isLoading}
+ >
+ Continue with Email
{isLastUsedMethod(LoginMethod.EMAIL) && (
- <Badge variant="default" className="absolute -top-2 -right-2">
- Last used
- </Badge>
+ <ButtonBadge variant="project">Last used</ButtonBadge>
)}
- </div>
- </>
- )}
- {(!config.enabledLoginMethods ||
- (shouldDisplayLoginMethod(LoginMethod.EMAIL) &&
- config.enabledLoginMethods.length > 1)) && (
- <div className="my-4 flex w-full flex-row items-center py-2">
- <div className="w-full border-t border-mineshaft-400/60" />
- <span className="mx-2 text-xs text-mineshaft-400">or</span>
- <div className="w-full border-t border-mineshaft-400/60" />
+ </Button>
</div>
)}
- <div className="flex w-full gap-2">
- {shouldDisplayLoginMethod(LoginMethod.GOOGLE) && (
- <SocialLoginButton
- icon={faGoogle}
- label={t("login.continue-with-google")}
- onClick={() => handleSocialLogin(LoginMethod.GOOGLE)}
- showLastUsed={isLastUsedMethod(LoginMethod.GOOGLE)}
- />
- )}
- {shouldDisplayLoginMethod(LoginMethod.GITHUB) && (
- <SocialLoginButton
- icon={faGithub}
- label="Continue with GitHub"
- onClick={() => handleSocialLogin(LoginMethod.GITHUB)}
- showLastUsed={isLastUsedMethod(LoginMethod.GITHUB)}
- />
- )}
- {shouldDisplayLoginMethod(LoginMethod.GITLAB) && (
- <SocialLoginButton
- icon={faGitlab}
- label="Continue with GitLab"
- onClick={() => handleSocialLogin(LoginMethod.GITLAB)}
- showLastUsed={isLastUsedMethod(LoginMethod.GITLAB)}
- />
- )}
- </div>
- {shouldDisplayLoginMethod(LoginMethod.SAML) && (
- <OrgLoginButton
- label="Continue with SAML"
- onClick={handleSaml}
- className="mt-2"
- showLastUsed={isLastUsedMethod(LoginMethod.SAML)}
- />
- )}
- {shouldDisplayLoginMethod(LoginMethod.OIDC) && (
- <OrgLoginButton
- label="Continue with OIDC"
- onClick={handleOidc}
- className="mt-2"
- showLastUsed={isLastUsedMethod(LoginMethod.OIDC)}
- />
- )}
- {shouldDisplayLoginMethod(LoginMethod.LDAP) && (
- <OrgLoginButton
- label="Continue with LDAP"
- onClick={() =>
- navigate({
- to: "/login/ldap",
- search: {
- callback_port: callbackPort
- }
- })
- }
- className="mt-2"
- showLastUsed={isLastUsedMethod(LoginMethod.LDAP)}
- />
- )}
{!isLoading && loginError && <Error text={t("login.error-login") ?? ""} />}
</CardContent>
- </Card>
- <div className="mt-6 flex flex-col items-center gap-3">
- {config.allowSignUp &&
- (shouldDisplayLoginMethod(LoginMethod.EMAIL) ||
- shouldDisplayLoginMethod(LoginMethod.GOOGLE) ||
- shouldDisplayLoginMethod(LoginMethod.GITHUB) ||
- shouldDisplayLoginMethod(LoginMethod.GITLAB)) && (
- <div className="flex flex-row items-center justify-center gap-1.5 text-sm">
- <span className="text-label">Don&apos;t have an account?</span>
- <Link to="/signup">
- <span className="cursor-pointer text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project">
- Sign up
- </span>
- </Link>
- </div>
- )}
- {shouldDisplayLoginMethod(LoginMethod.EMAIL) && (
- <div className="flex flex-row justify-center text-xs text-label">
- <Link to="/account-recovery">
- <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
- Recover your account
- </span>
+ </AuthPagePanel>
+ {config.allowSignUp &&
+ (shouldDisplayLoginMethod(LoginMethod.EMAIL) ||
+ shouldDisplayLoginMethod(LoginMethod.GOOGLE) ||
+ shouldDisplayLoginMethod(LoginMethod.GITHUB) ||
+ shouldDisplayLoginMethod(LoginMethod.GITLAB)) && (
+ <div className="mt-3 flex items-center justify-center gap-1.5 text-sm">
+ <span className="text-label">Don&apos;t have an account?</span>
+ <Link
+ to="/signup"
+ className="text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ >
+ Sign up
</Link>
</div>
)}
- </div>
</form>
);
};
diff --git a/frontend/src/pages/auth/LoginPage/components/OrgLoginButton.tsx b/frontend/src/pages/auth/LoginPage/components/OrgLoginButton.tsx
index 7d65184ef0..f481e9c657 100644
--- a/frontend/src/pages/auth/LoginPage/components/OrgLoginButton.tsx
+++ b/frontend/src/pages/auth/LoginPage/components/OrgLoginButton.tsx
@@ -1,26 +1,29 @@
import { faLock } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { Badge, Button } from "@app/components/v3";
+import { Button, ButtonBadge } from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
type Props = {
label: string;
onClick: () => void;
className?: string;
+ showLabel?: boolean;
showLastUsed?: boolean;
};
-export const OrgLoginButton = ({ label, onClick, className, showLastUsed }: Props) => (
- <div className={cn("relative w-full", className)}>
+export const OrgLoginButton = ({
+ label,
+ onClick,
+ className,
+ showLabel = true,
+ showLastUsed
+}: Props) => (
+ <div className={cn("min-w-0 flex-1", className)}>
<Button variant="outline" size="lg" isFullWidth onClick={onClick}>
- <FontAwesomeIcon icon={faLock} className="mr-2" />
- {label}
+ {showLabel && <FontAwesomeIcon icon={faLock} />}
+ {showLabel ? `Continue with ${label}` : label}
+ {showLastUsed && <ButtonBadge variant="project">Last used</ButtonBadge>}
</Button>
- {showLastUsed && (
- <Badge variant="project" className="absolute -top-2 -right-2">
- Last used
- </Badge>
- )}
</div>
);
diff --git a/frontend/src/pages/auth/LoginPage/components/SSOStep/SSOStep.tsx b/frontend/src/pages/auth/LoginPage/components/SSOStep/SSOStep.tsx
deleted file mode 100644
index f7fe1a808e..0000000000
--- a/frontend/src/pages/auth/LoginPage/components/SSOStep/SSOStep.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { useState } from "react";
-import { useTranslation } from "react-i18next";
-
-import { Button, Card, CardContent, CardHeader, CardTitle, Input } from "@app/components/v3";
-import { LoginMethod } from "@app/hooks/api/admin/types";
-import { useLastLogin } from "@app/hooks/useLastLogin";
-
-import { LoginSection } from "../../Login.utils";
-
-type Props = {
- setSection: (section: LoginSection) => void;
- type: "SAML" | "OIDC";
-};
-
-export const SSOStep = ({ setSection, type }: Props) => {
- const { lastLogin, saveLastLogin } = useLastLogin();
- const { t } = useTranslation();
-
- const matchingMethod = type === "SAML" ? LoginMethod.SAML : LoginMethod.OIDC;
- const initialEmail =
- lastLogin?.method === matchingMethod && lastLogin.orgSlug ? lastLogin.orgSlug : "";
-
- const [ssoEmail, setSSOEmail] = useState(initialEmail);
-
- const queryParams = new URLSearchParams(window.location.search);
-
- const handleSubmission = (e: React.FormEvent) => {
- e.preventDefault();
-
- // Extract domain from email (or use raw input if no @ present)
- const domain = ssoEmail.includes("@") ? ssoEmail.split("@")[1]?.trim() : ssoEmail.trim();
- if (!domain) return;
-
- const identifier = encodeURIComponent(domain);
- const callbackPort = queryParams.get("callback_port");
-
- saveLastLogin({ method: matchingMethod, orgSlug: ssoEmail });
-
- if (type === "SAML") {
- window.location.href = `/api/v1/sso/redirect/saml2/organizations/domain/${identifier}${
- callbackPort ? `?callback_port=${encodeURIComponent(callbackPort)}` : ""
- }`;
- } else {
- window.location.href = `/api/v1/sso/oidc/login?domain=${identifier}${
- callbackPort ? `&callbackPort=${encodeURIComponent(callbackPort)}` : ""
- }`;
- }
- };
-
- return (
- <form onSubmit={handleSubmission} className="mx-auto w-full max-w-sm">
- <Card className="w-full items-stretch gap-0 p-6">
- <CardHeader className="mb-4 gap-4">
- <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-[1.35rem] font-medium text-transparent">
- What&apos;s your work email?
- </CardTitle>
- </CardHeader>
- <CardContent>
- <div className="w-full">
- <Input
- value={ssoEmail}
- onChange={(e) => setSSOEmail(e.target.value)}
- type="email"
- placeholder="[email protected]"
- required
- className="h-10"
- />
- </div>
- <div className="mt-4 w-full">
- <Button type="submit" variant="project" size="lg" isFullWidth>
- Continue with {type}
- </Button>
- </div>
- <div className="mt-6 flex flex-row justify-center text-xs text-muted">
- <button onClick={() => setSection(LoginSection.Initial)} type="button">
- <span className="cursor-pointer duration-200 hover:text-label hover:underline hover:decoration-project/45 hover:underline-offset-2">
- {t("login.other-option")}
- </span>
- </button>
- </div>
- </CardContent>
- </Card>
- </form>
- );
-};
diff --git a/frontend/src/pages/auth/LoginPage/components/SSOStep/index.tsx b/frontend/src/pages/auth/LoginPage/components/SSOStep/index.tsx
deleted file mode 100644
index e7d80b2c05..0000000000
--- a/frontend/src/pages/auth/LoginPage/components/SSOStep/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { SSOStep } from "./SSOStep";
diff --git a/frontend/src/pages/auth/LoginPage/components/SocialLoginButton.tsx b/frontend/src/pages/auth/LoginPage/components/SocialLoginButton.tsx
index f8d9afc212..065624e0e4 100644
--- a/frontend/src/pages/auth/LoginPage/components/SocialLoginButton.tsx
+++ b/frontend/src/pages/auth/LoginPage/components/SocialLoginButton.tsx
@@ -1,29 +1,22 @@
import { IconDefinition } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { Badge, Button, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
+import { Button, ButtonBadge } from "@app/components/v3";
type Props = {
icon: IconDefinition;
label: string;
onClick: () => void;
+ showLabel?: boolean;
showLastUsed?: boolean;
};
-export const SocialLoginButton = ({ icon, label, onClick, showLastUsed }: Props) => (
- <Tooltip disableHoverableContent>
- <TooltipTrigger asChild>
- <div className="relative w-full">
- <Button aria-label={label} variant="outline" size="lg" isFullWidth onClick={onClick}>
- <FontAwesomeIcon icon={icon} className="!size-4" />
- </Button>
- {showLastUsed && (
- <Badge variant="project" className="absolute -top-2 -right-2">
- Last used
- </Badge>
- )}
- </div>
- </TooltipTrigger>
- <TooltipContent side="top">{label}</TooltipContent>
- </Tooltip>
+export const SocialLoginButton = ({ icon, label, onClick, showLabel, showLastUsed }: Props) => (
+ <div className="min-w-0 flex-1">
+ <Button aria-label={label} variant="outline" size="lg" isFullWidth onClick={onClick}>
+ <FontAwesomeIcon icon={icon} />
+ {showLabel && <span className="min-w-0 truncate">{label}</span>}
+ {showLastUsed && <ButtonBadge variant="project">Last used</ButtonBadge>}
+ </Button>
+ </div>
);
diff --git a/frontend/src/pages/auth/LoginPage/components/index.tsx b/frontend/src/pages/auth/LoginPage/components/index.tsx
index 7aeb255156..33142e0b04 100644
--- a/frontend/src/pages/auth/LoginPage/components/index.tsx
+++ b/frontend/src/pages/auth/LoginPage/components/index.tsx
@@ -1,2 +1 @@
export { InitialStep } from "./InitialStep";
-export { SSOStep } from "./SSOStep";
diff --git a/frontend/src/pages/auth/LoginSamlPage/LoginSamlPage.tsx b/frontend/src/pages/auth/LoginSamlPage/LoginSamlPage.tsx
new file mode 100644
index 0000000000..3f1902b689
--- /dev/null
+++ b/frontend/src/pages/auth/LoginSamlPage/LoginSamlPage.tsx
@@ -0,0 +1,3 @@
+import { LoginSsoPage } from "../LoginSsoPage/LoginSsoPage";
+
+export const LoginSamlPage = () => <LoginSsoPage type="SAML" />;
diff --git a/frontend/src/pages/auth/LoginSamlPage/route.tsx b/frontend/src/pages/auth/LoginSamlPage/route.tsx
new file mode 100644
index 0000000000..5bf3f43cc2
--- /dev/null
+++ b/frontend/src/pages/auth/LoginSamlPage/route.tsx
@@ -0,0 +1,25 @@
+import { createFileRoute, stripSearchParams } from "@tanstack/react-router";
+import { zodValidator } from "@tanstack/zod-adapter";
+import { z } from "zod";
+
+import { LoginSamlPage } from "./LoginSamlPage";
+
+const LoginSamlPageQueryParamsSchema = z.object({
+ callback_port: z.coerce.number().optional().catch(undefined),
+ is_admin_login: z.boolean().optional().catch(false),
+ organizationSlug: z.string().optional().catch(undefined)
+});
+
+export const Route = createFileRoute("/_restrict-login-signup/login/saml")({
+ component: LoginSamlPage,
+ validateSearch: zodValidator(LoginSamlPageQueryParamsSchema),
+ search: {
+ middlewares: [
+ stripSearchParams({
+ callback_port: undefined,
+ is_admin_login: false,
+ organizationSlug: undefined
+ })
+ ]
+ }
+});
diff --git a/frontend/src/pages/auth/LoginSsoPage/LoginSsoPage.tsx b/frontend/src/pages/auth/LoginSsoPage/LoginSsoPage.tsx
new file mode 100644
index 0000000000..840816ffe9
--- /dev/null
+++ b/frontend/src/pages/auth/LoginSsoPage/LoginSsoPage.tsx
@@ -0,0 +1,132 @@
+import { useState } from "react";
+import { Helmet } from "react-helmet";
+import { useTranslation } from "react-i18next";
+import { useNavigate } from "@tanstack/react-router";
+import { ChevronLeft } from "lucide-react";
+import { z } from "zod";
+
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
+import {
+ Button,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Field,
+ FieldLabel,
+ IconButton,
+ Input
+} from "@app/components/v3";
+import { LoginMethod } from "@app/hooks/api/admin/types";
+import { getLastLoginIdentifier, useLastLogin } from "@app/hooks/useLastLogin";
+
+const workEmailSchema = z.string().trim().email();
+
+type Props = {
+ type: "SAML" | "OIDC";
+};
+
+export const LoginSsoPage = ({ type }: Props) => {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const { lastLogin, saveLastLogin } = useLastLogin();
+ const queryParams = new URLSearchParams(window.location.search);
+ const callbackPort = queryParams.get("callback_port");
+ const isAdminLogin = queryParams.get("is_admin_login") === "true";
+ const organizationSlug = queryParams.get("organizationSlug") || undefined;
+ const method = type === "SAML" ? LoginMethod.SAML : LoginMethod.OIDC;
+ const previousIdentifier =
+ lastLogin?.method === method ? getLastLoginIdentifier(lastLogin) : null;
+ const initialEmail = previousIdentifier?.type === "email" ? previousIdentifier.value : "";
+ const [workEmail, setWorkEmail] = useState(initialEmail);
+
+ const handleLogin = () => {
+ const domain = workEmail.trim().split("@")[1]?.toLowerCase();
+ if (!organizationSlug && !domain) return;
+
+ saveLastLogin({
+ method,
+ identifier: {
+ type: organizationSlug ? "orgSlug" : "email",
+ value: organizationSlug || workEmail.trim()
+ }
+ });
+
+ if (method === LoginMethod.SAML) {
+ const identifierPath = organizationSlug
+ ? encodeURIComponent(organizationSlug)
+ : `domain/${encodeURIComponent(domain as string)}`;
+ const query = callbackPort
+ ? `?callback_port=${encodeURIComponent(String(callbackPort))}`
+ : "";
+ window.location.assign(`/api/v1/sso/redirect/saml2/organizations/${identifierPath}${query}`);
+ return;
+ }
+
+ const query = new URLSearchParams({
+ [organizationSlug ? "orgSlug" : "domain"]: organizationSlug || (domain as string)
+ });
+ if (callbackPort) query.set("callbackPort", String(callbackPort));
+ window.location.assign(`/api/v1/sso/oidc/login?${query.toString()}`);
+ };
+
+ const canSubmit = Boolean(organizationSlug) || workEmailSchema.safeParse(workEmail).success;
+ const loginPath = isAdminLogin ? "/login/admin" : "/login";
+
+ return (
+ <AuthPageLayout variant="focused">
+ <Helmet>
+ <title>{t("common.head-title", { title: `${type} Login` })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ <meta property="og:title" content={t("login.og-title") ?? ""} />
+ <meta name="og:description" content={t("login.og-description") ?? ""} />
+ </Helmet>
+ <div className="mx-auto flex w-full flex-col items-center justify-center">
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2">
+ <div className="flex items-center gap-1.5">
+ <IconButton
+ aria-label="Back to login"
+ variant="ghost-muted"
+ size="xs"
+ className="-ml-2"
+ onClick={() => navigate({ to: loginPath })}
+ >
+ <ChevronLeft />
+ </IconButton>
+ <CardTitle className="ml-0.5 bg-linear-to-b from-white to-bunker-200 bg-clip-text font-alliance text-2xl font-normal text-transparent">
+ {type} Login
+ </CardTitle>
+ </div>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-4">
+ {!organizationSlug && (
+ <Field>
+ <FieldLabel htmlFor={`${type.toLowerCase()}-work-email`}>Work Email</FieldLabel>
+ <Input
+ id={`${type.toLowerCase()}-work-email`}
+ value={workEmail}
+ onChange={(event) => setWorkEmail(event.target.value)}
+ type="email"
+ placeholder="[email protected]"
+ autoComplete="email"
+ className="h-10"
+ />
+ </Field>
+ )}
+ <Button
+ variant="project"
+ size="lg"
+ isFullWidth
+ isDisabled={!canSubmit}
+ onClick={handleLogin}
+ >
+ Continue with {type}
+ </Button>
+ </CardContent>
+ </AuthPagePanel>
+ </div>
+ </AuthPageLayout>
+ );
+};
diff --git a/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx b/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx
index 9626f4cc5c..0455cddbbc 100644
--- a/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx
+++ b/frontend/src/pages/auth/PasswordSetupPage/PasswordSetupPage.tsx
@@ -1,285 +1,186 @@
-import { FormEvent, useState } from "react";
-import { faCheck, faEye, faEyeSlash, faKey, faX } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useState } from "react";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate, useSearch } from "@tanstack/react-router";
+import { Check, Eye, EyeOff, X } from "lucide-react";
+import { z } from "zod";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
+import { PasswordField } from "@app/components/auth/PasswordField";
import { createNotification } from "@app/components/notifications";
-import passwordCheck from "@app/components/utilities/checks/password/PasswordCheck";
-import { Button, Card, CardTitle, FormControl, Input } from "@app/components/v2";
+import { createPasswordSchema } from "@app/components/utilities/checks/password/passwordPolicy";
+import { usePasswordBreachCheck } from "@app/components/utilities/checks/password/usePasswordBreachCheck";
+import {
+ AnimatedCollapse,
+ Button,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ Field,
+ FieldError,
+ FieldLabel,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput
+} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
+import { useServerConfig } from "@app/context";
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
import { useSetupPassword } from "@app/hooks/api/auth/queries";
+const createSchema = (passwordPolicy: TPasswordPolicy) =>
+ z
+ .object({
+ password: createPasswordSchema(passwordPolicy),
+ confirmPassword: z.string().min(1, "Please confirm your password")
+ })
+ .refine(({ confirmPassword, password }) => confirmPassword === password, {
+ message: "Passwords do not match",
+ path: ["confirmPassword"]
+ });
+
+type FormData = z.infer<ReturnType<typeof createSchema>>;
+
export const PasswordSetupPage = () => {
- const [password, setPassword] = useState("");
- const [confirmPassword, setConfirmPassword] = useState("");
- const [showPassword, setShowPassword] = useState(false);
- const [showConfirmPassword, setShowConfirmPassword] = useState(false);
- const [passwordsMatch, setPasswordsMatch] = useState(true);
- const [passwordErrorTooShort, setPasswordErrorTooShort] = useState(true);
- const [passwordErrorTooLong, setPasswordErrorTooLong] = useState(false);
- const [passwordErrorNoLetterChar, setPasswordErrorNoLetterChar] = useState(true);
- const [passwordErrorNoNumOrSpecialChar, setPasswordErrorNoNumOrSpecialChar] = useState(true);
- const [passwordErrorRepeatedChar, setPasswordErrorRepeatedChar] = useState(false);
- const [passwordErrorEscapeChar, setPasswordErrorEscapeChar] = useState(false);
- const [passwordErrorLowEntropy, setPasswordErrorLowEntropy] = useState(false);
- const [passwordErrorBreached, setPasswordErrorBreached] = useState(false);
const [isRedirecting, setIsRedirecting] = useState(false);
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
+ const { config } = useServerConfig();
+ const {
+ formState: { errors, isSubmitting, submitCount },
+ handleSubmit,
+ register,
+ setError,
+ watch
+ } = useForm<FormData>({
+ resolver: zodResolver(createSchema(config.passwordPolicy)),
+ mode: "onChange",
+ defaultValues: { password: "", confirmPassword: "" }
+ });
const search = useSearch({ from: ROUTE_PATHS.Auth.PasswordSetupPage.id });
-
const navigate = useNavigate();
-
const setupPassword = useSetupPassword();
+ const password = watch("password");
+ const confirmPassword = watch("confirmPassword");
+ const { breachStatus, validatePassword } = usePasswordBreachCheck({
+ password,
+ policy: config.passwordPolicy
+ });
- const parsedUrl = search;
- const token = parsedUrl.token as string;
- const email = (parsedUrl.to as string)?.replace(" ", "+").trim();
+ const token = search.token as string;
+ const email = (search.to as string)?.replace(" ", "+").trim();
- const handleSetPassword = async (e: FormEvent<HTMLFormElement>) => {
- e.preventDefault();
- const errorCheck = await passwordCheck({
- password,
- setPasswordErrorTooShort,
- setPasswordErrorTooLong,
- setPasswordErrorNoLetterChar,
- setPasswordErrorNoNumOrSpecialChar,
- setPasswordErrorRepeatedChar,
- setPasswordErrorEscapeChar,
- setPasswordErrorLowEntropy,
- setPasswordErrorBreached
- });
-
- if (password !== confirmPassword) {
- setPasswordsMatch(false);
+ const handleSetPassword = async ({ password: nextPassword }: FormData) => {
+ const latestBreachStatus = await validatePassword(nextPassword);
+ if (latestBreachStatus === "breached") {
+ setError("password", {
+ type: "validate",
+ message: "This password was found in a known data breach."
+ });
return;
}
- setPasswordsMatch(true);
-
- if (!errorCheck) {
- try {
- await setupPassword.mutateAsync({
- email,
- token,
- password
- });
+ try {
+ await setupPassword.mutateAsync({ email, token, password: nextPassword });
+ setIsRedirecting(true);
+ createNotification({
+ type: "success",
+ title: "Password successfully set",
+ text: "Redirecting to login..."
+ });
- setIsRedirecting(true);
-
- createNotification({
- type: "success",
- title: "Password successfully set",
- text: "Redirecting to login..."
- });
-
- setTimeout(() => {
- window.location.href = "/login";
- }, 3000);
- } catch {
- navigate({ to: "/personal-settings" });
- }
+ setTimeout(() => {
+ window.location.href = "/login";
+ }, 3000);
+ } catch {
+ navigate({ to: "/personal-settings" });
}
};
- const isInvalidPassword =
- passwordErrorTooShort ||
- passwordErrorTooLong ||
- passwordErrorNoLetterChar ||
- passwordErrorNoNumOrSpecialChar ||
- passwordErrorRepeatedChar ||
- passwordErrorEscapeChar ||
- passwordErrorLowEntropy ||
- passwordErrorBreached;
+ const isLoading = isSubmitting || setupPassword.isPending || isRedirecting;
+ const showDangerState = submitCount > 0;
+ const isPasswordValidated = breachStatus === "safe" || breachStatus === "unavailable";
+ const doPasswordsMatch = confirmPassword.length > 0 && password === confirmPassword;
return (
- <div className="flex h-screen w-full flex-col items-center justify-center bg-bunker-800">
- <form onSubmit={handleSetPassword}>
- <Card className="flex w-full max-w-lg flex-col rounded-md border border-mineshaft-600 px-8 py-4">
- <CardTitle
- className="p-0 pt-2 pb-4 text-left text-xl"
- subTitle="Make sure to store your password somewhere safe."
- >
- <div className="flex flex-row items-center">
- <div className="flex items-center pb-0.5">
- <FontAwesomeIcon icon={faKey} />
- </div>
- <span className="ml-2.5">Set Password</span>
- </div>
- </CardTitle>
- <FormControl label="Password">
- <Input
+ <AuthPageLayout variant="focused">
+ <form className="w-full" onSubmit={handleSubmit(handleSetPassword)}>
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2">
+ <CardTitle>Set Password</CardTitle>
+ <CardDescription>Make sure to store your password somewhere safe.</CardDescription>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-4">
+ <PasswordField
+ id="password-setup-password"
value={password}
- type={showPassword ? "text" : "password"}
- autoComplete="new-password"
- onChange={(e) => {
- setPassword(e.target.value);
- passwordCheck({
- password: e.target.value,
- setPasswordErrorTooShort,
- setPasswordErrorTooLong,
- setPasswordErrorNoLetterChar,
- setPasswordErrorNoNumOrSpecialChar,
- setPasswordErrorRepeatedChar,
- setPasswordErrorEscapeChar,
- setPasswordErrorLowEntropy,
- setPasswordErrorBreached
- });
- }}
- rightIcon={
- <button
- type="button"
- onClick={() => {
- setShowPassword((prev) => !prev);
- }}
- className="cursor-pointer self-end text-gray-400"
- >
- {showPassword ? (
- <FontAwesomeIcon size="sm" icon={faEyeSlash} />
- ) : (
- <FontAwesomeIcon size="sm" icon={faEye} />
- )}
- </button>
- }
- />
- </FormControl>
- <FormControl
- label="Confirm Password"
- errorText="Passwords must match"
- isError={!passwordsMatch}
- >
- <Input
- value={confirmPassword}
- type={showConfirmPassword ? "text" : "password"}
- autoComplete="new-password"
- onChange={(e) => setConfirmPassword(e.target.value)}
- rightIcon={
- <button
- type="button"
- onClick={() => {
- setShowConfirmPassword((prev) => !prev);
- }}
- className="cursor-pointer self-end text-gray-400"
- >
- {showConfirmPassword ? (
- <FontAwesomeIcon size="sm" icon={faEyeSlash} />
- ) : (
- <FontAwesomeIcon size="sm" icon={faEye} />
- )}
- </button>
- }
+ policy={config.passwordPolicy}
+ breachStatus={breachStatus}
+ registration={register("password")}
+ error={showDangerState ? errors.password : undefined}
+ submitCount={submitCount}
/>
- </FormControl>
- <div className="mb-4 flex w-full max-w-md flex-col items-start rounded-md bg-mineshaft-700 px-2 py-2 transition-opacity duration-100">
- <div className="mb-1 text-sm text-gray-400">Password must contain:</div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorTooShort ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorTooShort ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- at least 14 characters
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorTooLong ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorTooLong ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- at most 100 characters
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorNoLetterChar ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorNoLetterChar ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- at least 1 letter character
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorNoNumOrSpecialChar ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${
- passwordErrorNoNumOrSpecialChar ? "text-gray-400" : "text-gray-600"
- } text-sm`}
- >
- at least 1 number or special character
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorRepeatedChar ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorRepeatedChar ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- at most 3 repeated, consecutive characters
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorEscapeChar ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorEscapeChar ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- no escape characters
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorLowEntropy ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorLowEntropy ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- no personal information
- </div>
- </div>
- <div className="ml-1 flex flex-row items-center justify-start">
- {passwordErrorBreached ? (
- <FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
- ) : (
- <FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
- )}
- <div
- className={`${passwordErrorBreached ? "text-gray-400" : "text-gray-600"} text-sm`}
- >
- password not found in a data breach.
- </div>
- </div>
- </div>
- <Button
- isDisabled={isInvalidPassword || setupPassword.isPending || isRedirecting}
- colorSchema="secondary"
- type="submit"
- isLoading={setupPassword.isPending}
- >
- Submit
- </Button>
- </Card>
+ <AnimatedCollapse
+ isOpen={isPasswordValidated}
+ contentClassName={isPasswordValidated ? "overflow-visible" : undefined}
+ >
+ <Field data-invalid={showDangerState && Boolean(errors.confirmPassword)}>
+ <FieldLabel htmlFor="password-setup-confirm-password">Confirm Password</FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ {...register("confirmPassword")}
+ id="password-setup-confirm-password"
+ type={showConfirmPassword ? "text" : "password"}
+ placeholder="••••••••"
+ autoComplete="new-password"
+ aria-invalid={showDangerState && Boolean(errors.confirmPassword)}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ onClick={() => setShowConfirmPassword((current) => !current)}
+ aria-label={
+ showConfirmPassword
+ ? "Hide password confirmation"
+ : "Show password confirmation"
+ }
+ >
+ {showConfirmPassword ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ <AnimatedCollapse isOpen={confirmPassword.length > 0}>
+ <div className="flex items-start gap-2 pt-1 text-xs" aria-live="polite">
+ {doPasswordsMatch ? (
+ <Check className="mt-0.5 size-3.5 shrink-0 text-success" />
+ ) : (
+ <X className="mt-0.5 size-3.5 shrink-0 text-danger" />
+ )}
+ <span className={doPasswordsMatch ? "text-muted" : "text-danger"}>
+ {doPasswordsMatch ? "Passwords match" : "Passwords do not match"}
+ </span>
+ </div>
+ </AnimatedCollapse>
+ {showDangerState && errors.confirmPassword ? (
+ <FieldError>{errors.confirmPassword.message}</FieldError>
+ ) : null}
+ </Field>
+ </AnimatedCollapse>
+ <Button
+ isDisabled={isLoading || breachStatus === "checking" || breachStatus === "breached"}
+ variant="project"
+ size="lg"
+ type="submit"
+ isFullWidth
+ isPending={isLoading}
+ >
+ Submit
+ </Button>
+ </CardContent>
+ </AuthPagePanel>
</form>
- </div>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/RequestNewInvitePage/RequestNewInvitePage.tsx b/frontend/src/pages/auth/RequestNewInvitePage/RequestNewInvitePage.tsx
index 239d23d49e..a5e8b56c72 100644
--- a/frontend/src/pages/auth/RequestNewInvitePage/RequestNewInvitePage.tsx
+++ b/frontend/src/pages/auth/RequestNewInvitePage/RequestNewInvitePage.tsx
@@ -1,7 +1,9 @@
import { Helmet } from "react-helmet";
import { Link, useSearch } from "@tanstack/react-router";
-import { Button } from "@app/components/v2";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
+import { Button, CardContent, CardDescription, CardHeader, CardTitle } from "@app/components/v3";
/**
* This is the page that shows up when a user's invitation
@@ -13,31 +15,28 @@ export const RequestNewInvitePage = () => {
const isAlreadyMember = reason === "already_member";
return (
- <div className="flex flex-col justify-between bg-bunker-700 md:h-screen">
+ <AuthPageLayout variant="focused">
<Helmet>
<title>{isAlreadyMember ? "Already a Member" : "Request a New Invite"}</title>
<link rel="icon" href="/infisical.ico" />
</Helmet>
- <div className="mt-8 flex h-screen w-screen flex-col items-center justify-center text-bunker-200">
- {isAlreadyMember ? (
- <>
- <p className="text-4xl text-primary-100">Invite already accepted</p>
- <p className="my-4 text-lg">You&apos;re already a member of this organization.</p>
- <Link to="/login">
- <Button size="lg">Go to Login</Button>
- </Link>
- </>
- ) : (
- <>
- <p className="text-4xl text-primary-100">Oops, your invite has expired</p>
- <p className="my-4 text-lg">Ask your admin for a new one.</p>
- <p className="max-w-xs px-7 text-center text-sm leading-tight text-bunker-400">
- <span className="rounded-md bg-primary-500/40 px-1 text-black">Note:</span> If it
- still doesn&apos;t work, please reach out to us at [email protected]
- </p>
- </>
- )}
- </div>
- </div>
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2 text-center">
+ <CardTitle>
+ {isAlreadyMember ? "Invite already accepted" : "Your invite has expired"}
+ </CardTitle>
+ <CardDescription>
+ {isAlreadyMember
+ ? "You're already a member of this organization."
+ : "Ask your administrator to send you a new invitation."}
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Button asChild variant="project" size="lg" isFullWidth>
+ <Link to="/login">Go to Login</Link>
+ </Button>
+ </CardContent>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/SelectOrgPage/EmailDuplicationConfirmation.tsx b/frontend/src/pages/auth/SelectOrgPage/EmailDuplicationConfirmation.tsx
index 8fba090a4c..f06c6a55bc 100644
--- a/frontend/src/pages/auth/SelectOrgPage/EmailDuplicationConfirmation.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/EmailDuplicationConfirmation.tsx
@@ -3,9 +3,11 @@ import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { Link, useNavigate } from "@tanstack/react-router";
+import { useNavigate } from "@tanstack/react-router";
import { format } from "date-fns";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { createNotification } from "@app/components/notifications";
import { Button, DeleteActionModal, Tooltip } from "@app/components/v2";
import { usePopUp } from "@app/hooks";
@@ -37,109 +39,98 @@ export const EmailDuplicationConfirmation = ({ onRemoveDuplicateLater }: Props)
}, [logout, navigate]);
return (
- <div className="flex max-h-screen min-h-screen flex-col justify-center overflow-y-auto bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <Helmet>
- <title>{t("common.head-title", { title: t("login.title") })}</title>
- <link rel="icon" href="/infisical.ico" />
- <meta property="og:image" content="/images/message.png" />
- <meta property="og:title" content={t("login.og-title") ?? ""} />
- <meta name="og:description" content={t("login.og-description") ?? ""} />
- </Helmet>
- <div className="mx-auto mt-20 w-fit max-w-2xl rounded-lg border-2 border-mineshaft-500 p-10 shadow-lg">
- <Link to="/">
- <div className="mb-4 flex justify-center">
- <img
- src="/images/gradientLogo.svg"
- style={{
- height: "90px",
- width: "120px"
- }}
- alt="Infisical logo"
- />
- </div>
- </Link>
- <form className="mx-auto flex w-full flex-col items-center justify-center">
- <div className="mb-6">
- <h1 className="mb-2 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-2xl font-medium text-transparent">
- Multiple Accounts Detected
- </h1>
- <p className="text-md mb-4 text-center text-white">
- <span className="text-slate-300">You&apos;re currently logged in as</span>{" "}
- <b>{duplicateAccounts?.data?.myAccount?.username}</b>.
- </p>
- <div className="mt-4 mb-4 flex flex-col rounded-r border-l-2 border-l-primary bg-mineshaft-300/5 px-4 py-2.5">
- <p className="mt-1 mb-2 text-sm text-bunker-300">
- We&apos;ve detected multiple accounts using variations of the same email address.
+ <>
+ <AuthPageLayout variant="focused" showFooter={false} contentClassName="max-w-2xl">
+ <Helmet>
+ <title>{t("common.head-title", { title: t("login.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ <meta property="og:title" content={t("login.og-title") ?? ""} />
+ <meta name="og:description" content={t("login.og-description") ?? ""} />
+ </Helmet>
+ <AuthPagePanel>
+ <form className="mx-auto flex w-full flex-col">
+ <div className="mb-6">
+ <h1 className="mb-2 font-alliance text-2xl font-normal text-foreground">
+ Multiple Accounts Detected
+ </h1>
+ <p className="mb-4 text-sm text-label">
+ <span>You&apos;re currently logged in as</span>{" "}
+ <b>{duplicateAccounts?.data?.myAccount?.username}</b>.
</p>
+ <div className="mt-4 mb-4 flex flex-col rounded-r border-l-2 border-l-primary bg-mineshaft-300/5 px-4 py-2.5">
+ <p className="mt-1 mb-2 text-sm text-bunker-300">
+ We&apos;ve detected multiple accounts using variations of the same email address.
+ </p>
+ </div>
</div>
- </div>
- <div className="mb-4 w-full border-b border-mineshaft-400 pb-1 text-sm text-mineshaft-200">
- Your other accounts
- </div>
- <div className="flex h-full max-h-60 thin-scrollbar w-full flex-col items-stretch gap-2 overflow-auto rounded-md">
- {duplicateAccounts?.data?.duplicateAccounts?.map((el) => {
- const lastSession = el.devices?.at(-1);
- return (
- <div
- key={el.id}
- className="flex items-center gap-8 rounded-md bg-mineshaft-700 px-4 py-3 text-gray-200"
- >
- <div className="group flex grow flex-col">
- <div className="truncate text-sm transition-colors">{el.username}</div>
- <div className="mt-2 text-xs">
- Last logged in at {format(new Date(el.updatedAt), "Pp")}
+ <div className="mb-4 w-full border-b border-mineshaft-400 pb-1 text-sm text-mineshaft-200">
+ Your other accounts
+ </div>
+ <div className="flex h-full max-h-60 thin-scrollbar w-full flex-col items-stretch gap-2 overflow-auto rounded-md">
+ {duplicateAccounts?.data?.duplicateAccounts?.map((el) => {
+ const lastSession = el.devices?.at(-1);
+ return (
+ <div
+ key={el.id}
+ className="flex items-center gap-8 rounded-md bg-mineshaft-700 px-4 py-3 text-gray-200"
+ >
+ <div className="group flex grow flex-col">
+ <div className="truncate text-sm transition-colors">{el.username}</div>
+ <div className="mt-2 text-xs">
+ Last logged in at {format(new Date(el.updatedAt), "Pp")}
+ </div>
+ <div className="mt-2 text-xs">
+ Organizations: {el?.organizations?.map((i) => i.slug)?.join(",")}
+ </div>
</div>
- <div className="mt-2 text-xs">
- Organizations: {el?.organizations?.map((i) => i.slug)?.join(",")}
+ <div>
+ <Tooltip
+ className="max-w-lg"
+ content={
+ <div className="flex flex-col space-y-1 text-sm">
+ <div>IP: {lastSession?.ip || "-"}</div>
+ <div>User Agent: {lastSession?.userAgent || "-"}</div>
+ </div>
+ }
+ >
+ <FontAwesomeIcon icon={faInfoCircle} />
+ </Tooltip>
</div>
</div>
- <div>
- <Tooltip
- className="max-w-lg"
- content={
- <div className="flex flex-col space-y-1 text-sm">
- <div>IP: {lastSession?.ip || "-"}</div>
- <div>User Agent: {lastSession?.userAgent || "-"}</div>
- </div>
- }
- >
- <FontAwesomeIcon icon={faInfoCircle} />
- </Tooltip>
- </div>
- </div>
- );
- })}
- </div>
- <div className="mt-4 flex w-full flex-col">
- <div className="flex gap-6">
- <Button
- className="flex-1 grow"
- isLoading={removeDuplicateEmails.isPending}
- onClick={() => handlePopUpToggle("removeDuplicateConfirm", true)}
- >
- Delete all other accounts
- </Button>
+ );
+ })}
+ </div>
+ <div className="mt-4 flex w-full flex-col">
+ <div className="flex gap-6">
+ <Button
+ className="flex-1 grow"
+ isLoading={removeDuplicateEmails.isPending}
+ onClick={() => handlePopUpToggle("removeDuplicateConfirm", true)}
+ >
+ Delete all other accounts
+ </Button>
+ <Button
+ variant="outline_bg"
+ onClick={() => onRemoveDuplicateLater()}
+ className="flex-1 grow"
+ >
+ Remind me later
+ </Button>
+ </div>
<Button
- variant="outline_bg"
- onClick={() => onRemoveDuplicateLater()}
- className="flex-1 grow"
+ isLoading={logout.isPending}
+ variant="plain"
+ colorSchema="secondary"
+ className="mt-4"
+ onClick={handleLogout}
>
- Remind me later
+ Change Account
</Button>
</div>
- <Button
- isLoading={logout.isPending}
- variant="plain"
- colorSchema="secondary"
- className="mt-4"
- onClick={handleLogout}
- >
- Change Account
- </Button>
- </div>
- </form>
- </div>
- <div className="pb-28" />
+ </form>
+ </AuthPagePanel>
+ </AuthPageLayout>
<DeleteActionModal
isOpen={popUp.removeDuplicateConfirm.isOpen}
subTitle={`You’re currently logged in as ${duplicateAccounts?.data?.myAccount?.username}. Once you confirm, your other duplicate accounts will be permanently removed. Please make sure none of those accounts contain any production secrets, as this action cannot be undone.`}
@@ -159,6 +150,6 @@ export const EmailDuplicationConfirmation = ({ onRemoveDuplicateLater }: Props)
})
}
/>
- </div>
+ </>
);
};
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
index 1a87162ed7..4bb817b062 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
@@ -1,14 +1,17 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
-import { Link, useNavigate, useRouteContext, useRouter, useSearch } from "@tanstack/react-router";
+import { useNavigate, useRouteContext, useRouter, useSearch } from "@tanstack/react-router";
import { addSeconds, format, formatISO } from "date-fns";
import { ChevronRight, LogIn, Search } from "lucide-react";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { Mfa } from "@app/components/auth/Mfa";
import { createNotification } from "@app/components/notifications";
import SecurityClient from "@app/components/utilities/SecurityClient";
-import { Button, ContentLoader, Input, Spinner } from "@app/components/v2";
+import { ContentLoader, Input, Spinner } from "@app/components/v2";
+import { VerificationCodeHeader } from "@app/components/v3";
import { SessionStorageKeys } from "@app/const";
import { ROUTE_PATHS } from "@app/const/routes";
import { useToggle } from "@app/hooks";
@@ -51,12 +54,12 @@ const OrgRow = ({
className={`group flex h-14 w-full cursor-pointer items-center justify-between rounded-md border border-mineshaft-600 px-4 shadow-md transition-colors ${bgClass}`}
>
<div className="flex flex-col items-start">
- <p className="truncate">{name}</p>
+ <p className="truncate font-alliance">{name}</p>
{(label || joinedAt) && (
<p className="text-xs text-mineshaft-400">
{label}
{label && joinedAt && " · "}
- {joinedAt && <>Member since {format(new Date(joinedAt), "MMM d yyyy")}</>}
+ {joinedAt && <>Member since {format(new Date(joinedAt), "MMM d, yyyy")}</>}
</p>
)}
</div>
@@ -367,16 +370,16 @@ export const SelectOrgPage = () => {
);
}
- return (
- <div className="flex max-h-screen min-h-screen flex-col justify-center overflow-y-auto bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <Helmet>
- <title>{t("common.head-title", { title: t("login.title") })}</title>
- <link rel="icon" href="/infisical.ico" />
- <meta property="og:image" content="/images/message.png" />
- <meta property="og:title" content={t("login.og-title") ?? ""} />
- <meta name="og:description" content={t("login.og-description") ?? ""} />
- </Helmet>
- {shouldShowMfa ? (
+ if (shouldShowMfa) {
+ return (
+ <>
+ <Helmet>
+ <title>{t("common.head-title", { title: t("login.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ <meta property="og:title" content={t("login.og-title") ?? ""} />
+ <meta name="og:description" content={t("login.og-description") ?? ""} />
+ </Helmet>
<Mfa
email={user.email as string}
successCallback={() => {
@@ -385,73 +388,74 @@ export const SelectOrgPage = () => {
}
}}
method={requiredMfaMethod as MfaMethod}
+ onChangeAccount={handleLogout}
+ />
+ </>
+ );
+ }
+
+ return (
+ <AuthPageLayout variant="focused" showFooter={false}>
+ <Helmet>
+ <title>{t("common.head-title", { title: t("login.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ <meta property="og:title" content={t("login.og-title") ?? ""} />
+ <meta name="og:description" content={t("login.og-description") ?? ""} />
+ </Helmet>
+ <AuthPagePanel>
+ <VerificationCodeHeader
+ title="Choose your organization as"
+ recipient={user.username}
+ action={
+ <button
+ aria-label={`Sign out ${user.username}`}
+ className="shrink-0 cursor-pointer text-sm text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ onClick={handleLogout}
+ type="button"
+ >
+ Sign out
+ </button>
+ }
/>
- ) : (
- <div className="mx-auto mt-20 w-full max-w-md pb-28">
- <Link to="/">
- <div className="mb-4 flex justify-center">
- <img
- src="/images/gradientLogo.svg"
- style={{ height: "90px", width: "120px" }}
- alt="Infisical logo"
+
+ <div className="rounded-xl border-2 border-mineshaft-500 shadow-lg">
+ {totalOrgCount >= 5 && (
+ <div className="border-b border-mineshaft-600 px-4 py-3">
+ <Input
+ value={searchTerm}
+ onChange={(e) => setSearchTerm(e.target.value)}
+ placeholder={
+ selectedRootOrg ? "Search sub-organizations..." : "Search organizations..."
+ }
+ leftIcon={<Search className="size-4" />}
+ className="h-10"
/>
</div>
- </Link>
- <div className="mb-8 space-y-2">
- <h1 className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-2xl font-medium text-transparent">
- Choose your organization
- </h1>
- <div className="space-y-1">
- <p className="text-md text-center text-gray-500">
- You&apos;re currently logged in as <strong>{user.username}</strong>
- </p>
- <p className="text-md text-center text-gray-500">
- Not you?{" "}
- <Button variant="link" onClick={handleLogout} className="font-medium">
- Change account
- </Button>
- </p>
+ )}
+
+ {selectedRootOrg && (
+ <div className="border-b border-mineshaft-600 px-4 py-2">
+ <nav className="flex items-center gap-1.5 text-sm">
+ <button
+ type="button"
+ onClick={() => {
+ setSelectedRootOrg(null);
+ setSearchTerm("");
+ }}
+ className="text-mineshaft-400 transition-colors hover:text-gray-200"
+ >
+ All organizations
+ </button>
+ <span className="text-white">›</span>
+ <span className="font-medium text-gray-300">{selectedRootOrg.name}</span>
+ </nav>
</div>
- </div>
-
- <div className="rounded-lg border-2 border-mineshaft-500 shadow-lg">
- {totalOrgCount >= 5 && (
- <div className="border-b border-mineshaft-600 px-4 py-3">
- <Input
- value={searchTerm}
- onChange={(e) => setSearchTerm(e.target.value)}
- placeholder={
- selectedRootOrg ? "Search sub-organizations..." : "Search organizations..."
- }
- leftIcon={<Search className="size-4" />}
- className="h-10"
- />
- </div>
- )}
+ )}
- {selectedRootOrg && (
- <div className="border-b border-mineshaft-600 px-4 py-2">
- <nav className="flex items-center gap-1.5 text-sm">
- <button
- type="button"
- onClick={() => {
- setSelectedRootOrg(null);
- setSearchTerm("");
- }}
- className="text-mineshaft-400 transition-colors hover:text-gray-200"
- >
- All organizations
- </button>
- <span className="text-white">›</span>
- <span className="font-medium text-gray-300">{selectedRootOrg.name}</span>
- </nav>
- </div>
- )}
-
- <div className="max-h-96 thin-scrollbar overflow-y-auto p-2">{renderListContent()}</div>
- </div>
+ <div className="max-h-96 thin-scrollbar overflow-y-auto p-2">{renderListContent()}</div>
</div>
- )}
- </div>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx b/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx
index e5fab7d00f..8b2bb71b7b 100644
--- a/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx
+++ b/frontend/src/pages/auth/SignUpInvitePage/SignUpInvitePage.tsx
@@ -1,43 +1,39 @@
import { Helmet } from "react-helmet";
-import { Link, useNavigate, useRouteContext } from "@tanstack/react-router";
+import { Link, useRouteContext } from "@tanstack/react-router";
-import { Button } from "@app/components/v2";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
+import { Button, CardContent, CardDescription, CardHeader, CardTitle } from "@app/components/v3";
import { SignUpPage } from "../SignUpPage/SignUpPage";
export const SignupInvitePage = () => {
- const navigate = useNavigate();
const { inviteEmail, error } = useRouteContext({
from: "/_restrict-login-signup/signupinvite"
}) as { inviteEmail?: string; error?: string };
if (error) {
return (
- <div className="flex min-h-screen flex-col items-center justify-center bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
+ <AuthPageLayout variant="focused">
<Helmet>
<title>Invalid Invitation</title>
<link rel="icon" href="/infisical.ico" />
</Helmet>
- <Link to="/">
- <div className="mb-8 flex justify-center">
- <img
- src="/images/gradientLogo.svg"
- style={{ height: "90px", width: "120px" }}
- alt="Infisical logo"
- />
- </div>
- </Link>
- <div className="mx-auto w-full max-w-md rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-8 text-center">
- <h1 className="mb-2 text-xl font-medium text-gray-200">Invitation Invalid</h1>
- <p className="mb-6 text-sm text-gray-400">{error}</p>
- <p className="mb-4 text-sm text-gray-500">
- Please ask your organization admin to send a new invitation.
- </p>
- <Button onClick={() => navigate({ to: "/login" })} size="sm" colorSchema="primary">
- Go to Login
- </Button>
- </div>
- </div>
+ <AuthPagePanel>
+ <CardHeader className="mb-6 gap-2 text-center">
+ <CardTitle>Invitation Invalid</CardTitle>
+ <CardDescription>{error}</CardDescription>
+ <CardDescription>
+ Please ask your organization administrator to send a new invitation.
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Button asChild variant="project" size="lg" isFullWidth>
+ <Link to="/login">Go to Login</Link>
+ </Button>
+ </CardContent>
+ </AuthPagePanel>
+ </AuthPageLayout>
);
}
diff --git a/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx b/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx
index 25d3a3fb70..5c4ef35172 100644
--- a/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx
+++ b/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx
@@ -3,15 +3,12 @@ import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "@tanstack/react-router";
-import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";
-import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";
-import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
import CodeInputStep from "@app/components/auth/CodeInputStep";
import InitialSignupStep from "@app/components/auth/InitialSignupStep";
import TeamInviteStep from "@app/components/auth/TeamInviteStep";
import UserInfoStep from "@app/components/auth/UserInfoStep";
import { createNotification } from "@app/components/notifications";
-import { Button } from "@app/components/v3";
import { useServerConfig } from "@app/context";
import { useSelectOrganization } from "@app/hooks/api/auth/queries";
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
@@ -24,6 +21,11 @@ enum SignupSection {
InviteTeam = "invite-team"
}
+type PendingEmailVerification = {
+ email: string;
+ resendCooldownEndTime: number;
+};
+
export interface SignUpPageProps {
invite?: {
email: string;
@@ -33,7 +35,8 @@ export interface SignUpPageProps {
export const SignUpPage = ({ invite }: SignUpPageProps) => {
const isInvite = Boolean(invite);
const [email, setEmail] = useState(invite?.email ?? "");
- const [resendCooldownSeconds, setResendCooldownSeconds] = useState(0);
+ const [pendingEmailVerification, setPendingEmailVerification] =
+ useState<PendingEmailVerification | null>(null);
const [section, setSection] = useState<SignupSection>(
isInvite ? SignupSection.UserInfo : SignupSection.Email
);
@@ -52,9 +55,13 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {
}
}, [config.allowSignUp]);
- const handleEmailComplete = (cooldownSeconds: number) => {
- setResendCooldownSeconds(cooldownSeconds);
+ const handleEmailComplete = (verificationEmail: string, cooldownSeconds: number) => {
+ setEmail(verificationEmail);
if (serverDetails?.emailConfigured) {
+ setPendingEmailVerification({
+ email: verificationEmail,
+ resendCooldownEndTime: Date.now() + cooldownSeconds * 1000
+ });
setSection(SignupSection.VerifyCode);
} else {
setSection(SignupSection.UserInfo);
@@ -62,9 +69,27 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {
};
const handleCodeVerified = () => {
+ setPendingEmailVerification(null);
setSection(SignupSection.UserInfo);
};
+ const handleChangeEmail = () => {
+ setSection(SignupSection.Email);
+ };
+
+ const handleResumeEmailVerification = () => {
+ if (!pendingEmailVerification) return;
+
+ setEmail(pendingEmailVerification.email);
+ setSection(SignupSection.VerifyCode);
+ };
+
+ const handleResendCooldownChange = (resendCooldownEndTime: number) => {
+ setPendingEmailVerification((pendingVerification) =>
+ pendingVerification ? { ...pendingVerification, resendCooldownEndTime } : null
+ );
+ };
+
const handleUserInfoComplete = async () => {
if (isInvite) {
const userOrgs = await fetchOrganizations();
@@ -103,6 +128,8 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {
email={email}
setEmail={setEmail}
incrementStep={handleEmailComplete}
+ pendingVerificationEmail={pendingEmailVerification?.email}
+ onResumeVerification={handleResumeEmailVerification}
/>
);
case SignupSection.VerifyCode:
@@ -110,7 +137,9 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {
<CodeInputStep
email={email}
onComplete={handleCodeVerified}
- initialCooldown={resendCooldownSeconds}
+ onChangeEmail={handleChangeEmail}
+ resendCooldownEndTime={pendingEmailVerification?.resendCooldownEndTime ?? 0}
+ onResendCooldownChange={handleResendCooldownChange}
/>
);
case SignupSection.UserInfo:
@@ -124,9 +153,52 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {
}
};
+ const renderBottomContent = () => {
+ if (section === SignupSection.Email) {
+ return (
+ <p className="text-xs text-pretty text-label">
+ By signing up, you agree to our{" "}
+ <a
+ href="https://infisical.com/terms/cloud"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="underline underline-offset-2 transition-colors duration-200 hover:text-foreground hover:decoration-project/45"
+ >
+ Terms of Service
+ </a>{" "}
+ and{" "}
+ <a
+ href="https://infisical.com/privacy"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="underline underline-offset-2 transition-colors duration-200 hover:text-foreground hover:decoration-project/45"
+ >
+ Privacy Policy
+ </a>
+ .
+ </p>
+ );
+ }
+
+ if (section === SignupSection.VerifyCode) {
+ return (
+ <div className="flex items-center justify-center gap-1.5 text-sm">
+ <span className="text-label">Already have an account?</span>
+ <Link
+ to="/login"
+ className="text-foreground/95 underline decoration-project/60 underline-offset-2 transition-colors duration-200 hover:decoration-project"
+ >
+ Log in
+ </Link>
+ </div>
+ );
+ }
+
+ return undefined;
+ };
+
return (
- <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4 py-4">
- <AuthPageBackground />
+ <AuthPageLayout showFooter={false} bottomContent={renderBottomContent()}>
<Helmet>
<title>{t("common.head-title", { title: t("signup.title") })}</title>
<link rel="icon" href="/infisical.ico" />
@@ -134,17 +206,13 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {
<meta property="og:title" content={t("signup.og-title") as string} />
<meta name="og:description" content={t("signup.og-description") as string} />
</Helmet>
- <AuthPageHeader>
- <Button asChild variant="project">
- <Link to="/login">Log In</Link>
- </Button>
- </AuthPageHeader>
- <div className="relative z-10 my-auto flex flex-col items-center py-10">
+ {section === SignupSection.VerifyCode ? (
+ <div className="w-full">{renderView()}</div>
+ ) : (
<form className="w-full" onSubmit={(e) => e.preventDefault()}>
{renderView()}
</form>
- </div>
- <AuthPageFooter />
- </div>
+ )}
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx b/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
index c4282e176f..bebdd7caeb 100644
--- a/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
+++ b/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
@@ -1,59 +1,28 @@
import { useEffect, useState } from "react";
-import ReactCodeInput from "react-code-input";
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { Link, useNavigate, useSearch } from "@tanstack/react-router";
import { jwtDecode } from "jwt-decode";
-import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";
-import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";
-import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";
+import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
+import { AuthPagePanel } from "@app/components/auth/AuthPagePanel";
import { createNotification } from "@app/components/notifications";
import SecurityClient from "@app/components/utilities/SecurityClient";
-import { Button, Card, CardContent, CardHeader, CardTitle, FieldError } from "@app/components/v3";
+import {
+ Button,
+ CardContent,
+ useClientResendDelay,
+ VerificationCodeForm,
+ VerificationCodeHeader,
+ VerificationCodeResend
+} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import { isInfisicalCloud } from "@app/helpers/platform";
import { getHubSpotUtk } from "@app/helpers/utmTracking";
import { useSendEmailVerificationCode } from "@app/hooks/api";
import { useCompleteAccountSignup } from "@app/hooks/api/auth/queries";
-const codeInputStyle = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "55px",
- borderRadius: "6px",
- fontSize: "24px",
- height: "55px",
- paddingLeft: "7",
- backgroundColor: "transparent",
- color: "#ebebeb",
- border: "1px solid #2b2c30",
- textAlign: "center",
- outlineColor: "#2d2f33",
- borderColor: "#2b2c30"
- }
-} as const;
-
-const codeInputStylePhone = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield",
- width: "40px",
- borderRadius: "6px",
- fontSize: "24px",
- height: "40px",
- paddingLeft: "7",
- backgroundColor: "transparent",
- color: "#ebebeb",
- border: "1px solid #2b2c30",
- textAlign: "center",
- outlineColor: "#2d2f33",
- borderColor: "#2b2c30"
- }
-} as const;
+const CLIENT_RESEND_DELAY_SECONDS = 20;
export const SignupSsoPage = () => {
const { t } = useTranslation();
@@ -73,7 +42,9 @@ export const SignupSsoPage = () => {
isEmailVerified?: boolean;
};
- const { mutateAsync: sendEmailVerificationCode } = useSendEmailVerificationCode();
+ const { mutateAsync: sendEmailVerificationCode, isPending: isResending } =
+ useSendEmailVerificationCode();
+ const resendDelay = useClientResendDelay(CLIENT_RESEND_DELAY_SECONDS);
useEffect(() => {
SecurityClient.setSignupToken(token);
@@ -112,6 +83,7 @@ export const SignupSsoPage = () => {
const handleResendCode = async () => {
try {
await sendEmailVerificationCode(token);
+ resendDelay.restartDelay();
createNotification({
text: "Successfully resent code",
type: "success"
@@ -125,8 +97,14 @@ export const SignupSsoPage = () => {
};
return (
- <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4">
- <AuthPageBackground />
+ <AuthPageLayout
+ variant="focused"
+ headerAction={
+ <Button asChild variant="outline" size="sm">
+ <Link to="/login">Log In</Link>
+ </Button>
+ }
+ >
<Helmet>
<title>{t("common.head-title", { title: t("signup.title") })}</title>
<link rel="icon" href="/infisical.ico" />
@@ -134,82 +112,35 @@ export const SignupSsoPage = () => {
<meta property="og:title" content={t("signup.og-title") as string} />
<meta name="og:description" content={t("signup.og-description") as string} />
</Helmet>
- <AuthPageHeader>
- <Button asChild>
- <Link to="/login">Log In</Link>
- </Button>
- </AuthPageHeader>
- <div className="relative z-10 my-auto flex flex-col items-center py-10">
- <form className="w-full" onSubmit={(e) => e.preventDefault()}>
- <div className="mx-auto flex w-full flex-col items-center justify-center">
- <Card className="mx-auto w-full max-w-md items-stretch gap-0 p-6">
- <CardHeader className="mb-2 gap-2">
- <CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-[1.55rem] font-medium text-transparent">
- We&apos;ve sent a verification code to
- </CardTitle>
- </CardHeader>
- <CardContent>
- <p className="text-md my-1 flex justify-center font-medium text-foreground">
- {decoded.email}
- </p>
- <div className="mx-auto hidden w-max min-w-[20rem] md:block">
- <ReactCodeInput
- name=""
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setCode}
- {...codeInputStyle}
- className="code-input-v3 mt-6 mb-2"
- />
- </div>
- <div className="mx-auto mt-4 block w-max md:hidden">
- <ReactCodeInput
- name=""
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setCode}
- {...codeInputStylePhone}
- className="code-input-v3 mt-2 mb-2"
- />
- </div>
- {completeAccountSignup.isError && (
- <FieldError>Oops. Your code is wrong. Please try again.</FieldError>
- )}
- <div className="mt-4 w-full">
- <Button
- type="submit"
- onClick={handleSubmit}
- variant="project"
- size="lg"
- isFullWidth
- isPending={completeAccountSignup.isPending}
- isDisabled={completeAccountSignup.isPending}
- >
- Verify
- </Button>
- </div>
- <div className="mt-6 flex flex-col items-center gap-2 text-xs text-label">
- <div className="flex flex-row items-baseline gap-1">
- <button
- disabled={completeAccountSignup.isPending}
- onClick={handleResendCode}
- type="button"
- >
- <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
- Don&apos;t see the code? Resend
- </span>
- </button>
- </div>
- <p className="text-label">Make sure to check your spam inbox.</p>
- </div>
- </CardContent>
- </Card>
- </div>
- </form>
+ <div className="mx-auto flex w-full flex-col items-center justify-center">
+ <AuthPagePanel>
+ <VerificationCodeHeader
+ title="We've sent a verification code to"
+ recipient={decoded.email}
+ />
+ <CardContent>
+ <VerificationCodeForm
+ name="signup-sso-verification-code"
+ value={code}
+ onChange={setCode}
+ onSubmit={handleSubmit}
+ isPending={completeAccountSignup.isPending}
+ error={
+ completeAccountSignup.isError
+ ? "Oops. Your code is wrong. Please try again."
+ : undefined
+ }
+ >
+ <VerificationCodeResend
+ isDisabled={completeAccountSignup.isPending}
+ isResending={isResending}
+ remainingSeconds={resendDelay.remainingSeconds}
+ onResend={handleResendCode}
+ />
+ </VerificationCodeForm>
+ </CardContent>
+ </AuthPagePanel>
</div>
- <AuthPageFooter />
- </div>
+ </AuthPageLayout>
);
};
diff --git a/frontend/src/pages/middlewares/restrict-login-signup.tsx b/frontend/src/pages/middlewares/restrict-login-signup.tsx
index 69fa9ff809..5b62836a57 100644
--- a/frontend/src/pages/middlewares/restrict-login-signup.tsx
+++ b/frontend/src/pages/middlewares/restrict-login-signup.tsx
@@ -10,7 +10,6 @@ import { z } from "zod";
import { Button } from "@app/components/v2";
import { SessionStorageKeys } from "@app/const";
import { useServerConfig } from "@app/context";
-import { authKeys, fetchAuthToken } from "@app/hooks/api/auth/queries";
import { setAuthToken } from "@app/hooks/api/reactQuery";
import { GtmHead } from "@app/hooks/useGtm";
@@ -82,12 +81,7 @@ export const Route = createFileRoute("/_restrict-login-signup")({
throw redirect({ to: "/admin/signup" });
}
- const data = await context.queryClient
- .ensureQueryData({
- queryKey: authKeys.getAuthToken,
- queryFn: fetchAuthToken
- })
- .catch(() => null);
+ const data = context.authToken;
if (!data) return;
setAuthToken(data.token);
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSubOrgsTab/OrgSubOrgsTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSubOrgsTab/OrgSubOrgsTab.tsx
index 56ea41448c..8972aae262 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSubOrgsTab/OrgSubOrgsTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSubOrgsTab/OrgSubOrgsTab.tsx
@@ -214,14 +214,12 @@ export const OrgSubOrgsTab = () => {
if (shouldShowMfa) {
return (
- <div className="flex max-h-screen min-h-screen flex-col items-center justify-center gap-2 overflow-y-auto bg-linear-to-tr from-mineshaft-600 via-mineshaft-800 to-bunker-700">
- <Mfa
- email={user.email as string}
- method={requiredMfaMethod}
- successCallback={mfaSuccessCallback}
- closeMfa={() => toggleShowMfa.off()}
- />
- </div>
+ <Mfa
+ email={user.email as string}
+ method={requiredMfaMethod}
+ successCallback={mfaSuccessCallback}
+ closeMfa={() => toggleShowMfa.off()}
+ />
);
}
diff --git a/frontend/src/pages/root.tsx b/frontend/src/pages/root.tsx
index 3533030158..169c9ac610 100644
--- a/frontend/src/pages/root.tsx
+++ b/frontend/src/pages/root.tsx
@@ -5,7 +5,8 @@ import { NotificationContainer } from "@app/components/notifications";
import { TooltipProvider } from "@app/components/v2";
import { adminQueryKeys, fetchServerConfig } from "@app/hooks/api/admin/queries";
import { TServerConfig } from "@app/hooks/api/admin/types";
-import { authKeys, fetchAuthToken } from "@app/hooks/api/auth/queries";
+import { authKeys } from "@app/hooks/api/auth/queries";
+import { fetchAuthToken, shouldRetryAuthTokenFetch } from "@app/hooks/api/auth/refresh";
import { queryClient } from "@app/hooks/api/reactQuery";
type TRouterContext = {
@@ -27,21 +28,23 @@ const RootPage = () => {
export const Route = createRootRouteWithContext<TRouterContext>()({
component: RootPage,
beforeLoad: async ({ context }) => {
- await context.queryClient
+ const authToken = await context.queryClient
.fetchQuery({
queryKey: authKeys.getAuthToken,
queryFn: fetchAuthToken,
- staleTime: Infinity
+ staleTime: Infinity,
+ retry: shouldRetryAuthTokenFetch
})
.catch(() => {
// No valid refresh cookie — boot continues unauthenticated.
// Downstream middlewares handle redirects for protected routes.
+ return null;
});
const serverConfig = await context.queryClient.ensureQueryData({
queryKey: adminQueryKeys.serverConfig(),
queryFn: fetchServerConfig
});
- return { serverConfig };
+ return { authToken, serverConfig };
}
});
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx
index c4ce5c4009..38f79cca3c 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx
@@ -1,5 +1,4 @@
import { useState } from "react";
-import ReactCodeInput from "react-code-input";
import { Controller, useForm, useWatch } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
@@ -7,6 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
+import { VerificationCodeForm } from "@app/components/v3";
import { useUser } from "@app/context";
import {
useRequestEmailChangeOTP,
@@ -24,27 +24,6 @@ const emailSchema = z
export type EmailFormData = z.infer<typeof emailSchema>;
-const otpInputProps = {
- inputStyle: {
- fontFamily: "monospace",
- margin: "4px",
- MozAppearance: "textfield" as const,
- width: "45px",
- borderRadius: "6px",
- fontSize: "18px",
- height: "45px",
- padding: "0",
- paddingLeft: "0",
- paddingRight: "0",
- backgroundColor: "#262626",
- color: "white",
- border: "1px solid #404040",
- textAlign: "center" as const,
- outlineColor: "#8ca542",
- borderColor: "#404040"
- }
-};
-
type OtpStep = "currentEmail" | "newEmail";
export const ChangeEmailSection = () => {
@@ -234,20 +213,15 @@ export const ChangeEmailSection = () => {
}}
>
<ModalContent title={otpTitle} subTitle={otpSubTitle}>
- <div className="flex flex-col items-center space-y-4">
- <div className="flex justify-center">
- <ReactCodeInput
- key={otpStep ?? "closed"}
- name="otp-input"
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setTypedOTP}
- value={typedOTP}
- {...otpInputProps}
- className="mb-4"
- />
- </div>
+ <VerificationCodeForm
+ key={otpStep ?? "closed"}
+ name="email-change-verification-code"
+ value={typedOTP}
+ onChange={setTypedOTP}
+ onSubmit={onOtpSubmit}
+ submitLabel={otpButtonLabel}
+ isPending={isOtpSubmitLoading}
+ >
{otpStep === "newEmail" && (
<p className="text-center text-xs text-mineshaft-400">
Didn&apos;t get a code? If the new address already belongs to another Infisical
@@ -255,19 +229,17 @@ export const ChangeEmailSection = () => {
completed.
</p>
)}
- <div className="flex gap-2">
- <Button colorSchema="secondary" variant="outline" onClick={closeOtpModal}>
- Cancel
- </Button>
+ <div className="flex justify-center">
<Button
- onClick={onOtpSubmit}
- isLoading={isOtpSubmitLoading}
- isDisabled={typedOTP.length !== 6 || isOtpSubmitLoading}
+ type="button"
+ colorSchema="secondary"
+ variant="outline"
+ onClick={closeOtpModal}
>
- {otpButtonLabel}
+ Cancel
</Button>
</div>
- </div>
+ </VerificationCodeForm>
</ModalContent>
</Modal>
</>
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/ChangePasswordSection/ChangePasswordSection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/ChangePasswordSection/ChangePasswordSection.tsx
index 1ae4921626..cc38ce4e4a 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/ChangePasswordSection/ChangePasswordSection.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/ChangePasswordSection/ChangePasswordSection.tsx
@@ -1,66 +1,66 @@
-import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
-import { useTranslation } from "react-i18next";
-import { faXmark } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
+import { PasswordField } from "@app/components/auth/PasswordField";
import { createNotification } from "@app/components/notifications";
-import checkPassword from "@app/components/utilities/checks/password/checkPassword";
+import { createPasswordSchema } from "@app/components/utilities/checks/password/passwordPolicy";
+import { usePasswordBreachCheck } from "@app/components/utilities/checks/password/usePasswordBreachCheck";
import { Button, FormControl, Input } from "@app/components/v2";
-import { useUser } from "@app/context";
+import { useServerConfig, useUser } from "@app/context";
+import { TPasswordPolicy } from "@app/hooks/api/admin/types";
import { useResetUserPasswordV2, useSendPasswordSetupEmail } from "@app/hooks/api/auth/queries";
import { UserEncryptionVersion } from "@app/hooks/api/auth/types";
import { clearSession } from "@app/hooks/api/users/queries";
-type Errors = {
- tooShort?: string;
- tooLong?: string;
- noLetterChar?: string;
- noNumOrSpecialChar?: string;
- repeatedChar?: string;
- escapeChar?: string;
- lowEntropy?: string;
- breached?: string;
-};
-
-const schema = z
- .object({
- oldPassword: z.string(),
- newPassword: z.string()
- })
- .required();
+const createSchema = (passwordPolicy: TPasswordPolicy) =>
+ z.object({
+ oldPassword: z.string().min(1, "Current password is required"),
+ newPassword: createPasswordSchema(passwordPolicy)
+ });
-export type FormData = z.infer<typeof schema>;
+export type FormData = z.infer<ReturnType<typeof createSchema>>;
export const ChangePasswordSection = () => {
- const { t } = useTranslation();
const navigate = useNavigate();
const { user } = useUser();
- const { reset, control, handleSubmit } = useForm({
+ const { config } = useServerConfig();
+ const {
+ reset,
+ control,
+ handleSubmit,
+ register,
+ setError,
+ watch,
+ formState: { errors, isSubmitting, submitCount }
+ } = useForm<FormData>({
defaultValues: {
oldPassword: "",
newPassword: ""
},
- resolver: zodResolver(schema)
+ resolver: zodResolver(createSchema(config.passwordPolicy)),
+ mode: "onChange"
+ });
+ const newPassword = watch("newPassword");
+ const { breachStatus, validatePassword } = usePasswordBreachCheck({
+ password: newPassword,
+ policy: config.passwordPolicy
});
- const [errors, setErrors] = useState<Errors>({});
- const [isLoading, setIsLoading] = useState(false);
const sendSetupPasswordEmail = useSendPasswordSetupEmail();
const { mutateAsync: resetPasswordV2 } = useResetUserPasswordV2();
- const onFormSubmit = async ({ oldPassword, newPassword }: FormData) => {
+ const onFormSubmit = async ({ oldPassword, newPassword: submittedPassword }: FormData) => {
try {
- const errorCheck = await checkPassword({
- password: newPassword,
- setErrors
- });
-
- if (errorCheck) return;
- setIsLoading(true);
+ const latestBreachStatus = await validatePassword(submittedPassword);
+ if (latestBreachStatus === "breached") {
+ setError("newPassword", {
+ type: "validate",
+ message: "This password was found in a known data breach."
+ });
+ return;
+ }
if (user.encryptionVersion !== UserEncryptionVersion.V2) {
createNotification({
@@ -68,17 +68,15 @@ export const ChangePasswordSection = () => {
type: "error"
});
- setIsLoading(false);
return;
}
await resetPasswordV2({
oldPassword,
- newPassword
+ newPassword: submittedPassword
});
clearSession();
- setIsLoading(false);
createNotification({
text: "Successfully changed password",
type: "success"
@@ -88,7 +86,6 @@ export const ChangePasswordSection = () => {
navigate({ to: "/login" });
} catch (err) {
console.error(err);
- setIsLoading(false);
createNotification({
text: "Failed to change password",
type: "error"
@@ -130,42 +127,22 @@ export const ChangePasswordSection = () => {
/>
</div>
<div className="max-w-md">
- <Controller
- defaultValue=""
- render={({ field, fieldState: { error } }) => (
- <FormControl isError={Boolean(error)} errorText={error?.message}>
- <Input
- placeholder="New password"
- type="password"
- {...field}
- className="bg-mineshaft-800"
- />
- </FormControl>
- )}
- control={control}
- name="newPassword"
+ <PasswordField
+ id="change-password-new-password"
+ value={newPassword}
+ policy={config.passwordPolicy}
+ breachStatus={breachStatus}
+ registration={register("newPassword")}
+ error={errors.newPassword}
+ submitCount={submitCount}
/>
</div>
- {Object.keys(errors).length > 0 && (
- <div className="my-4 flex max-w-md flex-col items-start rounded-md bg-white/5 px-2 py-2">
- <div className="mb-2 text-sm text-gray-400">{t("section.password.validate-base")}</div>
- {Object.keys(errors).map((key) => {
- if (errors[key as keyof Errors]) {
- return (
- <div className="items-top ml-1 flex flex-row justify-start" key={key}>
- <div>
- <FontAwesomeIcon icon={faXmark} className="text-md mr-2.5 ml-0.5 text-red" />
- </div>
- <p className="text-sm text-gray-400">{errors[key as keyof Errors]}</p>
- </div>
- );
- }
-
- return null;
- })}
- </div>
- )}
- <Button type="submit" colorSchema="secondary" isLoading={isLoading} isDisabled={isLoading}>
+ <Button
+ type="submit"
+ colorSchema="secondary"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting || breachStatus === "checking" || breachStatus === "breached"}
+ >
Save
</Button>
<p className="mt-2 font-inter text-sm text-mineshaft-400">
diff --git a/frontend/src/routeTree.gen.ts b/frontend/src/routeTree.gen.ts
index 83f26a58d9..f4a4bbc88b 100644
--- a/frontend/src/routeTree.gen.ts
+++ b/frontend/src/routeTree.gen.ts
@@ -31,6 +31,8 @@ import { Route as publicViewSharedSecretByIDPageRouteImport } from './pages/publ
import { Route as publicViewSecretRequestByIDPageRouteImport } from './pages/public/ViewSecretRequestByIDPage/route'
import { Route as authSignUpSsoPageRouteImport } from './pages/auth/SignUpSsoPage/route'
import { Route as authSelectOrgPageRouteImport } from './pages/auth/SelectOrgPage/route'
+import { Route as authLoginSamlPageRouteImport } from './pages/auth/LoginSamlPage/route'
+import { Route as authLoginOidcPageRouteImport } from './pages/auth/LoginOidcPage/route'
import { Route as authLoginLdapPageRouteImport } from './pages/auth/LoginLdapPage/route'
import { Route as authAdminLoginPageRouteImport } from './pages/auth/AdminLoginPage/route'
import { Route as adminSignUpPageRouteImport } from './pages/admin/SignUpPage/route'
@@ -562,6 +564,18 @@ const authSelectOrgPageRouteRoute = authSelectOrgPageRouteImport.update({
getParentRoute: () => RestrictLoginSignupLoginRoute,
} as any)
+const authLoginSamlPageRouteRoute = authLoginSamlPageRouteImport.update({
+ id: '/saml',
+ path: '/saml',
+ getParentRoute: () => RestrictLoginSignupLoginRoute,
+} as any)
+
+const authLoginOidcPageRouteRoute = authLoginOidcPageRouteImport.update({
+ id: '/oidc',
+ path: '/oidc',
+ getParentRoute: () => RestrictLoginSignupLoginRoute,
+} as any)
+
const authLoginLdapPageRouteRoute = authLoginLdapPageRouteImport.update({
id: '/ldap',
path: '/ldap',
@@ -2892,6 +2906,20 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof authLoginLdapPageRouteImport
parentRoute: typeof RestrictLoginSignupLoginImport
}
+ '/_restrict-login-signup/login/oidc': {
+ id: '/_restrict-login-signup/login/oidc'
+ path: '/oidc'
+ fullPath: '/login/oidc'
+ preLoaderRoute: typeof authLoginOidcPageRouteImport
+ parentRoute: typeof RestrictLoginSignupLoginImport
+ }
+ '/_restrict-login-signup/login/saml': {
+ id: '/_restrict-login-signup/login/saml'
+ path: '/saml'
+ fullPath: '/login/saml'
+ preLoaderRoute: typeof authLoginSamlPageRouteImport
+ parentRoute: typeof RestrictLoginSignupLoginImport
+ }
'/_restrict-login-signup/login/select-organization': {
id: '/_restrict-login-signup/login/select-organization'
path: '/select-organization'
@@ -6162,6 +6190,8 @@ interface RestrictLoginSignupLoginRouteChildren {
authLoginPageRouteRoute: typeof authLoginPageRouteRoute
authAdminLoginPageRouteRoute: typeof authAdminLoginPageRouteRoute
authLoginLdapPageRouteRoute: typeof authLoginLdapPageRouteRoute
+ authLoginOidcPageRouteRoute: typeof authLoginOidcPageRouteRoute
+ authLoginSamlPageRouteRoute: typeof authLoginSamlPageRouteRoute
authSelectOrgPageRouteRoute: typeof authSelectOrgPageRouteRoute
authProviderErrorPageRouteRoute: typeof authProviderErrorPageRouteRoute
}
@@ -6171,6 +6201,8 @@ const RestrictLoginSignupLoginRouteChildren: RestrictLoginSignupLoginRouteChildr
authLoginPageRouteRoute: authLoginPageRouteRoute,
authAdminLoginPageRouteRoute: authAdminLoginPageRouteRoute,
authLoginLdapPageRouteRoute: authLoginLdapPageRouteRoute,
+ authLoginOidcPageRouteRoute: authLoginOidcPageRouteRoute,
+ authLoginSamlPageRouteRoute: authLoginSamlPageRouteRoute,
authSelectOrgPageRouteRoute: authSelectOrgPageRouteRoute,
authProviderErrorPageRouteRoute: authProviderErrorPageRouteRoute,
}
@@ -6249,6 +6281,8 @@ export interface FileRoutesByFullPath {
'/admin/signup': typeof adminSignUpPageRouteRoute
'/login/admin': typeof authAdminLoginPageRouteRoute
'/login/ldap': typeof authLoginLdapPageRouteRoute
+ '/login/oidc': typeof authLoginOidcPageRouteRoute
+ '/login/saml': typeof authLoginSamlPageRouteRoute
'/login/select-organization': typeof authSelectOrgPageRouteRoute
'/signup/sso': typeof authSignUpSsoPageRouteRoute
'/secret-request/secret/$secretRequestId': typeof publicViewSecretRequestByIDPageRouteRoute
@@ -6543,6 +6577,8 @@ export interface FileRoutesByTo {
'/admin/signup': typeof adminSignUpPageRouteRoute
'/login/admin': typeof authAdminLoginPageRouteRoute
'/login/ldap': typeof authLoginLdapPageRouteRoute
+ '/login/oidc': typeof authLoginOidcPageRouteRoute
+ '/login/saml': typeof authLoginSamlPageRouteRoute
'/login/select-organization': typeof authSelectOrgPageRouteRoute
'/signup/sso': typeof authSignUpSsoPageRouteRoute
'/secret-request/secret/$secretRequestId': typeof publicViewSecretRequestByIDPageRouteRoute
@@ -6819,6 +6855,8 @@ export interface FileRoutesById {
'/_restrict-login-signup/admin/signup': typeof adminSignUpPageRouteRoute
'/_restrict-login-signup/login/admin': typeof authAdminLoginPageRouteRoute
'/_restrict-login-signup/login/ldap': typeof authLoginLdapPageRouteRoute
+ '/_restrict-login-signup/login/oidc': typeof authLoginOidcPageRouteRoute
+ '/_restrict-login-signup/login/saml': typeof authLoginSamlPageRouteRoute
'/_restrict-login-signup/login/select-organization': typeof authSelectOrgPageRouteRoute
'/_restrict-login-signup/signup/sso': typeof authSignUpSsoPageRouteRoute
'/secret-request/secret/$secretRequestId': typeof publicViewSecretRequestByIDPageRouteRoute
@@ -7127,6 +7165,8 @@ export interface FileRouteTypes {
| '/admin/signup'
| '/login/admin'
| '/login/ldap'
+ | '/login/oidc'
+ | '/login/saml'
| '/login/select-organization'
| '/signup/sso'
| '/secret-request/secret/$secretRequestId'
@@ -7420,6 +7460,8 @@ export interface FileRouteTypes {
| '/admin/signup'
| '/login/admin'
| '/login/ldap'
+ | '/login/oidc'
+ | '/login/saml'
| '/login/select-organization'
| '/signup/sso'
| '/secret-request/secret/$secretRequestId'
@@ -7694,6 +7736,8 @@ export interface FileRouteTypes {
| '/_restrict-login-signup/admin/signup'
| '/_restrict-login-signup/login/admin'
| '/_restrict-login-signup/login/ldap'
+ | '/_restrict-login-signup/login/oidc'
+ | '/_restrict-login-signup/login/saml'
| '/_restrict-login-signup/login/select-organization'
| '/_restrict-login-signup/signup/sso'
| '/secret-request/secret/$secretRequestId'
@@ -8105,6 +8149,8 @@ export const routeTree = rootRoute
"/_restrict-login-signup/login/",
"/_restrict-login-signup/login/admin",
"/_restrict-login-signup/login/ldap",
+ "/_restrict-login-signup/login/oidc",
+ "/_restrict-login-signup/login/saml",
"/_restrict-login-signup/login/select-organization",
"/_restrict-login-signup/login/provider/error"
]
@@ -8153,6 +8199,14 @@ export const routeTree = rootRoute
"filePath": "auth/LoginLdapPage/route.tsx",
"parent": "/_restrict-login-signup/login"
},
+ "/_restrict-login-signup/login/oidc": {
+ "filePath": "auth/LoginOidcPage/route.tsx",
+ "parent": "/_restrict-login-signup/login"
+ },
+ "/_restrict-login-signup/login/saml": {
+ "filePath": "auth/LoginSamlPage/route.tsx",
+ "parent": "/_restrict-login-signup/login"
+ },
"/_restrict-login-signup/login/select-organization": {
"filePath": "auth/SelectOrgPage/route.tsx",
"parent": "/_restrict-login-signup/login"
diff --git a/frontend/src/routes.ts b/frontend/src/routes.ts
index e6282b7b9b..925cc09090 100644
--- a/frontend/src/routes.ts
+++ b/frontend/src/routes.ts
@@ -481,6 +481,8 @@ export const routes = rootRoute("root.tsx", [
route("/admin", "auth/AdminLoginPage/route.tsx"),
route("/select-organization", "auth/SelectOrgPage/route.tsx"),
route("/ldap", "auth/LoginLdapPage/route.tsx"),
+ route("/oidc", "auth/LoginOidcPage/route.tsx"),
+ route("/saml", "auth/LoginSamlPage/route.tsx"),
route("/provider/error", "auth/ProviderErrorPage/route.tsx")
]),
route("/signup", [