Fix authentik search engine

This commit is contained in:
2026-06-12 19:04:41 +02:00
parent 07bfc1045a
commit 67fc0b9bd3
3 changed files with 5 additions and 7 deletions
+2 -4
View File
@@ -1,5 +1,5 @@
const DEFAULT_URL = ""; const DEFAULT_URL = "";
const API_PATH = "/api/v3/core/applications"; const API_PATH = "/api/v3/core/applications/";
function isValidUrl(string) { function isValidUrl(string) {
try { try {
@@ -55,15 +55,13 @@ export default class AuthentikEngine {
context context
) { ) {
try { try {
configured = await this.isConfigured(); const configured = await this.isConfigured();
if(!configured){ if(!configured){
return []; return [];
} }
const doFetch = context?.fetch ?? fetch; const doFetch = context?.fetch ?? fetch;
var headers = {};
const response = await doFetch(`${this.authentikSearchUrl}?search=${encodeURIComponent(query)}&page_size=20&page=${encodeURIComponent(page)}`, {headers: {"Accept": "application/json", "Authorization": `Bearer ${this.authentikToken}` }}) const response = await doFetch(`${this.authentikSearchUrl}?search=${encodeURIComponent(query)}&page_size=20&page=${encodeURIComponent(page)}`, {headers: {"Accept": "application/json", "Authorization": `Bearer ${this.authentikToken}` }})
context?.sentinel?.(response, this.name) context?.sentinel?.(response, this.name)
const response_json = await response.json() const response_json = await response.json()
@@ -6,7 +6,7 @@ const AuthentikEngine = require('../index.js').default;
// --- CONFIGURATION --- // --- CONFIGURATION ---
const TEST_AUTHENTIK_URL = "https://authentik.furb.it"; // Change to your local instance if testing real connections const TEST_AUTHENTIK_URL = "https://authentik.furb.it"; // Change to your local instance if testing real connections
const API_PATH = "/api/v3/core/applications"; const API_PATH = "/api/v3/core/applications/";
// Mock Settings (Replace with your config or local instance URL) // Mock Settings (Replace with your config or local instance URL)
const settings = { const settings = {
@@ -106,7 +106,7 @@ async function runSearchTest() {
// Note: For a local test without a real API, you would typically need a Mock Server // Note: For a local test without a real API, you would typically need a Mock Server
// Here we will attempt a call to the real hosted Authentik to verify logic. // Here we will attempt a call to the real hosted Authentik to verify logic.
// Replace 'query' with a term that exists on public authentik.com // Replace 'query' with a term that exists on public authentik.com
const query = "esphome"; const query = "plex";
console.log(`\nExecuting search for: ${query}`); console.log(`\nExecuting search for: ${query}`);
+1 -1
View File
@@ -19,7 +19,7 @@
"path": "engines/authentik-searchengine", "path": "engines/authentik-searchengine",
"name": "Authentik", "name": "Authentik",
"description": "Search your private authentik instance", "description": "Search your private authentik instance",
"version": "1.0.0", "version": "1.0.1",
"screenshots": [ "screenshots": [
"screenshots/1.png" "screenshots/1.png"
] ]