mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Compare commits
2 Commits
6d7be1c7f2
...
a6ab095ff9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6ab095ff9 | ||
|
|
9a085bcb17 |
@@ -17,9 +17,15 @@ The account you made the API token for also needs the following **Assigned globa
|
||||
|
||||
Allowed fields: `["users", "loginsLast24H", "failedLoginsLast24H"]`.
|
||||
|
||||
| Authentik Version | Homepage Widget Version |
|
||||
| ----------------- | ----------------------- |
|
||||
| < 2025.8.0 | 1 (default) |
|
||||
| >= 2025.8.0 | 2 |
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: authentik
|
||||
url: http://authentik.host.or.ip:port
|
||||
key: api_token
|
||||
version: 2 # optional, default is 1
|
||||
```
|
||||
|
||||
@@ -308,7 +308,7 @@ export function cleanServiceGroups(groups) {
|
||||
// gamedig
|
||||
gameToken,
|
||||
|
||||
// beszel, glances, immich, komga, mealie, pihole, pfsense, speedtest
|
||||
// authentik, beszel, glances, immich, komga, mealie, pihole, pfsense, speedtest
|
||||
version,
|
||||
|
||||
// glances
|
||||
@@ -518,6 +518,7 @@ export function cleanServiceGroups(groups) {
|
||||
}
|
||||
if (
|
||||
[
|
||||
"authentik",
|
||||
"beszel",
|
||||
"glances",
|
||||
"immich",
|
||||
|
||||
@@ -10,8 +10,12 @@ export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
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) {
|
||||
const finalError = usersError ?? loginsError ?? failedLoginsError;
|
||||
@@ -28,15 +32,25 @@ export default function Component({ service }) {
|
||||
);
|
||||
}
|
||||
|
||||
const yesterday = new Date(Date.now()).setHours(-24);
|
||||
const loginsLast24H = loginsData.reduce(
|
||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||
0,
|
||||
);
|
||||
const failedLoginsLast24H = failedLoginsData.reduce(
|
||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||
0,
|
||||
);
|
||||
let loginsLast24H;
|
||||
let failedLoginsLast24H;
|
||||
switch (widget.version) {
|
||||
case 1:
|
||||
const yesterday = new Date(Date.now()).setHours(-24);
|
||||
loginsLast24H = loginsData.reduce(
|
||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||
0,
|
||||
);
|
||||
failedLoginsLast24H = failedLoginsData.reduce(
|
||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||
0,
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
loginsLast24H = loginsData[0]?.count || 0;
|
||||
failedLoginsLast24H = failedLoginsData[0]?.count || 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
|
||||
@@ -11,9 +11,15 @@ const widget = {
|
||||
login: {
|
||||
endpoint: "events/events/per_month/?action=login",
|
||||
},
|
||||
loginv2: {
|
||||
endpoint: "events/events/volume/?action=login&&history_days=1",
|
||||
},
|
||||
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