puiterwijk / flask-oidc

OpenID Connect support for Flask
BSD 2-Clause "Simplified" License
157 stars 219 forks source link

Why custom callback is bound with custom state? #91

Open kkzxak47 opened 5 years ago

kkzxak47 commented 5 years ago

Is there a way to enable custom callback and still use auto generated state? Currently I'm using a self modified version of flask-oidc, added a parameter to custom_callback decorator, so I can control whether to use custom or auto state:

    def custom_callback(self, statefield='custom'):
        def _custom_callback(view_func):
            """
            Wrapper function to use a custom callback.
            The custom OIDC callback will get the custom state field passed in with
            redirect_to_auth_server.
            """
            @wraps(view_func)
            def decorated(*args, **kwargs):
                plainreturn, data = self._process_callback(statefield)
                if plainreturn:
                    return data
                else:
                    return view_func(data, *args, **kwargs)
            self._custom_callback = decorated
            return decorated
        return _custom_callback

But I was wondering what's the rationale of current implementation?