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

Mismatching redirect URI. #1012

Closed
AmsellemJoseph opened this issue Mar 5, 2024 · 3 comments
Closed

Mismatching redirect URI. #1012

AmsellemJoseph opened this issue Mar 5, 2024 · 3 comments

Comments

@AmsellemJoseph
Copy link

yes

Bug description

When i want to signin in studio, I always get this error:

Error: invalid_request
Mismatching redirect URI.

Here is my cms-sso config:

Screenshot 2024-03-05 143846

How to reproduce

Environment

This is in Docker environment
Additional context

Thx a lot for your help :)

@yagouam
Copy link

yagouam commented Mar 6, 2024

Hi @AmsellemJoseph

We've face the same problem in our OpenEdx environment. We followed this solution to solve the problem.

To implement it into tutor we created a plugin with the following code (I've added comments for clarification):

from tutor import hooks

"""
Modify CMS OAuth configuration to prevent "Error: invalid_request. Mismatching redirect URI" when entering to Studio because Django Oauth Toolkit's request_uri is setted as https and we are trying to access as http.

An initial solution to this issue was to change Django Oauth Toolkit configuration directly in django admin, as suggested here https://discuss.openedx.org/t/error-invalid-request-mismatching-redirect-uri/7552 . But whenever we rebuild images or run "tutor local launch" this config is reseted and the issue reappears.

Changing SOCIAL_AUTH_REDIRECT_IS_HTTPS to True make this patch persistent and remove the need of changing django admin. See https://stackoverflow.com/a/56958260
"""

hooks.Filters.ENV_PATCHES.add_item(
    (
        "openedx-cms-common-settings",
        """
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PORT', '443')
USE_X_FORWARDED_PROTO = True
USE_X_FORWARDED_PORT = True
"""
    )
)

hooks.Filters.ENV_PATCHES.add_item(
     (
         "openedx-lms-common-settings",
         """
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PORT', '443')
USE_X_FORWARDED_PROTO = True
USE_X_FORWARDED_PORT = True
"""
     )
 )

@AmsellemJoseph
Copy link
Author

hey @yagouam,
Thx for your response.
I tried it, but unfortunately, it's always the same result...

@regisb
Copy link
Contributor

regisb commented Mar 26, 2024

Tutor does not support CMS urls that are suffixed with a port ("mydomain.com:4437") -- this issue is one of the reasons why.

@regisb regisb closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

3 participants