Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] GitHub OAuth Callback URL Forcing HTTPS Despite HTTP Configuration #615

Open
cheum opened this issue Dec 27, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@cheum
Copy link

cheum commented Dec 27, 2024

GitHub OAuth Callback URL Forcing HTTPS Despite HTTP Configuration

I want to deploy my app using HTTP.
The callback URL for GitHub OAuth still supports HTTP.
However, even if I set the callback URL to use HTTP, the redirect_uri is automatically changed to HTTPS when returned by the redir_url function.
I attempted to use the scheme parameter of redir_url, but it doesn’t work when host="0.0.0.0".
(Temporarily using the replace syntax resolves the issue.)

I understand that HTTPS is the standard, but I wanted to report this behavior. Below is the code I used.

# User asks us to Login
@app.get("/login")
def login(request):
    redir = redir_url(request, auth_callback_path, "http")  # .replace("https", "http")
    login_link = client.login_link(redir)
    return login_page(login_link)


# User comes back to us with an auth code from Github
@app.get(auth_callback_path)
def auth_redirect(code: str, request, session):
    redir = redir_url(request, auth_callback_path, "http")  # .replace("https", "http")
    user_info = client.retr_info(code, redir)
    user_id = user_info[client.id_key]
    session["user_id"] = user_id

    if user_id != authorized_user_id:
        return RedirectResponse("/protected", status_code=303)
    return RedirectResponse("/", status_code=303)


@app.get("/protected")
async def protected(req):
    return not_authorized_page()


serve(host="0.0.0.0", port=8050, reload=(not ENV_MODE))

Expected behavior

redir = redir_url(request, auth_callback_path, “http”)

I hope the syntax works.

Environment Information
Please provide the following version information:

  • fastlite version: 0.0.13
  • fastcore version: 1.7.22
  • fasthtml version: 0.10.1
@cheum cheum added the bug Something isn't working label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant