Giter VIP home page Giter VIP logo

e-petitions's Introduction

Petitions

This is the code base for the UK Government and Parliament's petitions service.

Setup

We recommend using Docker Desktop to get setup quickly. If you'd prefer not to use Docker then you'll need Ruby (3.0+), Node (20+), PostgreSQL (12+) and Memcached (1.5+) installed.

Create the databases

docker compose run --rm web rake db:setup

Load the country list

docker compose run --rm web rake epets:countries:load

Fetch the regions list

docker compose run --rm web rails runner 'FetchRegionsJob.perform_now'

Fetch the constituencies list

docker compose run --rm web rails runner 'FetchConstituenciesJob.perform_now'

Fetch the department list

docker compose run --rm web rails runner 'FetchDepartmentsJob.perform_now'

Enable signature counting

docker compose run --rm web rails runner 'Site.enable_signature_counts!(interval: 10)'

Start the services

docker compose up

Once the services have started you can access the front end, back end and any emails sent.

Tests

Before running any tests the database needs to be prepared:

docker compose run --rm web rake db:test:prepare

You can run the full test suite using following command:

docker compose run --rm web rake

Individual specs can be run using the following command:

docker compose run --rm web rspec spec/models/parliament_spec.rb

Similarly, individual cucumber features can be run using the following command:

docker compose run --rm web cucumber features/suzie_views_a_petition.feature

Moderation Portal SSO

The moderation portal is authenticated using the OmniAuth gem and implements a light wrapper around strategies so that multiple configurations of a strategy can be supported, e.g. two or more SAML identity providers.

The config/sso.yml has a configuration of the Developer strategy for local development which should not be used in production. The test configuration in the file shows how a typical SAML IdP would be configured.

There are four key attributes that need to be returned in the OmniAuth auth_info hash, these being first_name, last_name, email and groups. The email attribute acts as the uid for the user and the groups attribute controls what role they get assigned.

The configuration attributes are:

  • name

    This is a required attribute and must be unique. It also must be suitable for use in a url as it forms part of the callback url for OmniAuth.

  • strategy

    This is the OmniAuth strategy to use as the parent class for the identity provider.

  • domains

    The list of email domains to use with this identity provider, e.g.

    domains:
      - "example.com"
  • roles

    Controls the mapping of the groups attribute to the assigned role, e.g.

    roles:
      sysadmin:
        - "System Administrators"
      moderator:
        - "Petition Moderators"
      reviewer:
        - "Petition Reviewers"

    The default for any of the three roles is an empty set so if an identity provider is only being used for one of the roles then there's no need to configure the others.

  • config

    This is the configuration that is passed to the OmniAuth strategy and should be a hash of the documented options supported by the strategy.

e-petitions's People

Contributors

abraaomota avatar alanth avatar alexander-bobin avatar allbecauseyoutoldmeso avatar ansonk avatar benjamineskola avatar cdccollins avatar davidbasalla avatar dependabot[bot] avatar dracos avatar etagwerker avatar h-lame avatar jamiecobbett avatar kushalp avatar leandroalemao avatar mattbostock avatar mikerogers0 avatar mybits avatar neilvanbeinum avatar om-sharma avatar oskarpearson avatar otlaitil avatar pixeltrix avatar pudiva avatar richardjpope avatar rooreynolds avatar samcrang avatar thatkevin avatar tomski avatar willp-bl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

e-petitions's Issues

Installation problem

Hello! This may be a bit dumb question, but still.
When I am switching to the e-petitions project on my server, it gives me the following message:

=> Booting Puma
=> Rails 4.2.2 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Puma 2.11.3 starting...

  • Min threads: 0, max threads: 16
  • Environment: development
  • Listening on tcp://localhost:3000

How and where can I change the settings, so that it runs properly on my server address and not just localhost?

Dependent on Constituencies

I'm looking at the feasibility of forking this for the States of Jersey Government and have running locally with no issues (to start poking around at how it's doing certain things).

A few questions around Constituencies though.

  • What role does the check for a Constituency actually do?
  • Is it purely for results on the backend (which Constituencies are concerned the most about a petition) or is it tied up with the actual validation of a signature?
  • Is this only performed on the signature of a petition you've created or any time you sign one?

As I can currently sign a petition on parliament.uk without an issue using Jersey as a location and a valid Jersey postcode (assuming it be far too easy to limit location to just Jersey and have it all work...).

Thanks for any help.

Initial setup instructions don't work

The locations table is only populated in a migration, which you don't get if you use db:structure:load (which loads in structure.sql which says it includes all the migrations, including 20160210195916, but doesn't appear to include the data created in that migration).

If you instead have empty databases and run db:migrate, it appears to all run okay.

signatures_by_country element broken

Since #435 it seems that the signatures_by_country element of the json response is either missing or broken. Countries are missing and those that are there have incorrect signature counts.

Contacting petitioners

The benefits of using a petition from http://epetitions.direct.gov.uk/ for one's campaign are manifest.

Unfortunately, campaigners find themselves subsequently unable to communicate with those people who are manifestly interested in the issue to which the petition pertains.

Would it be possible to add an opt-in "allow $Person_or_organisation" to send me messages about this petition/campaign?

Receiving 403 errors on petition websites

Hi,

The Parallel Parliament server (134.209.27.240) is receiving 403 errors on all e-petition pages. This began around 0800Z on the 21st June 2021.

I presume this block is to do with the level of requests that the site makes on the petition pages. Would it be possible to have some guidance as how we can avoid being restricted in the future, or what issue caused the restrictions to initially be applied?

