Landing page with OAuth

I am using OAuth and I would like to get an unauthenticated landing page. I tried to use --index or --auth-template but it does not seem to do the trick. I get directly redirected to the OAuth page.

Is there a simple way to do that? The next thing I am thinking about is to use something like FastAPI before Panel. But then I should probably move the OAuth layer to FastAPI if I do that.

Apparently it’s not yet possible. One way to get there though is to use a custom OAuth plugin as described in the doc.

E.g. here is some dummy code showing how it could work:

class GoogleLoginHandler(OAuthIDTokenLoginHandler, OAuth2Mixin):

    _API_BASE_HEADERS = {
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
    }

    _OAUTH_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth"
    _OAUTH_ACCESS_TOKEN_URL = "https://accounts.google.com/o/oauth2/token"

    _SCOPE = ['profile', 'email']

    _USER_KEY = 'email'

    ##### Madness starts here ######

    def _simple_get(self):
        html = BASIC_LOGIN_TEMPLATE.render(
            errormessage="",
            PANEL_CDN=CDN_DIST
        )
        self.write(html)

    async def get(self):
        if "state" not in self.request.uri:
            self._simple_get()
        else:
            await super().get()

    async def post(self):
        await super().get()
1 Like