Create Authentik groups from Apps → Authentik

A New group form in the Groups section makes a group with a name and nothing
else: it starts empty and is never one that makes administrators of
Authentik. A name Authentik already has is refused in its own words, and a
name that decides a role in this app (Settings → Sign-in) is said to. Admin
only; audited with who made which group.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-01 00:58:33 +01:00
1 parent 6c5a5f0bd6
commit c9385387bc
9 files changed
+152 -12

No files matched your search

+1
View File
@@ -3444,6 +3444,7 @@ export const api = {
users: (id: number, search = "") => request<{ users: AuthentikPerson[]; more: boolean; self: number | null }>(`/api/authentik/${id}/users${search.trim() ? `?search=${encodeURIComponent(search.trim())}` : ""}`),
setUserActive: (id: number, pk: number, active: boolean) => request<{ user: AuthentikPerson }>(`/api/authentik/${id}/users/${pk}/active`, { method: "POST", body: JSON.stringify({ active }) }),
groupDetails: (id: number) => request<{ groups: AuthentikGroupDetail[]; people: AuthentikGroupPerson[]; more: boolean; self: number | null }>(`/api/authentik/${id}/group-details`),
createGroup: (id: number, name: string) => request<{ group: AuthentikGroupDetail }>(`/api/authentik/${id}/groups`, { method: "POST", body: JSON.stringify({ name }) }),
updateGroup: (id: number, gid: string, body: { name?: string; membersAdd?: number[]; membersRemove?: number[] }) => request<{ changed: string[]; added: number; removed: number }>(`/api/authentik/${id}/groups/${gid}`, { method: "PATCH", body: JSON.stringify(body) }),
updateUser: (id: number, pk: number, body: { name?: string; email?: string; groupsAdd?: string[]; groupsRemove?: string[] }) => request<{ user: AuthentikPerson; changed: string[] }>(`/api/authentik/${id}/users/${pk}`, { method: "PATCH", body: JSON.stringify(body) }),
deleteUser: (id: number, pk: number, username: string) => request<void>(`/api/authentik/${id}/users/${pk}`, { method: "DELETE", body: JSON.stringify({ username }) }),
+49 -2
View File
@@ -74,7 +74,8 @@ function EditGroup({ g, people, self, busy, onSave, onCancel }: { g: AuthentikGr
}
/**
* The groups of an Authentik, for an administrator to rename and to put users in and take them out of. Whether a group makes its members administrators is shown, not changed. A group that
* The groups of an Authentik, for an administrator to make, rename and to put users in and take them out of. Whether a group makes its members administrators is shown, not changed — and a group
* made here never does. A group that
* decides somebody's role in this app says so, and asks before it is changed.
*/
export default function AuthentikGroupList({ a }: { a: AuthentikInfo }) {
@@ -85,9 +86,32 @@ export default function AuthentikGroupList({ a }: { a: AuthentikInfo }) {
const [busy, setBusy] = useState<string | "list" | null>(null);
const [error, setError] = useState<string | null>(null);
const [notice, setNotice] = useState<string | null>(null);
const [creating, setCreating] = useState(false);
const [newName, setNewName] = useState("");
if (!a.canCreateUsers) return null;
async function create(e: FormEvent) {
e.preventDefault();
if (busy !== null) return;
setBusy("new");
setError(null);
setNotice(null);
try {
const { group } = await api.authentik.createGroup(a.id, newName.trim());
setCreating(false);
setNewName("");
setNotice(
`Made "${group.name}", with no members.${group.decidesRole ? ` Its name decides who is ${group.decidesRole === "admin" ? "an administrator" : "an operator"} here (Settings → Sign-in): whoever is put in it gets that role at their next sign-in.` : ""}`,
);
if (groups !== null) await load();
else setBusy(null);
} catch (err) {
setError(readableError(err));
setBusy(null);
}
}
async function load() {
setBusy("list");
setError(null);
@@ -132,8 +156,31 @@ export default function AuthentikGroupList({ a }: { a: AuthentikInfo }) {
<h4>Groups</h4>
<ErrorNotice error={error} />
<SuccessNotice notice={notice} />
{creating ? (
<form onSubmit={create} className="card card-sm mb-2">
<div className="card-body">
<label className="form-label" htmlFor={`ak-new-group-${a.id}`}>
Name of the new group
</label>
<input id={`ak-new-group-${a.id}`} className="form-control form-control-sm mb-2" style={{ maxWidth: 360 }} required maxLength={200} autoComplete="off" autoFocus value={newName} onChange={(e) => setNewName(e.target.value)} />
<div className="text-secondary small mb-2">It starts with no members — put them in with Edit — and it does not make its members administrators of Authentik; that is decided in Authentik.</div>
<div className="d-flex gap-2">
<button type="submit" className="btn btn-sm btn-primary" disabled={busy !== null || newName.trim() === ""}>
{busy === "new" ? "Making…" : "Make group"}
</button>
<button type="button" className="btn btn-sm btn-link text-secondary" onClick={() => { setCreating(false); setNewName(""); }} disabled={busy === "new"}>
Cancel
</button>
</div>
</div>
</form>
) : (
<button type="button" className="btn btn-sm btn-primary me-2 mb-2" onClick={() => { setCreating(true); setNotice(null); setError(null); }} disabled={busy !== null}>
New group…
</button>
)}
{groups === null ? (
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => void load()} disabled={busy !== null}>
<button type="button" className="btn btn-sm btn-outline-secondary mb-2" onClick={() => void load()} disabled={busy !== null}>
{busy === "list" ? "Reading…" : "Show groups"}
</button>
) : (
+1 -1
View File
@@ -162,7 +162,7 @@ export default function Authentik({ user }: { user: CurrentUser }) {
<h2 className="page-title">Authentik</h2>
<p className="text-secondary">
The sign-in in front of everything else. It is read every few minutes with an API token (see <Link to="/integrations">Integrations</Link>). An <strong>outpost that goes quiet</strong> (the apps it guards stop letting anyone in), a <strong>certificate</strong> or an{" "}
<strong>API token</strong> that is about to run out, <strong>no worker</strong> and a burst of <strong>failed sign-ins</strong> are alerts — see <Link to="/alerts">Alerts</Link>.{user.role === "admin" && " An administrator can also make a user here, with a one-time link for them to choose a password, and switch users off or delete them, and rename groups and change who is in them."}
<strong>API token</strong> that is about to run out, <strong>no worker</strong> and a burst of <strong>failed sign-ins</strong> are alerts — see <Link to="/alerts">Alerts</Link>.{user.role === "admin" && " An administrator can also make a user here, with a one-time link for them to choose a password, and switch users off or delete them, and make and rename groups and change who is in them."}
</p>
<ErrorNotice error={error} />
{!data && !error && <BlockSkeleton lines={4} />}