vertexcover-io / falcon-auth

A falcon middleware + authentication backends that adds authentication layer to you app/api service.
MIT License
103 stars 31 forks source link

Resource auth attribute is modified by FalconAuthMiddleware #33

Open volinthius opened 5 years ago

volinthius commented 5 years ago

In FalconAuthMiddleware the auth attribute of the resource is picked and then modified:

    def _get_auth_settings(self, req, resource):
        auth_settings = getattr(resource, 'auth', {})
        auth_settings['exempt_routes'] = self.exempt_routes
        if auth_settings.get('auth_disabled'):
            auth_settings['exempt_routes'].append(req.uri_template)

        for key in ('exempt_methods', 'backend'):
            auth_settings[key] = auth_settings.get(key) or getattr(self, key)

        return auth_settings

This causes a minor issue with JWTAuthBackend backend during testing when resource is only overriding exempt_methods (not backend). For each test we are creating a fresh OIDC provider instance. However since the auth backend (and JWT key with it) is already set in one test to resource later tests still use that old auth backend (with old JWT key) key and fail.