1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/auth/auth_context.py
Syed Ahmed 2db3b186f9 ui: add support for exposing quay UI as a dynamic plugin (PROJQUAY-3203) (#1799)
* ui: add support for exposing quay UI as a dynamic plugin (PROJQUAY-3203)

* Introduces a new SSO JWT based auth for client side Oauth
* Adds a new entrypoint component for the UI without topnav and sidenav for plugin
* Adds webpack config to build dynamic plugin
2023-04-20 19:05:07 -04:00

42 lines
1.1 KiB
Python

from flask import _request_ctx_stack
def get_authenticated_context():
"""
Returns the auth context for the current request context, if any.
"""
return getattr(_request_ctx_stack.top, "authenticated_context", None)
def get_authenticated_user():
"""
Returns the authenticated user, if any, or None if none.
"""
context = get_authenticated_context()
return context.authed_user if context else None
def get_validated_oauth_token():
"""
Returns the authenticated and validated OAuth access token, if any, or None if none.
"""
context = get_authenticated_context()
return context.authed_oauth_token if context else None
def get_sso_token():
"""
Returns the authenticated and SSO token, if any, or None if none.
"""
context = get_authenticated_context()
return context.sso_token if context else None
def set_authenticated_context(auth_context):
"""
Sets the auth context for the current request context to that given.
"""
ctx = _request_ctx_stack.top
ctx.authenticated_context = auth_context
return auth_context