Skip to content

Commit

Permalink
sse: bypass auth when yunohost postinstall aint done yet
Browse files Browse the repository at this point in the history
  • Loading branch information
alexAubin committed Dec 17, 2024
1 parent edb0beb commit ae36587
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions moulinette/interfaces/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import os
import sys
import re
import errno
Expand All @@ -36,6 +37,7 @@
from moulinette.core import (
MoulinetteError,
MoulinetteValidationError,
MoulinetteAuthenticationError,
)
from moulinette.interfaces import (
BaseActionsMapParser,
Expand Down Expand Up @@ -396,11 +398,12 @@ def sse(self):
profile = request.params.get("profile", self.actionsmap.default_authentication)
authenticator = self.actionsmap.get_authenticator(profile)

try:
authenticator.get_session_cookie()
except KeyError:
raise HTTPResponse(m18n.g("not_logged_in"), 401)

# Hardcoded yunohost stuff for the SSE stream to not require authentication when postinstall isnt done yet...
if os.path.exists("/etc/yunohost/installed"):
try:
authenticator.get_session_cookie()
except MoulinetteAuthenticationError:
raise HTTPResponse(m18n.g("not_logged_in"), 401)

response.content_type = 'text/event-stream'
response.cache_control = 'no-cache'
Expand Down

0 comments on commit ae36587

Please sign in to comment.