Skip to content

Commit

Permalink
Merge pull request #5 from thcrt/hide-apps
Browse files Browse the repository at this point in the history
Add application hiding
  • Loading branch information
thcrt authored Dec 9, 2024
2 parents 12d9fe1 + e53af3e commit d26bfbc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ The URL to an icon representing the app.

### `apps.<app-name>.url`
The URL at which the app is hosted, to which the user will be redirected when clicking it.

### `apps.<app-name>.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)).
2 changes: 1 addition & 1 deletion src/blobdash/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/blobdash/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Application:
url: Optional[str] = None
icon: Optional[str] = None
desc: Optional[str] = None
hidden: bool = False


class ApplicationProvider:
Expand Down
4 changes: 4 additions & 0 deletions src/blobdash/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion src/blobdash/settings.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/blobdash/templates/index.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@
</dialog>
<main>
{% for app in apps.values() %}
<a href="{{ app.url }}">
<img src="{{ app.icon }}">
<h3>
{{ app.name }}
</h3>
<p>{{ app.desc }}</p>
</a>
{% if not app.hidden %}
<a href="{{ app.url }}">
<img src="{{ app.icon }}">
<h3>
{{ app.name }}
</h3>
<p>{{ app.desc }}</p>
</a>
{% endif %}
{% endfor %}
</main>
</body>
Expand Down

0 comments on commit d26bfbc

Please sign in to comment.