GithubHelp home page GithubHelp logo

Comments (4)

edulix avatar edulix commented on July 28, 2024

Hi Xavi: I'm not sure what's the problem, but you shouldn't use sqlite. BTW, I recommend you to try with this deployment script: https://github.com/agoravoting/agora-ciudadana-box

from agora-ciudadana.

xaviarias avatar xaviarias commented on July 28, 2024

Thanks Edulix. I'll try with the agora box.

from agora-ciudadana.

xaviarias avatar xaviarias commented on July 28, 2024

After having several problems with the deployment script, I have changed the database to PostgreSQL. The site works much faster than SQL Lite, but the error still appears.

I think is a security issue, regarding at the line authentication.py line 161:

if request.META.get('HTTP_AUTHORIZATION') ...
else:
    username = request.GET.get('username') or request.POST.get('username')
    api_key = request.GET.get('api_key') or request.POST.get('api_key')
    ...

Neither the headers or GET/POST data contain API Key. In debug mode I have set the request.META dictionary to {'HTTP_AUTHORIZATION' : 'apikey xavi:xxxxxxxxxxxxxxxx'} with the proper API Key and it works fine.

The request is generated in agora_view.html line 93:

var ajax_data = {
    'tallied_elections': {% rest request '/agora/' agora.id '/tallied_elections/?limit=3' %},
    'agora': {% rest request '/agora/' agora.id '/' %},
    'user_permissions': {% custom_rest request "POST" '{"action":"get_permissions"}' '/agora/' agora.id '/action/' %}
};

The custom rest request in POST to obtain user permissions must be authenticated in order to succeed.
In any case, the error should not produce this error page. Instead, receiving a 401 Ajax response should only display a blank content.

Searching about the AttributeError 'str' object has no attribute 'get', it seems that the response returned to Django is a string instead of HttpResponse, but debugging the code becomes too complex to find out the exact place.

Could you look ajax_data to see where the headers are managed and maybe add the Authorization header?

from agora-ciudadana.

xaviarias avatar xaviarias commented on July 28, 2024

Last commit solved the issue, thanks @danigm !

from agora-ciudadana.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.