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:
1 parent
6c5a5f0bd6
commit
c9385387bc
9 files changed
+152
-12
No files matched your search
@@ -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>
|
||||
) : (
|
||||
|
||||
Reference in new issue
Block a user