auth

Main authentication module for my projects
git clone git://git.finwo.net/app/auth
Log | Files | Refs

commit daa1eeac4b7e9da685c6418f5279d3c19c2022bd
parent 38b162ab6f8aedd50768ec7a6844e9d0dc11b813
Author: finwo <finwo@pm.me>
Date:   Sat, 21 Nov 2026 01:08:08 +0100

admin: identity provider screens with domain mapping panel (P3)

Diffstat:
Mapp/admin/src/main.ts | 12++++++++++++
Mapp/admin/src/screen/admin.tsx | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Aapp/admin/src/screen/provider-edit.tsx | 794+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aapp/admin/src/screen/providers.tsx | 499+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapp/admin/src/screen/settings.tsx | 12+++++++++++-
Mapp/admin/src/util/api.ts | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapp/admin/src/util/auth.ts | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/css-check/fixtures/provider-domains.html | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/css-check/fixtures/providers.html | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 1697 insertions(+), 5 deletions(-)

diff --git a/app/admin/src/main.ts b/app/admin/src/main.ts @@ -61,6 +61,18 @@ const routes: m.RouteDefs = { '/email-domains/:realm': { render: () => m(Admin, {}), }, + '/providers': { + render: () => m(Admin, {}), + }, + '/providers/:realm': { + render: () => m(Admin, {}), + }, + '/providers/:realm/new': { + render: () => m(Admin, {}), + }, + '/providers/:realm/edit/:provider': { + render: () => m(Admin, {}), + }, '/system-settings': { render: () => m(Admin, {}), }, diff --git a/app/admin/src/screen/admin.tsx b/app/admin/src/screen/admin.tsx @@ -27,6 +27,8 @@ import { ClientsPage } from './clients'; import { GlobalUserPage } from './global-user'; import { HostsPage } from './hosts'; import { EmailDomainsPage } from './email-domains'; +import { ProvidersPage } from './providers'; +import { ProviderEditPage } from './provider-edit'; import { UserPage } from './user'; import { UsersPage } from './users'; import { SettingsPage } from './settings'; @@ -151,6 +153,41 @@ function emailDomainsRealm() { } } +function providersRealm() { + const path = currentPath(); + if (path !== '/providers' && !path.startsWith('/providers/')) return null; + const suffix = path.slice('/providers/'.length); + if (!suffix) return null; + const slug = suffix.split('/')[0]; + try { + return decodeURIComponent(slug); + } catch { + return null; + } +} + +function providerEditPath() { + const path = currentPath(); + const create = /^\/providers\/([^/]+)\/new$/.exec(path); + if (create) { + try { + return { realmSlug: decodeURIComponent(create[1]), providerSlug: null }; + } catch { + return null; + } + } + const match = /^\/providers\/([^/]+)\/edit\/(.+)$/.exec(path); + if (!match) return null; + try { + return { + realmSlug: decodeURIComponent(match[1]), + providerSlug: decodeURIComponent(match[2]), + }; + } catch { + return null; + } +} + export const Admin: m.Component = { user: null as UserInfo | null, systemAdmin: false, @@ -348,6 +385,7 @@ export const Admin: m.Component = { const realmSettings = path === '/settings' || path.startsWith('/settings/'); const hosts = path === '/hosts' || path.startsWith('/hosts/'); const emailDomains = path === '/email-domains' || path.startsWith('/email-domains/'); + const providers = path === '/providers' || path.startsWith('/providers/'); const title = realmsPath ? 'Realms | Administration' : clients @@ -366,9 +404,15 @@ export const Admin: m.Component = { ? 'Hosts | Administration' : emailDomains ? 'Email domains | Administration' - : realmSettings - ? 'Realm settings | Administration' - : 'Administration'; + : providers + ? path.endsWith('/new') + ? 'Add provider | Administration' + : path.includes('/edit/') + ? 'Edit provider | Administration' + : 'Identity providers | Administration' + : realmSettings + ? 'Realm settings | Administration' + : 'Administration'; document.title = title; }, @@ -396,12 +440,15 @@ export const Admin: m.Component = { const realmSettings = path === '/settings' || path.startsWith('/settings/'); const hosts = path === '/hosts' || path.startsWith('/hosts/'); const emailDomains = path === '/email-domains' || path.startsWith('/email-domains/'); + const providers = path === '/providers' || path.startsWith('/providers/'); const realmSlug = sessionsRealm(); const clientRealmSlug = clientsRealm(); const userRealmSlug = usersRealm(); const settingsRealmSlug = settingsRealm(); const hostsRealmSlug = hostsRealm(); const emailDomainsRealmSlug = emailDomainsRealm(); + const providersRealmSlug = providersRealm(); + const providerEdit = providerEditPath(); const clientEdit = clientEditPath(); const userDetail = userDetailPath(); const globalUser = globalUserDetailPath(); @@ -434,7 +481,7 @@ export const Admin: m.Component = { href: appUrl(realmNav.href), label: realmNav.label, icon: LibraryBig, - active: realmsPath || realmSettings || hosts || emailDomains, + active: realmsPath || realmSettings || hosts || emailDomains || providers, onclick: (event: Event) => { event.preventDefault(); m.route.set(realmNav.href); @@ -617,6 +664,23 @@ export const Admin: m.Component = { canCreateRealm={Boolean(this.canCreateRealm)} onAuthExpired={() => this.authExpired()} /> + ) : providers && providerEdit ? ( + <ProviderEditPage + realmSlug={providerEdit.realmSlug} + providerSlug={providerEdit.providerSlug} + realms={this.realms} + realmsError={this.realmsError} + canCreateRealm={Boolean(this.canCreateRealm)} + onAuthExpired={() => this.authExpired()} + /> + ) : providers ? ( + <ProvidersPage + realmSlug={providersRealmSlug} + realms={this.realms} + realmsError={this.realmsError} + canCreateRealm={Boolean(this.canCreateRealm)} + onAuthExpired={() => this.authExpired()} + /> ) : realmSettings ? ( <SettingsPage realmSlug={settingsRealmSlug} diff --git a/app/admin/src/screen/provider-edit.tsx b/app/admin/src/screen/provider-edit.tsx @@ -0,0 +1,794 @@ +import m from 'mithril'; +import { PageHeader } from '@component/page-header'; +import { SelectMenu } from '@component/select-menu'; +import { Breadcrumb } from '../component/breadcrumb'; +import { realmNavigation } from '../util/navigation'; +import { formatDate } from '../util/format'; +import { + connectAdminProviderDomain, + createAdminRealmProvider, + disconnectAdminProviderDomain, + loadAdminRealmEmailDomains, + loadAdminRealmProvider, + loadAdminRealmProviders, + updateAdminRealmProvider, +} from '../util/auth'; +import { + appUrl, + type AdminIdentityProvider, + type AdminIdentityProviderPatchInput, + type AdminRealm, + type AdminRealmEmailDomain, +} from '../util/api'; + +interface ProviderEditAttrs { + realmSlug: string | null; + providerSlug: string | null; + realms: AdminRealm[] | null; + realmsError: Error | null; + canCreateRealm: boolean; + onAuthExpired: () => void; +} + +const SECRET_HELP_KEEP = 'The current secret is never displayed. Enter a new value to replace it.'; +const SECRET_HELP_UNSET = 'This provider has no secret. Entering one switches it to confidential authentication.'; +const SECRET_HELP_REMOVED = 'This provider will stop using a client secret after saving.'; +const SECRET_PLACEHOLDER_SET = 'Configured. Leave blank to keep the current secret.'; +const SECRET_PLACEHOLDER_UNSET = 'No secret configured. Enter one to make this a confidential client.'; +const SECRET_PLACEHOLDER_REMOVED = 'The stored secret will be removed on save.'; +const SECRET_PLACEHOLDER_CREATE = 'Optional. Leave blank for public or native apps.'; +const SECRET_HELP_CREATE = 'Leave blank for public or native apps that do not use a secret.'; + +function providerKey(realmSlug: string | null, providerSlug: string | null) { + return `${realmSlug || ''}:${providerSlug || 'new'}`; +} + +function slugify(value: string) { + return value + .toLowerCase() + .replace(/[^a-z0-9-]+/g, '-') + .replace(/^-+|-+$/g, '') + .slice(0, 63); +} + +function providerRequestError(e: any): boolean { + return e?.status === 401 || (e?.status === 400 && e?.code !== 'invalid_request'); +} + +export const ProviderEditPage: m.Component<ProviderEditAttrs> = { + attrs: null as ProviderEditAttrs | null, + loadedKey: null as string | null, + loading: false, + redirecting: false, + provider: null as AdminIdentityProvider | null, + providers: [] as AdminIdentityProvider[], + emailDomains: [] as AdminRealmEmailDomain[], + error: null as Error | null, + formError: null as Error | string | null, + notice: null as string | null, + pendingNotice: null as string | null, + saving: false, + connecting: false, + disconnecting: null as string | null, + selectedDomain: '', + + slug: '', + displayName: '', + issuer: '', + clientId: '', + secret: '', + scopes: 'openid email profile', + enabled: true, + secretCleared: false, + slugTouched: false, + + oninit(this: any, vnode: m.Vnode<ProviderEditAttrs>) { + this.attrs = vnode.attrs; + this.ensure(); + }, + + onupdate(this: any, vnode: m.Vnode<ProviderEditAttrs>) { + this.attrs = vnode.attrs; + this.ensure(); + }, + + ensure(this: any) { + const { realms, realmSlug, providerSlug } = this.attrs; + if (!realms) return; + + if (realms.length === 0) { + this.loading = false; + this.error = null; + return; + } + + const selected = realmSlug && realms.some((realm) => realm.slug === realmSlug); + if (!selected) { + if (!this.redirecting) { + this.redirecting = true; + m.route.set(`/providers/${encodeURIComponent(realms[0].slug)}`, null, { + replace: true, + }); + } + return; + } + + this.redirecting = false; + const key = providerKey(realmSlug, providerSlug); + if (key === this.loadedKey) return; + + const saved = m.route.param('saved'); + if (typeof saved === 'string' && saved) { + this.pendingNotice = `Provider ${saved} saved.`; + m.route.set( + providerSlug + ? `/providers/${encodeURIComponent(realmSlug!)}/edit/${encodeURIComponent(providerSlug)}` + : `/providers/${encodeURIComponent(realmSlug!)}`, + null, + { replace: true } + ); + } + + this.loadedKey = key; + this.provider = null; + this.error = null; + this.formError = null; + this.notice = null; + this.saving = false; + this.connecting = false; + this.disconnecting = null; + this.selectedDomain = ''; + this.secret = ''; + this.secretCleared = false; + this.slugTouched = false; + + if (providerSlug) { + this.loadEdit(realmSlug!, providerSlug); + } else { + this.slug = ''; + this.displayName = ''; + this.issuer = ''; + this.clientId = ''; + this.scopes = 'openid email profile'; + this.enabled = true; + this.loadCreate(realmSlug!); + } + }, + + applyPendingNotice(this: any) { + if (this.pendingNotice) { + this.notice = this.pendingNotice; + this.pendingNotice = null; + } + }, + + async loadEdit(this: any, realmSlug: string, providerSlug: string) { + this.loading = true; + m.redraw(); + + try { + const [provider, providers, emailDomains] = await Promise.all([ + loadAdminRealmProvider(realmSlug, providerSlug), + loadAdminRealmProviders(realmSlug), + loadAdminRealmEmailDomains(realmSlug), + ]); + if (this.loadedKey !== providerKey(realmSlug, providerSlug)) return; + + this.provider = provider; + this.providers = providers; + this.emailDomains = emailDomains; + this.slug = provider.slug; + this.displayName = provider.display_name; + this.issuer = provider.issuer; + this.clientId = provider.client_id; + this.scopes = provider.scopes || ''; + this.enabled = provider.enabled; + } catch (e: any) { + if (this.loadedKey !== providerKey(realmSlug, providerSlug)) return; + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + this.error = e as Error; + } finally { + if (this.loadedKey === providerKey(realmSlug, providerSlug)) { + this.loading = false; + this.applyPendingNotice(); + } + m.redraw(); + } + }, + + async loadCreate(this: any, realmSlug: string) { + this.loading = true; + m.redraw(); + + try { + const providers = await loadAdminRealmProviders(realmSlug); + if (this.loadedKey !== providerKey(realmSlug, null)) return; + this.providers = providers; + } catch (e: any) { + if (this.loadedKey !== providerKey(realmSlug, null)) return; + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + this.error = e as Error; + } finally { + if (this.loadedKey === providerKey(realmSlug, null)) { + this.loading = false; + this.applyPendingNotice(); + } + m.redraw(); + } + }, + + async refreshProviders(this: any) { + const { realmSlug, providerSlug } = this.attrs; + if (!realmSlug) return; + try { + const providers = await loadAdminRealmProviders(realmSlug); + if (this.loadedKey !== providerKey(realmSlug, providerSlug)) return; + this.providers = providers; + const current = providers.find((entry) => entry.slug === providerSlug); + if (current) this.provider = current; + } catch { + /* domain lists stay stale until the next load */ + } + }, + + connectedDomainNames(this: any) { + return (this.provider?.domains || []).map((entry) => entry.domain); + }, + + mappedByOther(this: any, domain: string) { + const currentSlug = this.provider?.slug || ''; + return this.providers.some( + (entry: AdminIdentityProvider) => + entry.slug !== currentSlug && entry.domains.some((mapped) => mapped.domain === domain) + ); + }, + + availableDomains(this: any) { + if (!this.provider) return []; + return this.emailDomains + .filter((entry) => entry.status === 'verified' && !this.mappedByOther(entry.domain)) + .map((entry) => entry.domain); + }, + + async submitConnect(this: any) { + const { realmSlug, providerSlug } = this.attrs; + const domain = this.selectedDomain; + if (!realmSlug || !providerSlug || !domain || this.connecting) return; + + this.connecting = true; + this.formError = null; + this.notice = null; + m.redraw(); + + try { + const result = await connectAdminProviderDomain(realmSlug, providerSlug, domain); + this.selectedDomain = ''; + await this.refreshProviders(); + this.notice = `Email domain ${result.domain} connected to ${this.displayName}.`; + } catch (e: any) { + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + this.formError = e as Error; + } finally { + this.connecting = false; + m.redraw(); + } + }, + + async submitDisconnect(this: any, domain: string) { + const { realmSlug, providerSlug } = this.attrs; + if (!realmSlug || !providerSlug || this.disconnecting) return; + + this.disconnecting = domain; + this.formError = null; + this.notice = null; + m.redraw(); + + try { + const result = await disconnectAdminProviderDomain(realmSlug, providerSlug, domain); + await this.refreshProviders(); + this.notice = `Email domain ${result.domain} disconnected from ${this.displayName}.`; + } catch (e: any) { + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + this.formError = e as Error; + } finally { + this.disconnecting = null; + m.redraw(); + } + }, + + validate(this: any, isEdit: boolean): string | null { + const name = this.displayName.trim(); + const slug = this.slug.trim().toLowerCase(); + const issuer = this.issuer.trim(); + const clientId = this.clientId.trim(); + + if (!name) return 'Display name is required.'; + if (!isEdit) { + if (!slug || !/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(slug)) { + return 'Slug must use lowercase letters, numbers and hyphens.'; + } + if (this.providers.some((entry: AdminIdentityProvider) => entry.slug === slug)) { + return 'A provider with this slug already exists in the realm.'; + } + } + if (!issuer.startsWith('https://')) return 'Issuer must start with https://.'; + if (issuer.endsWith('/')) return 'Issuer must not end with a slash.'; + if (!issuer.slice(8).includes('.')) return 'Issuer must include a complete hostname.'; + if (!clientId || /\s/.test(clientId)) { + return 'Client id is required and must not contain spaces.'; + } + return null; + }, + + async submit(this: any) { + const { realmSlug, providerSlug } = this.attrs; + if (!realmSlug) return; + const isEdit = Boolean(providerSlug); + + const validationError = this.validate(isEdit); + if (validationError) { + this.formError = validationError; + this.notice = null; + m.redraw(); + return; + } + + this.saving = true; + this.formError = null; + this.notice = null; + m.redraw(); + + try { + if (!isEdit) { + const scopes = this.scopes.trim(); + const response = await createAdminRealmProvider(realmSlug, { + slug: this.slug.trim().toLowerCase(), + display_name: this.displayName.trim(), + issuer: this.issuer.trim(), + client_id: this.clientId.trim(), + ...(this.secret ? { client_secret: this.secret } : {}), + ...(scopes ? { scopes } : {}), + enabled: this.enabled, + }); + m.route.set( + `/providers/${encodeURIComponent(realmSlug)}/edit/${encodeURIComponent(response.provider.slug)}`, + { saved: response.provider.slug } + ); + return; + } + + const baseline = this.provider as AdminIdentityProvider; + const patch: AdminIdentityProviderPatchInput = {}; + const displayName = this.displayName.trim(); + const issuer = this.issuer.trim(); + const clientId = this.clientId.trim(); + const scopes = this.scopes.trim(); + + if (displayName !== baseline.display_name) patch.display_name = displayName; + if (issuer !== baseline.issuer) patch.issuer = issuer; + if (clientId !== baseline.client_id) patch.client_id = clientId; + if (scopes && scopes !== baseline.scopes) patch.scopes = scopes; + if (this.enabled !== baseline.enabled) patch.enabled = this.enabled; + if (this.secret) patch.client_secret = this.secret; + else if (this.secretCleared) patch.client_secret = null; + + if (Object.keys(patch).length === 0) { + m.route.set(`/providers/${encodeURIComponent(realmSlug)}`); + return; + } + + await updateAdminRealmProvider(realmSlug, providerSlug!, patch); + m.route.set(`/providers/${encodeURIComponent(realmSlug)}`, { saved: providerSlug }); + } catch (e: any) { + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + this.formError = e as Error; + } finally { + this.saving = false; + m.redraw(); + } + }, + + view(this: any) { + const { realms, realmsError, realmSlug, providerSlug, canCreateRealm } = this.attrs; + const isEdit = Boolean(providerSlug); + const selected = realms?.find((realm) => realm.slug === realmSlug) || realms?.[0] || null; + const nav = realmNavigation(realms, Boolean(canCreateRealm)); + const breadcrumbRealm = selected?.display_name || selected?.slug || realmSlug || ''; + const realmEncoded = encodeURIComponent(realmSlug || ''); + const listHref = `/providers/${realmEncoded}`; + const settingsHref = `/settings/${realmEncoded}`; + const busy = this.loading || this.redirecting || (isEdit && !this.provider); + + const breadcrumbItems = [ + { + label: nav.label, + ...(nav.isPlural ? { path: '/realms' } : {}), + }, + { label: breadcrumbRealm, path: settingsHref }, + { label: 'Identity providers', path: listHref }, + { label: isEdit ? this.displayName || 'Edit provider' : 'Add provider' }, + ]; + + const available = this.availableDomains(); + const domainOptions = available.map((domain: string) => ({ value: domain, label: domain })); + const hasSecret = isEdit ? Boolean(this.provider?.has_secret) : false; + const secretPlaceholder = !isEdit + ? SECRET_PLACEHOLDER_CREATE + : this.secretCleared + ? SECRET_PLACEHOLDER_REMOVED + : hasSecret + ? SECRET_PLACEHOLDER_SET + : SECRET_PLACEHOLDER_UNSET; + const secretHelp = !isEdit + ? SECRET_HELP_CREATE + : this.secretCleared + ? SECRET_HELP_REMOVED + : hasSecret || this.secret + ? SECRET_HELP_KEEP + : SECRET_HELP_UNSET; + const connected = this.connectedDomainNames(); + const showFallbackNote = isEdit && !this.enabled && connected.length > 0; + + return ( + <div> + <Breadcrumb items={breadcrumbItems} /> + <PageHeader + title={isEdit ? `Edit ${this.displayName || providerSlug}` : 'Add provider'} + subtitle={ + isEdit + ? 'Update provider configuration and the email domains routed to it.' + : 'Register an external sign-in provider for this realm.' + } + /> + + {realmsError ? ( + <div class="alert" role="alert"> + {realmsError.message} + </div> + ) : null} + + {this.error ? ( + <div class="alert" role="alert"> + <p>{this.error.message}</p> + <div class="action-row"> + <button + class="button button-secondary" + type="button" + onclick={() => { + this.loadedKey = null; + this.ensure(); + }} + > + Try again + </button> + <a + class="button button-secondary" + href={appUrl(listHref)} + onclick={(event: MouseEvent) => { + event.preventDefault(); + m.route.set(listHref); + }} + > + Back to providers + </a> + </div> + </div> + ) : null} + + {this.notice ? ( + <div class="notice" role="status"> + {this.notice} + </div> + ) : null} + + {busy ? ( + <div class="panel" aria-busy="true"> + <div class="skeleton skeleton-title"></div> + <div class="skeleton"></div> + <div class="skeleton skeleton-short"></div> + </div> + ) : ( + <div class="stack"> + <form + class="stack" + novalidate + onsubmit={(event: Event) => { + event.preventDefault(); + this.submit(); + }} + > + <section class="panel" aria-label="Provider"> + <h2>Provider</h2> + {this.formError ? ( + <div class="alert" role="alert"> + {typeof this.formError === 'string' ? this.formError : this.formError.message} + </div> + ) : null} + + <label class="field"> + <span class="field-label">Slug</span> + <input + class="field-control u-mono" + type="text" + value={this.slug} + maxlength="63" + placeholder="example-sso" + autocomplete="off" + spellcheck="false" + readonly={isEdit} + disabled={this.saving} + oninput={(event: Event) => { + this.slug = (event.target as HTMLInputElement).value; + this.slugTouched = true; + this.formError = null; + }} + /> + <span class="field-hint"> + {isEdit + ? 'The slug cannot be changed after the provider is created.' + : 'Lowercase letters, numbers and hyphens. Used in provider URLs and audit logs.'} + </span> + </label> + + <label class="field"> + <span class="field-label">Display name</span> + <input + class="field-control" + type="text" + value={this.displayName} + maxlength="120" + placeholder="Example SSO" + autocomplete="off" + disabled={this.saving} + oninput={(event: Event) => { + this.displayName = (event.target as HTMLInputElement).value; + this.formError = null; + if (!isEdit && !this.slugTouched) { + this.slug = slugify(this.displayName); + } + }} + /> + <span class="field-hint"> + Shown to users when this provider is offered at sign-in. + </span> + </label> + + <label class="field"> + <span class="field-label">Issuer</span> + <input + class="field-control u-mono" + type="text" + value={this.issuer} + maxlength="253" + placeholder="https://idp.example.com" + autocomplete="off" + spellcheck="false" + disabled={this.saving} + oninput={(event: Event) => { + this.issuer = (event.target as HTMLInputElement).value; + this.formError = null; + }} + /> + <span class="field-hint"> + The OIDC issuer URL. Must be https and must not end with a slash. + </span> + </label> + + <label class="field"> + <span class="field-label">Client id</span> + <input + class="field-control u-mono" + type="text" + value={this.clientId} + maxlength="255" + placeholder="auth-example" + autocomplete="off" + spellcheck="false" + disabled={this.saving} + oninput={(event: Event) => { + this.clientId = (event.target as HTMLInputElement).value; + this.formError = null; + }} + /> + </label> + + <label class="field"> + <span class="field-label">Client secret</span> + <input + class="field-control u-mono" + type="password" + value={this.secret} + maxlength="255" + placeholder={secretPlaceholder} + autocomplete="new-password" + spellcheck="false" + disabled={this.saving} + oninput={(event: Event) => { + this.secret = (event.target as HTMLInputElement).value; + if (isEdit && this.secret && this.secretCleared) { + this.secretCleared = false; + } + }} + /> + <span class="field-hint">{secretHelp}</span> + {isEdit && hasSecret && !this.secretCleared ? ( + <span class="u-cluster"> + <button + class="button button-secondary" + type="button" + disabled={this.saving} + onclick={() => { + this.secretCleared = true; + this.secret = ''; + }} + > + Remove secret + </button> + </span> + ) : null} + </label> + + <label class="field"> + <span class="field-label">Scopes</span> + <input + class="field-control u-mono" + type="text" + value={this.scopes} + maxlength="255" + autocomplete="off" + spellcheck="false" + disabled={this.saving} + oninput={(event: Event) => { + this.scopes = (event.target as HTMLInputElement).value; + this.formError = null; + }} + /> + <span class="field-hint"> + Space-separated OIDC scopes requested from the provider. + </span> + </label> + + <div class="action-row"> + <a + class="button button-secondary" + href={appUrl(listHref)} + onclick={(event: MouseEvent) => { + event.preventDefault(); + m.route.set(listHref); + }} + > + Cancel + </a> + <button class="button button-primary" type="submit" disabled={this.saving}> + {isEdit + ? this.saving + ? 'Saving' + : 'Save changes' + : this.saving + ? 'Creating' + : 'Create provider'} + </button> + </div> + </section> + + <section class="panel" aria-label="Status"> + <h2>Status</h2> + <label class="checkbox"> + <input + type="checkbox" + checked={this.enabled} + disabled={this.saving} + onchange={(event: Event) => { + this.enabled = (event.target as HTMLInputElement).checked; + }} + /> + <span>Enabled</span> + </label> + <p class="note"> + Disabled providers stay configured but new sign-ins use password instead. + </p> + {showFallbackNote ? ( + <p class="note"> + While this provider is disabled, sign-in for {connected.join(', ')} falls back + to password. + </p> + ) : null} + </section> + </form> + + {isEdit ? ( + <section class="panel" aria-label="Connected domains"> + <h2>Connected domains</h2> + <p class="note">Verified email domains that route sign-in through this provider.</p> + + <div class="toolbar toolbar-panel"> + <div class="field"> + <span class="field-label" id="provider-domain-select-label"> + Email domain + </span> + <SelectMenu + labelledBy="provider-domain-select-label" + value={this.selectedDomain} + options={domainOptions} + placeholder="Select a domain" + disabled={this.connecting || domainOptions.length === 0} + onchange={(value: string) => { + this.selectedDomain = value; + this.formError = null; + }} + /> + </div> + <div class="toolbar-actions"> + <button + class="button button-primary" + type="button" + disabled={this.connecting || available.length === 0} + onclick={() => this.submitConnect()} + > + {this.connecting ? 'Connecting' : 'Connect'} + </button> + </div> + </div> + + <table class="table"> + <thead> + <tr> + <th scope="col">Domain</th> + <th scope="col">Added</th> + <th scope="col">Actions</th> + </tr> + </thead> + <tbody> + {(this.provider?.domains || []).map((entry) => ( + <tr> + <td data-label="Domain"> + <span class="table-mono">{entry.domain}</span> + </td> + <td data-label="Added" class="table-meta u-nowrap"> + {formatDate(entry.created_at)} + </td> + <td data-label="Actions"> + <button + class="button-inline button-danger" + type="button" + disabled={Boolean(this.disconnecting)} + onclick={() => this.submitDisconnect(entry.domain)} + > + Disconnect + </button> + </td> + </tr> + ))} + </tbody> + </table> + {(this.provider?.domains || []).length === 0 ? ( + <p class="empty">No email domains are connected to this provider.</p> + ) : null} + </section> + ) : ( + <section class="panel" aria-label="Connected domains"> + <h2>Connected domains</h2> + <p class="note">Save the provider first to connect verified email domains to it.</p> + </section> + )} + </div> + )} + </div> + ); + }, +}; diff --git a/app/admin/src/screen/providers.tsx b/app/admin/src/screen/providers.tsx @@ -0,0 +1,499 @@ +import m from 'mithril'; +import { Modal } from '@component/modal'; +import { PageHeader } from '@component/page-header'; +import { Breadcrumb } from '../component/breadcrumb'; +import { RealmSelector } from '../component/realm-selector'; +import { realmNavigation } from '../util/navigation'; +import { + deleteAdminRealmProvider, + loadAdminRealmProviders, + updateAdminRealmProvider, +} from '../util/auth'; +import { appUrl, type AdminIdentityProvider, type AdminRealm } from '../util/api'; + +interface ProvidersAttrs { + realmSlug: string | null; + realms: AdminRealm[] | null; + realmsError: Error | null; + canCreateRealm: boolean; + onAuthExpired: () => void; +} + +function providerRequestError(e: any): boolean { + return e?.status === 401 || (e?.status === 400 && e?.code !== 'invalid_request'); +} + +function matchesSearch(provider: AdminIdentityProvider, term: string) { + if (!term) return true; + return `${provider.display_name} ${provider.slug} ${provider.issuer}`.toLowerCase().includes(term); +} + +export const ProvidersPage: m.Component<ProvidersAttrs> = { + attrs: null as ProvidersAttrs | null, + loadedRealm: null as string | null, + loading: false, + redirecting: false, + providers: null as AdminIdentityProvider[] | null, + error: null as Error | null, + notice: null as string | null, + search: '', + + toggleTarget: null as AdminIdentityProvider | null, + toggleError: null as Error | null, + toggling: false, + + deleteTarget: null as AdminIdentityProvider | null, + deleteConfirm: '', + deleteError: null as Error | null, + deleting: false, + + oninit(this: any, vnode: m.Vnode<ProvidersAttrs>) { + this.attrs = vnode.attrs; + this.ensure(); + }, + + onupdate(this: any, vnode: m.Vnode<ProvidersAttrs>) { + this.attrs = vnode.attrs; + this.ensure(); + }, + + ensure(this: any) { + const { realms, realmSlug } = this.attrs; + if (!realms) return; + + if (realms.length === 0) { + this.loadedRealm = null; + this.providers = null; + this.loading = false; + this.error = null; + if (!this.redirecting) { + this.redirecting = true; + m.route.set('/realms', null, { replace: true }); + } + return; + } + + const selected = realmSlug && realms.some((realm) => realm.slug === realmSlug); + if (!selected) { + if (!this.redirecting) { + this.redirecting = true; + m.route.set(`/providers/${encodeURIComponent(realms[0].slug)}`, null, { + replace: true, + }); + } + return; + } + + this.redirecting = false; + this.showSavedNotice(realmSlug!); + if (this.loadedRealm !== realmSlug) { + this.load(realmSlug!); + } + }, + + showSavedNotice(this: any, realmSlug: string) { + const saved = m.route.param('saved'); + if (typeof saved !== 'string' || !saved) return; + this.notice = `Provider ${saved} saved.`; + m.route.set(`/providers/${encodeURIComponent(realmSlug)}`, null, { replace: true }); + }, + + async load(this: any, realmSlug: string) { + this.loadedRealm = realmSlug; + this.loading = true; + this.error = null; + this.search = ''; + this.providers = null; + m.redraw(); + + try { + const providers = await loadAdminRealmProviders(realmSlug); + if (this.loadedRealm !== realmSlug) return; + this.providers = providers; + } catch (e: any) { + if (this.loadedRealm !== realmSlug) return; + if (e?.status === 401 || e?.status === 400) { + this.attrs.onAuthExpired(); + return; + } + this.error = e as Error; + } finally { + if (this.loadedRealm === realmSlug) this.loading = false; + m.redraw(); + } + }, + + resetToggle(this: any) { + this.toggleTarget = null; + this.toggleError = null; + this.toggling = false; + }, + + async applyToggle(this: any, provider: AdminIdentityProvider, enabled: boolean) { + const { realmSlug } = this.attrs; + if (!realmSlug) return; + + this.toggling = true; + if (this.toggleTarget) this.toggleError = null; + m.redraw(); + + try { + const response = await updateAdminRealmProvider(realmSlug, provider.slug, { enabled }); + if (this.loadedRealm === realmSlug) { + this.providers = (this.providers || []).map((entry) => + entry.slug === response.provider.slug ? response.provider : entry + ); + this.notice = `Provider ${response.provider.display_name} ${enabled ? 'enabled' : 'disabled'}.`; + } + this.resetToggle(); + } catch (e: any) { + this.toggling = false; + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + if (this.toggleTarget) { + this.toggleError = e as Error; + m.redraw(); + return; + } + this.error = e as Error; + m.redraw(); + } + }, + + openToggle(this: any, provider: AdminIdentityProvider) { + if (provider.enabled && provider.domains.length > 0) { + this.resetToggle(); + this.toggleTarget = provider; + m.redraw(); + return; + } + this.applyToggle(provider, !provider.enabled); + }, + + resetDelete(this: any) { + this.deleteTarget = null; + this.deleteConfirm = ''; + this.deleteError = null; + this.deleting = false; + }, + + openDelete(this: any, provider: AdminIdentityProvider) { + this.resetDelete(); + this.deleteTarget = provider; + m.redraw(); + }, + + async submitDelete(this: any) { + const { realmSlug } = this.attrs; + const target = this.deleteTarget; + if (!realmSlug || !target || this.deleting) return; + if (this.deleteConfirm.trim().toLowerCase() !== target.slug) return; + + this.deleting = true; + this.deleteError = null; + m.redraw(); + + try { + const result = await deleteAdminRealmProvider(realmSlug, target.slug); + if (this.loadedRealm === realmSlug) { + this.providers = (this.providers || []).filter((entry) => entry.slug !== result.slug); + this.notice = `Provider ${result.slug} deleted.`; + } + this.resetDelete(); + } catch (e: any) { + if (providerRequestError(e)) { + this.attrs.onAuthExpired(); + return; + } + this.deleteError = e as Error; + } finally { + this.deleting = false; + m.redraw(); + } + }, + + view(this: any) { + const { realms, realmsError, realmSlug, canCreateRealm } = this.attrs; + const selected = + realms?.find((realm) => realm.slug === realmSlug) || realms?.[0] || null; + const canManage = Boolean(selected?.can_edit); + const nav = realmNavigation(realms, Boolean(canCreateRealm)); + const breadcrumbRealm = selected?.display_name || selected?.slug || realmSlug || ''; + const settingsHref = `/settings/${encodeURIComponent(selected?.slug || realmSlug || '')}`; + + const breadcrumbItems = [ + { + label: nav.label, + ...(nav.isPlural ? { path: '/realms' } : {}), + }, + { label: breadcrumbRealm, path: settingsHref }, + { label: 'Identity providers' }, + ]; + + const providers = this.providers as AdminIdentityProvider[] | null; + const term = this.search.trim().toLowerCase(); + const visible = providers ? providers.filter((entry) => matchesSearch(entry, term)) : []; + + const toggleDomains = this.toggleTarget + ? this.toggleTarget.domains.map((entry) => entry.domain).join(', ') + : ''; + const deleteDomains = this.deleteTarget + ? this.deleteTarget.domains.map((entry) => entry.domain).join(', ') + : ''; + + return ( + <div> + <Breadcrumb items={breadcrumbItems} /> + <PageHeader + row + title="Identity providers" + subtitle="External sign-in providers that accounts in this realm can use." + > + <RealmSelector + realms={realms} + selected={selected} + onchange={(slug: string) => { + this.notice = null; + m.route.set(`/providers/${encodeURIComponent(slug)}`); + }} + /> + </PageHeader> + + {realmsError ? ( + <div class="alert" role="alert"> + {realmsError.message} + </div> + ) : null} + + {this.error ? ( + <div class="alert" role="alert"> + <p>{this.error.message}</p> + <button + class="button button-secondary" + type="button" + onclick={() => { + if (realmSlug) { + this.load(realmSlug); + } + }} + > + Try again + </button> + </div> + ) : null} + + {this.notice ? ( + <div class="notice" role="status"> + {this.notice} + </div> + ) : null} + + {!realms ? ( + <div class="loading">Loading realms</div> + ) : realms.length === 0 ? ( + <div class="empty"> + <p>No realms are available for this account.</p> + </div> + ) : this.loading || this.redirecting || !providers ? ( + <div class="panel" aria-busy="true"> + <div class="skeleton skeleton-title"></div> + <div class="skeleton"></div> + <div class="skeleton skeleton-short"></div> + </div> + ) : ( + <section class="card" aria-label="Realm identity providers"> + <div class="toolbar toolbar-panel"> + <div class="toolbar-search"> + <input + type="search" + value={this.search} + aria-label="Search providers" + placeholder="Search providers" + oninput={(event: Event) => { + this.search = (event.target as HTMLInputElement).value; + }} + /> + </div> + {canManage ? ( + <div class="toolbar-actions"> + <button + class="button button-primary" + type="button" + onclick={() => { + m.route.set(`/providers/${encodeURIComponent(realmSlug || '')}/new`); + }} + > + Add provider + </button> + </div> + ) : null} + </div> + + <table class="table"> + <thead> + <tr> + <th scope="col">Provider</th> + <th scope="col">Issuer</th> + <th scope="col">Status</th> + <th scope="col">Domains</th> + {canManage ? <th scope="col">Actions</th> : null} + </tr> + </thead> + <tbody> + {visible.map((entry: AdminIdentityProvider) => ( + <tr> + <td data-label="Provider">{entry.display_name}</td> + <td data-label="Issuer"> + <span class="table-mono">{entry.issuer}</span> + </td> + <td data-label="Status" class="u-nowrap"> + <span class="status"> + <span class="status-dot" aria-hidden="true"></span> + {entry.enabled ? 'Enabled' : 'Disabled'} + </span> + </td> + <td data-label="Domains">{entry.domains.length}</td> + {canManage ? ( + <td data-label="Actions" class="u-nowrap"> + <a + class="button-inline" + href={appUrl( + `/providers/${encodeURIComponent(realmSlug || '')}/edit/${encodeURIComponent(entry.slug)}` + )} + onclick={(event: MouseEvent) => { + event.preventDefault(); + m.route.set( + `/providers/${encodeURIComponent(realmSlug || '')}/edit/${encodeURIComponent(entry.slug)}` + ); + }} + > + Edit + </a> + <button + class="button-inline" + type="button" + disabled={this.toggling} + onclick={() => this.openToggle(entry)} + > + {entry.enabled ? 'Disable' : 'Enable'} + </button> + <button + class="button-inline button-danger" + type="button" + onclick={() => this.openDelete(entry)} + > + Delete + </button> + </td> + ) : null} + </tr> + ))} + </tbody> + </table> + {providers.length > 0 && visible.length === 0 ? ( + <div class="empty"> + <p>No providers match this search.</p> + </div> + ) : providers.length === 0 ? ( + <div class="empty"> + <p>No identity providers are configured for this realm.</p> + </div> + ) : null} + </section> + )} + + {this.toggleTarget ? ( + <Modal title="Disable provider" onClose={() => this.resetToggle()}> + {this.toggleError ? ( + <div class="alert" role="alert"> + {this.toggleError.message} + </div> + ) : null} + <p class="modal-note"> + While {this.toggleTarget.display_name} is disabled, sign-in for {toggleDomains} falls + back to password. Existing sessions are not affected. + </p> + <div class="modal-actions"> + <button + class="button button-secondary" + type="button" + disabled={this.toggling} + onclick={() => this.resetToggle()} + > + Cancel + </button> + <button + class="button button-primary" + type="button" + disabled={this.toggling} + onclick={() => this.applyToggle(this.toggleTarget, false)} + > + {this.toggling ? 'Disabling' : 'Disable provider'} + </button> + </div> + </Modal> + ) : null} + + {this.deleteTarget ? ( + <Modal title="Delete provider" onClose={() => this.resetDelete()}> + {this.deleteError ? ( + <div class="alert" role="alert"> + {this.deleteError.message} + </div> + ) : null} + <p class="modal-note"> + Delete {this.deleteTarget.display_name}? This cannot be undone. + {deleteDomains + ? ` Connected domains ${deleteDomains} will be unlinked and fall back to password sign-in.` + : ' No email domains are connected to this provider.'} + </p> + + <div class="form-field"> + <span class="field-label">Confirm slug</span> + <input + class="field-control" + type="text" + value={this.deleteConfirm} + maxlength="64" + placeholder={this.deleteTarget.slug} + autocomplete="off" + spellcheck="false" + data-modal-autofocus + disabled={this.deleting} + oninput={(event: Event) => { + this.deleteConfirm = (event.target as HTMLInputElement).value; + this.deleteError = null; + }} + /> + </div> + <p class="modal-note">Type the provider slug exactly to confirm.</p> + + <div class="modal-actions"> + <button + class="button button-secondary" + type="button" + disabled={this.deleting} + onclick={() => this.resetDelete()} + > + Cancel + </button> + <button + class="button button-danger" + type="button" + disabled={ + this.deleting || + this.deleteConfirm.trim().toLowerCase() !== this.deleteTarget.slug + } + onclick={() => this.submitDelete()} + > + {this.deleting ? 'Deleting' : 'Delete provider'} + </button> + </div> + </Modal> + ) : null} + </div> + ); + }, +}; diff --git a/app/admin/src/screen/settings.tsx b/app/admin/src/screen/settings.tsx @@ -407,7 +407,7 @@ export const SettingsPage: m.Component<SettingsAttrs> = { <section class="panel"> <h2>Realm access</h2> - <p class="note">Manage hostnames and email domains for this realm.</p> + <p class="note">Manage hostnames, email domains and identity providers for this realm.</p> <div class="action-row"> <a class="button button-secondary" @@ -429,6 +429,16 @@ export const SettingsPage: m.Component<SettingsAttrs> = { > Email domains </a> + <a + class="button button-secondary" + href={appUrl(`/providers/${encodeURIComponent(realmSlug || '')}`)} + onclick={(event: MouseEvent) => { + event.preventDefault(); + m.route.set(`/providers/${encodeURIComponent(realmSlug || '')}`); + }} + > + Providers + </a> </div> </section> </div> diff --git a/app/admin/src/util/api.ts b/app/admin/src/util/api.ts @@ -113,6 +113,72 @@ export interface AdminRealmEmailDomainDeleteResponse { domain: string; } +export interface AdminIdentityProviderDomain { + domain: string; + created_at: number; +} + +export interface AdminIdentityProvider { + id: string; + slug: string; + display_name: string; + issuer: string; + client_id: string; + scopes: string; + enabled: boolean; + has_secret: boolean; + domains: AdminIdentityProviderDomain[]; + created_at: number; + updated_at: number; +} + +export interface AdminIdentityProviderCreateInput { + slug: string; + display_name: string; + issuer: string; + client_id: string; + client_secret?: string; + scopes?: string; + enabled?: boolean; +} + +export interface AdminIdentityProviderPatchInput { + display_name?: string; + issuer?: string; + client_id?: string; + client_secret?: string | null; + scopes?: string; + enabled?: boolean; +} + +export interface AdminIdentityProviderListResponse { + providers: AdminIdentityProvider[]; +} + +export interface AdminIdentityProviderResponse { + ok: boolean; + provider: AdminIdentityProvider; +} + +export interface AdminIdentityProviderDeleteResponse { + ok: boolean; + removed: boolean; + slug: string; + unlinked_domains: string[]; +} + +export interface AdminProviderDomainConnectResponse { + ok: boolean; + domain: string; + already_connected?: boolean; +} + +export interface AdminProviderDomainDisconnectResponse { + ok: boolean; + removed: boolean; + domain: string; +} + export interface AdminRealmSettings { slug: string; display_name: string; diff --git a/app/admin/src/util/auth.ts b/app/admin/src/util/auth.ts @@ -13,6 +13,14 @@ import { type AdminClientHostCreateResponse, type AdminClientHostDeleteResponse, type AdminClientHostListResponse, + type AdminIdentityProvider, + type AdminIdentityProviderCreateInput, + type AdminIdentityProviderDeleteResponse, + type AdminIdentityProviderListResponse, + type AdminIdentityProviderPatchInput, + type AdminIdentityProviderResponse, + type AdminProviderDomainConnectResponse, + type AdminProviderDomainDisconnectResponse, type AdminGlobalUser, type AdminGlobalUserDetail, type AdminMeUser, @@ -216,6 +224,91 @@ export async function deleteAdminRealmEmailDomain( ); } +export async function loadAdminRealmProviders( + realmSlug: string +): Promise<AdminIdentityProvider[]> { + const realm = encodeURIComponent(realmSlug); + const response = await adminJson<AdminIdentityProviderListResponse>( + `/api/v1/admin/realms/${realm}/providers` + ); + return response.providers; +} + +export async function loadAdminRealmProvider( + realmSlug: string, + slug: string +): Promise<AdminIdentityProvider> { + const realm = encodeURIComponent(realmSlug); + const provider = encodeURIComponent(slug); + const response = await adminJson<AdminIdentityProviderResponse>( + `/api/v1/admin/realms/${realm}/providers/${provider}` + ); + return response.provider; +} + +export async function createAdminRealmProvider( + realmSlug: string, + input: AdminIdentityProviderCreateInput +): Promise<AdminIdentityProviderResponse> { + const realm = encodeURIComponent(realmSlug); + return adminJson<AdminIdentityProviderResponse>( + `/api/v1/admin/realms/${realm}/providers`, + { method: 'POST', body: JSON.stringify(input) } + ); +} + +export async function updateAdminRealmProvider( + realmSlug: string, + slug: string, + patch: AdminIdentityProviderPatchInput +): Promise<AdminIdentityProviderResponse> { + const realm = encodeURIComponent(realmSlug); + const provider = encodeURIComponent(slug); + return adminJson<AdminIdentityProviderResponse>( + `/api/v1/admin/realms/${realm}/providers/${provider}`, + { method: 'PATCH', body: JSON.stringify(patch) } + ); +} + +export async function deleteAdminRealmProvider( + realmSlug: string, + slug: string +): Promise<AdminIdentityProviderDeleteResponse> { + const realm = encodeURIComponent(realmSlug); + const provider = encodeURIComponent(slug); + return adminJson<AdminIdentityProviderDeleteResponse>( + `/api/v1/admin/realms/${realm}/providers/${provider}`, + { method: 'DELETE' } + ); +} + +export async function connectAdminProviderDomain( + realmSlug: string, + slug: string, + domain: string +): Promise<AdminProviderDomainConnectResponse> { + const realm = encodeURIComponent(realmSlug); + const provider = encodeURIComponent(slug); + return adminJson<AdminProviderDomainConnectResponse>( + `/api/v1/admin/realms/${realm}/providers/${provider}/domains`, + { method: 'POST', body: JSON.stringify({ domain }) } + ); +} + +export async function disconnectAdminProviderDomain( + realmSlug: string, + slug: string, + domain: string +): Promise<AdminProviderDomainDisconnectResponse> { + const realm = encodeURIComponent(realmSlug); + const provider = encodeURIComponent(slug); + const encoded = encodeURIComponent(domain); + return adminJson<AdminProviderDomainDisconnectResponse>( + `/api/v1/admin/realms/${realm}/providers/${provider}/domains/${encoded}`, + { method: 'DELETE' } + ); +} + export async function loadAdminSessions(realmSlug: string): Promise<AdminSession[]> { const realm = encodeURIComponent(realmSlug); const response = await adminJson<{ sessions: AdminSession[] }>( diff --git a/tools/css-check/fixtures/provider-domains.html b/tools/css-check/fixtures/provider-domains.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width,initial-scale=1"> + <title>provider domains table fixture</title> + <link rel="stylesheet" href="../../../app/shared/style/global.css"> + </head> + <body> + <main class="content"> + <section class="panel" aria-label="Connected domains"> + <h2>Connected domains</h2> + <p class="note">Verified email domains that route sign-in through this provider.</p> + + <div class="toolbar toolbar-panel"> + <div class="field"> + <span class="field-label" id="provider-domain-select-label">Email domain</span> + <button class="select-trigger" type="button" aria-labelledby="provider-domain-select-label"> + <span class="select-value">Select a domain</span> + </button> + </div> + <div class="toolbar-actions"> + <button class="button button-primary" type="button">Connect</button> + </div> + </div> + + <table class="table"> + <thead> + <tr> + <th scope="col">Domain</th> + <th scope="col">Added</th> + <th scope="col">Actions</th> + </tr> + </thead> + <tbody> + <tr> + <td data-label="Domain"> + <span class="table-mono">sso.acme.test</span> + </td> + <td data-label="Added" class="table-meta u-nowrap">12 Mar 2026</td> + <td data-label="Actions"> + <button class="button-inline button-danger" type="button">Disconnect</button> + </td> + </tr> + <tr> + <td data-label="Domain"> + <span class="table-mono">a-really-long-domain-name-for-boundary-checking.enterprise.test</span> + </td> + <td data-label="Added" class="table-meta u-nowrap">1 December 2025</td> + <td data-label="Actions"> + <button class="button-inline button-danger" type="button">Disconnect</button> + </td> + </tr> + </tbody> + </table> + </section> + </main> + </body> +</html> diff --git a/tools/css-check/fixtures/providers.html b/tools/css-check/fixtures/providers.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width,initial-scale=1"> + <title>providers table fixture</title> + <link rel="stylesheet" href="../../../app/shared/style/global.css"> + </head> + <body> + <main class="content"> + <section class="card" aria-label="Realm identity providers"> + <div class="toolbar toolbar-panel"> + <div class="toolbar-search"> + <input + type="search" + aria-label="Search providers" + placeholder="Search providers" + > + </div> + <div class="toolbar-actions"> + <button class="button button-primary" type="button">Add provider</button> + </div> + </div> + + <table class="table"> + <thead> + <tr> + <th scope="col">Provider</th> + <th scope="col">Issuer</th> + <th scope="col">Status</th> + <th scope="col">Domains</th> + <th scope="col">Actions</th> + </tr> + </thead> + <tbody> + <tr> + <td data-label="Provider">Example SSO</td> + <td data-label="Issuer"> + <span class="table-mono">https://idp.example.com</span> + </td> + <td data-label="Status" class="u-nowrap"> + <span class="status"> + <span class="status-dot" aria-hidden="true"></span> + Enabled + </span> + </td> + <td data-label="Domains">1</td> + <td data-label="Actions" class="u-nowrap"> + <a class="button-inline" href="#">Edit</a> + <button class="button-inline" type="button">Disable</button> + <button class="button-inline button-danger" type="button">Delete</button> + </td> + </tr> + <tr> + <td data-label="Provider">Legacy SSO</td> + <td data-label="Issuer"> + <span class="table-mono">https://old-idp.example.net</span> + </td> + <td data-label="Status" class="u-nowrap"> + <span class="status"> + <span class="status-dot" aria-hidden="true"></span> + Disabled + </span> + </td> + <td data-label="Domains">0</td> + <td data-label="Actions" class="u-nowrap"> + <a class="button-inline" href="#">Edit</a> + <button class="button-inline" type="button">Enable</button> + <button class="button-inline button-danger" type="button">Delete</button> + </td> + </tr> + <tr> + <td data-label="Provider">A Really Long Provider Display Name For Boundary Checking</td> + <td data-label="Issuer"> + <span class="table-mono">https://a-really-long-issuer-hostname-for-boundary-checking.enterprise.test</span> + </td> + <td data-label="Status" class="u-nowrap"> + <span class="status"> + <span class="status-dot" aria-hidden="true"></span> + Enabled + </span> + </td> + <td data-label="Domains">12</td> + <td data-label="Actions" class="u-nowrap"> + <a class="button-inline" href="#">Edit</a> + <button class="button-inline" type="button">Disable</button> + <button class="button-inline button-danger" type="button">Delete</button> + </td> + </tr> + </tbody> + </table> + </section> + </main> + </body> +</html>