Skip to content

Cannot build url for 'logout' when using dynamic client registration #116

Closed
@infohash

Description

@infohash
Contributor

If the logout view is mounted under a custom endpoint (other than the default, which is the name of the view function), or if using Blueprints, you must specify the full URL in the Flask-pyoidc configuration using post_logout_redirect_uris.

This is working as intended but when using dynamic client registration these methods are called:

def _register_client(self, client):

post_logout_redirect_uris = client._provider_configuration._client_registration_info.get(
'post_logout_redirect_uris',
default_post_logout_redirect_uris())

url_for_logout_view = self._get_url_for_logout_view()

def _get_url_for_logout_view(self):
return url_for(self._logout_view.__name__, _external=True) if self._logout_view else None

self._logout_view.__name__ returns the name of the view function. url_for uses the route registration to find the route registered against that name. If the view function is mounted at blueprint, its name is prefixed by the name of the blueprint so providing only __name__ to url_for is not enough.

blueprint = Blueprint('api', __name__, url_prefix='/api/v1')
@blueprint.route('/logout')
def logout():

    return 'You have been logged out'

print(url_for('api.logout'))
# http://localhost:5000/api/v1/logout
print(url_for('logout'))
# Cannot build url for 'logout'. Did you mean 'api.logout'?

.get() will always call that method to set default value even if post_logout_redirect_uris is provided as an argument.

Activity

changed the title [-]Cannot build route for 'logout' when using dynamic client registration[/-] [+]Cannot build url for 'logout' when using dynamic client registration[/+] on Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @infohash

        Issue actions

          Cannot build url for 'logout' when using dynamic client registration · Issue #116 · zamzterz/Flask-pyoidc