diff --git a/docs/configuration.md b/docs/configuration.md index 03f5f7a..bb5a768 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -98,3 +98,8 @@ The URL to an icon representing the app. ### `apps..url` The URL at which the app is hosted, to which the user will be redirected when clicking it. + +### `apps..hidden` +Set to `true` to mark an app as hidden and prevent it being shown to users. + +If an app is fetched from authentik with `auth.fetch`, this will be set to `true` if the app's launch URL is `blank://blank`, as this is how authentik natively hides apps ([docs](https://docs.goauthentik.io/docs/add-secure-apps/applications/manage_apps#hide-applications)). diff --git a/src/blobdash/__init__.py b/src/blobdash/__init__.py index 8294670..706560b 100644 --- a/src/blobdash/__init__.py +++ b/src/blobdash/__init__.py @@ -1,6 +1,6 @@ import flask as f from click import secho -from pydantic import ValidationError, BaseModel +from pydantic import ValidationError from .settings import Settings diff --git a/src/blobdash/applications.py b/src/blobdash/applications.py index 5e0a02d..f0bd84b 100644 --- a/src/blobdash/applications.py +++ b/src/blobdash/applications.py @@ -14,6 +14,7 @@ class Application: url: Optional[str] = None icon: Optional[str] = None desc: Optional[str] = None + hidden: bool = False class ApplicationProvider: diff --git a/src/blobdash/auth.py b/src/blobdash/auth.py index 5675098..9dd6b48 100644 --- a/src/blobdash/auth.py +++ b/src/blobdash/auth.py @@ -41,6 +41,10 @@ def get_applications(self, username: str) -> list[Application]: url=app.launch_url, icon=urllib.parse.urljoin(self.host, app.meta_icon), desc=app.meta_description, + hidden=( + (parsed_url := urllib.parse.urlparse(app.launch_url)).scheme == "blank" + and parsed_url.netloc == "blank" + ), ) for app in list.results } diff --git a/src/blobdash/settings.py b/src/blobdash/settings.py index 5588e2e..7b3db19 100644 --- a/src/blobdash/settings.py +++ b/src/blobdash/settings.py @@ -1,5 +1,4 @@ from typing import Tuple, Type, Optional, Literal -from abc import ABCMeta from pydantic import BaseModel from pydantic_extra_types import color diff --git a/src/blobdash/templates/index.html.jinja b/src/blobdash/templates/index.html.jinja index bddbeb9..8297884 100644 --- a/src/blobdash/templates/index.html.jinja +++ b/src/blobdash/templates/index.html.jinja @@ -90,13 +90,15 @@
{% for app in apps.values() %} - - -

- {{ app.name }} -

-

{{ app.desc }}

-
+ {% if not app.hidden %} + + +

+ {{ app.name }} +

+

{{ app.desc }}

+
+ {% endif %} {% endfor %}