Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
208eb28
Bump flask from 2.0.2 to 2.0.3 (#2136)
dependabot[bot] Feb 15, 2022
a6bcb75
Bump @alephdata/followthemoney from 2.8.2 to 2.8.3 in /ui (#2142)
dependabot[bot] Feb 24, 2022
d0101a6
Bump followthemoney from 2.8.2 to 2.8.3 (#2141)
dependabot[bot] Feb 24, 2022
55f5163
Bump servicelayer[amazon,google] from 1.18.2 to 1.19.0 (#2143)
dependabot[bot] Feb 24, 2022
e2581e9
Set the node-sass version to 6.0.1 until we can start using dart inst…
Rosencrantz Mar 1, 2022
8068693
Bump normality from 2.2.5 to 2.3.1 (#2153)
dependabot[bot] Mar 14, 2022
78e7532
Bump sqlalchemy from 1.4.31 to 1.4.32 (#2148)
dependabot[bot] Mar 14, 2022
0471ff2
Merge branch 'main' of github.com:alephdata/aleph into develop
sunu Mar 15, 2022
22bdf4c
Fix search handler on home screen
tillprochaska Mar 9, 2022
2882e81
Bump followthemoney from 2.8.3 to 2.8.5 (#2166)
dependabot[bot] Mar 17, 2022
81cfe94
Bump urllib3 from 1.26.8 to 1.26.9 (#2165)
dependabot[bot] Mar 17, 2022
ba89bbc
Bump alembic from 1.7.6 to 1.7.7 (#2161)
dependabot[bot] Mar 17, 2022
1217bc8
Bump @alephdata/followthemoney from 2.8.3 to 2.8.4 in /ui (#2151)
dependabot[bot] Mar 17, 2022
0b04846
Add French translations into Aleph
Rosencrantz Mar 24, 2022
d9cc638
Fix helm build
Rosencrantz Mar 24, 2022
7420532
Fix up merge conflict
Rosencrantz Mar 28, 2022
d121c19
Bump @blueprintjs/core from 3.52.0 to 3.54.0 in /ui (#2172)
dependabot[bot] Apr 4, 2022
9900424
Bump @formatjs/intl-relativetimeformat from 9.5.2 to 10.0.1 in /ui (#…
dependabot[bot] Apr 4, 2022
bea6cb3
Bump @blueprintjs/select from 3.18.11 to 3.19.1 in /ui (#2181)
dependabot[bot] Apr 4, 2022
4deea2d
Bump flask-talisman from 0.8.1 to 1.0.0 (#2167)
dependabot[bot] Apr 4, 2022
bdc897e
Bump @alephdata/followthemoney from 2.8.4 to 2.9.0 in /ui (#2197)
dependabot[bot] Apr 4, 2022
1c358e6
Bump normality from 2.3.1 to 2.3.2 (#2177)
dependabot[bot] Apr 4, 2022
52ccc85
Bump followthemoney from 2.8.5 to 2.9.0 (#2186)
dependabot[bot] Apr 4, 2022
a1e3f6a
Fixed Gunicorn worker timout issue (#2226)
PitaHat Apr 23, 2022
5b3ee51
Remove ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl (#2242)
msmych May 3, 2022
6003afd
Bump followthemoney from 2.9.0 to 2.9.1 (#2221)
dependabot[bot] May 6, 2022
9fa9b20
Bump normality from 2.3.2 to 2.3.3 (#2212)
dependabot[bot] May 6, 2022
76d4051
Bump @alephdata/followthemoney from 2.9.0 to 2.9.1 in /ui (#2230)
dependabot[bot] May 6, 2022
07907d0
Bump jsonschema from 4.4.0 to 4.5.1 (#2258)
dependabot[bot] May 6, 2022
5703f8a
Bump file-selector from 0.2.4 to 0.6.0 in /ui (#2253)
dependabot[bot] May 6, 2022
4b99381
Bump sqlalchemy from 1.4.32 to 1.4.36 (#2240)
dependabot[bot] May 6, 2022
e6bdfd2
Update cryptography requirement (#2241)
dependabot[bot] May 6, 2022
7100ab1
Bump apispec from 5.1.1 to 5.2.1 (#2247)
dependabot[bot] May 9, 2022
faeffe9
Add config file examples for traefik/keycloak/minio setup (#2260)
catskillmarina May 10, 2022
b63b06e
Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS (#2246)
msmych May 10, 2022
46d85ad
Bump followthemoney from 2.9.1 to 2.9.2 (#2267)
dependabot[bot] May 11, 2022
ddd61f1
Bump the FtM version, should fix trips (#2279)
Rosencrantz May 18, 2022
41af2ef
Bump apispec from 5.2.1 to 5.2.2 (#2272)
dependabot[bot] May 23, 2022
cbe5cf2
Bump babel from 2.9.1 to 2.10.1 (#2224)
dependabot[bot] May 23, 2022
3259e0c
Concatenate error messages for the same path (#2273)
msmych May 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions aleph.env.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ ALEPH_UI_URL=http://localhost:8080/
# ALEPH_FAVICON=https://investigativedashboard.org/static/favicon.ico
# ALEPH_LOGO=http://assets.pudo.org/img/logo_bigger.png

# Other customisations
ALEPH_SAMPLE_SEARCHES=Vladimir Putin:TeliaSonera

# Set email addresses, separated by colons, that will be made admin.
# ALEPH_ADMINS=friedrich@pudo.org:demo@pudo.org

Expand Down
12 changes: 2 additions & 10 deletions aleph/model/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ def by_api_key(cls, api_key):
return q.first()

@classmethod
def load_or_create(cls, foreign_id, type_, name, email=None, is_admin=None):
def load_or_create(cls, foreign_id, type_, name, email=None, is_admin=False):
role = cls.by_foreign_id(foreign_id)

if role is None:
role = cls()
role.foreign_id = foreign_id
role.name = name or email
role.type = type_
role.is_admin = False
role.is_admin = is_admin
role.is_muted = False
role.is_tester = False
role.is_blocked = False
Expand All @@ -197,14 +197,6 @@ def load_or_create(cls, foreign_id, type_, name, email=None, is_admin=None):
if email is not None:
role.email = email

if is_admin is not None:
role.is_admin = is_admin

# see: https://github.com/alephdata/aleph/issues/111
auto_admins = [a.lower() for a in settings.ADMINS]
if email is not None and email.lower() in auto_admins:
role.is_admin = True

db.session.add(role)
db.session.flush()
return role
Expand Down
4 changes: 2 additions & 2 deletions aleph/oauth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from pprint import pformat # noqa
from authlib.jose import JsonWebToken, JsonWebKey
from authlib.integrations.flask_client import OAuth
from authlib.jose.errors import DecodeError

from aleph import settings
from aleph.util import is_auto_admin

oauth = OAuth()
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -92,7 +92,7 @@ def handle_oauth(provider, oauth_token):
role.foreign_id = role_id
role.update({"name": name})
if role is None:
role = Role.load_or_create(role_id, Role.USER, name, email=email)
role = Role.load_or_create(role_id, Role.USER, name, email=email, is_admin=is_auto_admin(email))
if not role.is_actor:
return None
role.clear_roles()
Expand Down
27 changes: 26 additions & 1 deletion aleph/tests/test_view_util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import json

from lxml.html import document_fromstring
from werkzeug.exceptions import BadRequest

from aleph.logic.html import sanitize_html
from aleph.views.util import get_url_path
from aleph.views.util import get_url_path, validate
from aleph.tests.util import TestCase


Expand Down Expand Up @@ -32,3 +35,25 @@ def test_sanitize_html(self):
assert attr == "https://example.org/blockchain", html
assert html.find(".//a").get("target") == "_blank", html
assert "nofollow" in html.find(".//a").get("rel"), html

def test_validate_returns_errors_for_paths(self):
# given
schema = "RoleCreate" # name min length 4, password min length 6
data = json.loads('{"name":"Bob","password":"1234","code":"token"}')

# then
with self.assertRaises(BadRequest) as ctx:
validate(data, schema)

self.assertEqual(ctx.exception.response.get_json().get("errors"), {"name": "'Bob' is too short", "password": "'1234' is too short"})

def test_validate_concatenates_multiple_errors_for_the_same_path(self):
# given
schema = "RoleCreate" # requires password and code
data = json.loads('{"wrong":"No password, no code"}')

# then
with self.assertRaises(BadRequest) as ctx:
validate(data, schema)

self.assertEqual(ctx.exception.response.get_json().get("errors"), {"": "'password' is a required property; 'code' is a required property"})
4 changes: 4 additions & 0 deletions aleph/translations/bs/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: Tajna Biscevic <tajna@occrp.org>, 2019\n"
"Language-Team: Bosnian (https://www.transifex.com/aleph/teams/76591/bs/)\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/de/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: pudo <friedrich@pudo.org>, 2020\n"
"Language-Team: German (https://www.transifex.com/aleph/teams/76591/de/)\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/es/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: Nathan Jaccard <nathan@occrp.org>, 2020\n"
"Language-Team: Spanish (https://www.transifex.com/aleph/teams/76591/es/)\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/fr/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: Jean-Philippe Menotti, 2022\n"
"Language-Team: French (https://www.transifex.com/aleph/teams/76591/fr/)\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/pt_BR/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: Laura M <kokoroko2@protonmail.com>, 2019\n"
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/aleph/teams/76591/pt_BR/)\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/ru/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: jen occrp, 2021\n"
"Language-Team: Russian (https://www.transifex.com/aleph/teams/76591/ru/)\n"
Expand Down
4 changes: 4 additions & 0 deletions aleph/translations/tr/LC_MESSAGES/aleph.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-03-24 13:21+0100\n"
=======
"POT-Creation-Date: 2022-03-28 10:50+0200\n"
>>>>>>> main
"PO-Revision-Date: 2018-03-15 07:37+0000\n"
"Last-Translator: Pinar Dag <pinar.dag@dagmedya.com>, 2018\n"
"Language-Team: Turkish (https://www.transifex.com/aleph/teams/76591/tr/)\n"
Expand Down
5 changes: 5 additions & 0 deletions aleph/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import structlog
from aleph import settings
from datetime import datetime, date
from normality import stringify
from flask_babel.speaklater import LazyString
Expand Down Expand Up @@ -82,3 +83,7 @@ def perform_request(self, method, url, headers=None, params=None, body=None):
del payload["es_req_body"]
log.debug("Performed ES request", **payload)
return result

def is_auto_admin(email):
auto_admins = [a.lower() for a in settings.ADMINS]
return email is not None and email.lower() in auto_admins
3 changes: 2 additions & 1 deletion aleph/views/roles_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from aleph.search import QueryParser, DatabaseQueryResult
from aleph.model import Role
from aleph.logic.roles import challenge_role, update_role, create_user, get_deep_role
from aleph.util import is_auto_admin
from aleph.views.serializers import RoleSerializer
from aleph.views.util import require, jsonify, parse_request, obj_or_404
from aleph.views.context import tag_request
Expand Down Expand Up @@ -146,7 +147,7 @@ def create():
status=409,
)

role = create_user(email, data.get("name"), data.get("password"))
role = create_user(email, data.get("name"), data.get("password"), is_admin=is_auto_admin(email))
# Let the serializer return more info about this user
request.authz = Authz.from_role(role)
tag_request(role_id=role.id)
Expand Down
6 changes: 4 additions & 2 deletions aleph/views/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ def parse_request(schema):
def validate(data, schema):
"""Validate the data inside a request against a schema."""
validator = get_validator(schema)
# data = clean_object(data)
errors = {}
for error in validator.iter_errors(data):
path = ".".join((str(c) for c in error.path))
errors[path] = error.message
if path not in errors:
errors[path] = error.message
else:
errors[path] += '; ' + error.message
log.info("ERROR [%s]: %s", path, error.message)

if not len(errors):
Expand Down
14 changes: 14 additions & 0 deletions contrib/aleph-traefik-minio-keycloak/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
build
ui
helm
aleph.env
aleph.egg-info
docker-compose.*
celerybeat-schedul*
contrib/allCountries.zip
.git
.vscode
.github
.travis.yml
.env
.tx
107 changes: 107 additions & 0 deletions contrib/aleph-traefik-minio-keycloak/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
*.pyc
*.DS_Store
.DS_Store
*.sqlite3
__pycache__
balkhashdb

TODO.md

build*

ui/node_modules
ui/build
ui/package-lock.json
ui/i18n/messages.json
ui/i18n/messages.pot
ui/**/*.css

services/elasticsearch/secrets

celerybeat-schedule*
aleph.env
test_settings.py
.coverage

npm-debug.log*
.idea/
ui/.idea/
node_modules/*
.eslintcache

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
.vscode/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
22 changes: 22 additions & 0 deletions contrib/aleph-traefik-minio-keycloak/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2014-2015 Friedrich Lindenberg
Copyright (c) 2016-2020 Journalism Development Network, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading