mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Enhancement: handle authentik v2025.8.0 breaking API changes (#5687)
This commit is contained in:
@@ -17,9 +17,15 @@ The account you made the API token for also needs the following **Assigned globa
|
|||||||
|
|
||||||
Allowed fields: `["users", "loginsLast24H", "failedLoginsLast24H"]`.
|
Allowed fields: `["users", "loginsLast24H", "failedLoginsLast24H"]`.
|
||||||
|
|
||||||
|
| Authentik Version | Homepage Widget Version |
|
||||||
|
| ----------------- | ----------------------- |
|
||||||
|
| < 2025.8.0 | 1 (default) |
|
||||||
|
| >= 2025.8.0 | 2 |
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
type: authentik
|
type: authentik
|
||||||
url: http://authentik.host.or.ip:port
|
url: http://authentik.host.or.ip:port
|
||||||
key: api_token
|
key: api_token
|
||||||
|
version: 2 # optional, default is 1
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
// gamedig
|
// gamedig
|
||||||
gameToken,
|
gameToken,
|
||||||
|
|
||||||
// beszel, glances, immich, komga, mealie, pihole, pfsense, speedtest
|
// authentik, beszel, glances, immich, komga, mealie, pihole, pfsense, speedtest
|
||||||
version,
|
version,
|
||||||
|
|
||||||
// glances
|
// glances
|
||||||
@@ -518,6 +518,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
|
"authentik",
|
||||||
"beszel",
|
"beszel",
|
||||||
"glances",
|
"glances",
|
||||||
"immich",
|
"immich",
|
||||||
|
|||||||
@@ -10,8 +10,12 @@ export default function Component({ service }) {
|
|||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data: usersData, error: usersError } = useWidgetAPI(widget, "users");
|
const { data: usersData, error: usersError } = useWidgetAPI(widget, "users");
|
||||||
const { data: loginsData, error: loginsError } = useWidgetAPI(widget, "login");
|
|
||||||
const { data: failedLoginsData, error: failedLoginsError } = useWidgetAPI(widget, "login_failed");
|
const loginsEndpoint = widget.version === 2 ? "loginv2" : "login";
|
||||||
|
const { data: loginsData, error: loginsError } = useWidgetAPI(widget, loginsEndpoint);
|
||||||
|
|
||||||
|
const failedLoginsEndpoint = widget.version === 2 ? "login_failedv2" : "login_failed";
|
||||||
|
const { data: failedLoginsData, error: failedLoginsError } = useWidgetAPI(widget, failedLoginsEndpoint);
|
||||||
|
|
||||||
if (usersError || loginsError || failedLoginsError) {
|
if (usersError || loginsError || failedLoginsError) {
|
||||||
const finalError = usersError ?? loginsError ?? failedLoginsError;
|
const finalError = usersError ?? loginsError ?? failedLoginsError;
|
||||||
@@ -28,15 +32,29 @@ export default function Component({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const yesterday = new Date(Date.now()).setHours(-24);
|
let loginsLast24H;
|
||||||
const loginsLast24H = loginsData.reduce(
|
let failedLoginsLast24H;
|
||||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
switch (widget.version) {
|
||||||
0,
|
case 1:
|
||||||
);
|
const yesterday = new Date(Date.now()).setHours(-24);
|
||||||
const failedLoginsLast24H = failedLoginsData.reduce(
|
loginsLast24H = loginsData.reduce(
|
||||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
failedLoginsLast24H = failedLoginsData.reduce(
|
||||||
|
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (loginsData.length > 0) {
|
||||||
|
loginsLast24H = loginsData[0]?.count || 0;
|
||||||
|
}
|
||||||
|
if (failedLoginsData.length > 0) {
|
||||||
|
failedLoginsLast24H = failedLoginsData[0]?.count || 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
|
|||||||
@@ -11,9 +11,15 @@ const widget = {
|
|||||||
login: {
|
login: {
|
||||||
endpoint: "events/events/per_month/?action=login",
|
endpoint: "events/events/per_month/?action=login",
|
||||||
},
|
},
|
||||||
|
loginv2: {
|
||||||
|
endpoint: "events/events/volume/?action=login&&history_days=1",
|
||||||
|
},
|
||||||
login_failed: {
|
login_failed: {
|
||||||
endpoint: "events/events/per_month/?action=login_failed",
|
endpoint: "events/events/per_month/?action=login_failed",
|
||||||
},
|
},
|
||||||
|
login_failedv2: {
|
||||||
|
endpoint: "events/events/volume/?action=login_failed&&history_days=1",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user