Small problem with installation -- PostgresSQL

Hello.

First, couple of small details regarding my environment.

  1. OS: Ubuntu 14.04
  2. PostgreSQL: 9.3

Error message:

$ rake db:structure:load
(in ~/Projects/Ruby/e-petitions)
psql: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"
rake aborted!
failed to execute:
psql -q -f ~/Projects/Ruby/e-petitions/db/structure.sql epets_development

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

Tasks: TOP => db:structure:load
(See full trace by running task with --trace)

Double-checked that the the epets user is available:

postgres=> select * from pg_user;
 usename  | usesysid | usecreatedb | usesuper | usecatupd | userepl |  passwd  | valuntil | useconfig 
----------+----------+-------------+----------+-----------+---------+----------+----------+-----------
 epets    |    16389 | f           | f        | f         | f       | ******** |          | 
 jremes   |    16390 | f           | f        | f         | f       | ******** |          | 
 postgres |       10 | t           | t        | t         | t       | ******** | infinity | 
(3 rows)

Looks like the PostgreSQL user defaults to "postgres" even if "epets" user exists.

Is there particular reason for this behaviour, please?

Thanks in advance.

Botnet attack

Has the site become compromised by a botnet attack, which has circumvented the email confirmation stage?

On the 2nd EU referendum petition the constant trickle of new signatures - including throughout the night - would appear to be suspicious.

Can't install locally with provided instructions

Hello,

I've been trying to install it a few days go but I get stuck at that part :
You will need to set up the config/database.yml. Copy what is in config/database.example.yml and add the password you used earlier for the epets postgres user

I can't find any file named database.example.ymlin the config file.

Could you provide any help?
Thanks!

Order option for records returned by petitions.json?

Currently I can search for bees in the list of rejected petitions via the following:

https://petition.parliament.uk/petitions.json?q=bees&page=1&state=rejected

Or list debated petitions via:

https://petition.parliament.uk/petitions.json?page=1&state=debated

I wondered if there is any additional parameter which can be passed to the search URL to allow results to be sorted by e.g. creation date, either ascending or descending?

I have searched first before raising this question but couldn't see anything, so maybe it's not an option?

Thanks

Jim

Signatures on petitions have no integrity

With the popularity of the recent 'revoke article 50' petition and rumours of signatories from other countries, fake signatories etc. I thought i'd take a look at the service to see how it all ticks.

It's occurred to me that all you need to sign a petition is a valid post code and an email address. Terribly poor integrity, if the purpose of the service was to verify that the petition was signed by a citizen.

Did you ever consider taking a NINO or passport number to prove citizenship? If there's a NINO -> Address database somewhere that would be even more formidable.

As it stands I think the service is easily disrupted, and as a result easily dismissed by the politicians it's meant to influence - was this an intentional strategy? I'd love to work to make it better. Even a 'i'm not a robot' button would go someway towards prevent fraudsters abusing the service.

API Documentation

This isn't really an issue, but more of a question..

I understand there is a REST API available for the website however I can't seem to find any documentation around the API... Is this available somewhere?

If it was in a really obvious place then my bad but if not then maybe it would be a good idea to provide a developer portal or some help pages referencing to it?

Thanks,
Liam

Shared "/signatures/" links say "We've added your signature to the petition"

A search on twitter shows people are sharing the user-specific "/signatures/" URLs on social media, rather than the intended "/petitions/" link.

Example: https://twitter.com/kerrycumiskey/status/623150244612702208 links to https://petition.parliament.uk/signatures/4688/signed/C6joqh4Feb4SYAWbphCa which returns the message

"We've added your signature to the petition: To debate a vote of no confidence in Health Secretary the Right Hon Jeremy Hunt"

Which is confusing to a user, since it give the impression that just by following the link they have "signed". Which may not have been their intention.

Also, as an aside I note that this also leaks the signer's constituency, which in some circumstance may be undesirable.

It would be cool to publish the 'Trending petitions' history as open data

Proposal:

  • Add journaling per petition to record the signature count hourly
  • To keep it performant you could have daily rows with 24 columns, one for each hour
  • The signing rate could be easily calculated, just the difference between one hour's count and the previous count
  • We could then add this data to the existing json for each petition (eg https://petition.parliament.uk/petitions/124333.json)

This would let people see the signing history of petitions and make mashups where you could see trending petitions against events in the news

Sending emails with SMTP

Hey!

I've been trying to send emails with a different SMTP server compared to the usual mailcatcher. I've changed the usual config in the development.rb env config to remove the if statement and just have:

    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      address: ENV.fetch('SMTP_HOST'),
      port: ENV.fetch('SMTP_PORT'),
      username: ENV.fetch('SMTP_USERNAME'),
      password: ENV.fetch('SMTP_PASSWORD'),
      authentication: 'login',
      enable_starttls_auto: true
    }

All the variables have been written out in both .env.development and docker-compose.yml. However, when something happens that's meant to send an email nothing gets received. I've tested the SMTP details and everything and it works fine, just nothing is sending from here? Is it even possible to do this?

Help would be appreciated ๐Ÿ˜„

Update crown image

Is this a maintained project?

Hi,

They haven't been any move on that repo since a few years. Is this an up to date repo or has the dev moved elsewhere?

Explicitly state rate limits for API access

Hi!

Thanks for maintaining this project!

I'm receiving a 403 forbidden error while querying the petition.json files, which I believe is due to exceeding the rate limits for the website. I was querying for all 465 pages of the petition data available.

Could these rate limits be explicitly stated to ensure that such issues can be circumvented in future?

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.