-
Notifications
You must be signed in to change notification settings - Fork 286
Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS #2246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @msmych, it looks good to me from a quick look. I have added a nit pick. Let me know what you think
aleph/settings.py
Outdated
@@ -64,6 +64,10 @@ | |||
# Assumes a comma-separated list. | |||
ADMINS = env.to_list("ALEPH_ADMINS") | |||
|
|||
def is_admin(email): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this to logic/roles.py
and rename it to something like is_auto_admin
to be more explicit. We try not to put app logic in settings directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit tricky — this causes circular dependency in imports: aleph.core → aleph.oauth → core.logic.roles → aleph.core
I think the right solution would be splitting aleph.core
into core that would provide things like db
and cache
that would be imported in different components, and aleph.app
that will only import everything needed to start the app.
For now moved is_auto_admin
to aleph.util
Updated and commented |
@sunu Are you happy with this now? |
* Bump flask from 2.0.2 to 2.0.3 (#2136) Bumps [flask](https://github.com/pallets/flask) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](pallets/flask@2.0.2...2.0.3) --- updated-dependencies: - dependency-name: flask dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.8.2 to 2.8.3 in /ui (#2142) * Bump followthemoney from 2.8.2 to 2.8.3 (#2141) * Bump servicelayer[amazon,google] from 1.18.2 to 1.19.0 (#2143) * Set the node-sass version to 6.0.1 until we can start using dart instead (#2145) * Bump normality from 2.2.5 to 2.3.1 (#2153) * Bump sqlalchemy from 1.4.31 to 1.4.32 (#2148) * Fix search handler on home screen The `HomeScreen` component needs to be wrapped in the `withRouter` HOC in order to have access to the `navigate` prop. * Bump followthemoney from 2.8.3 to 2.8.5 (#2166) * Bump urllib3 from 1.26.8 to 1.26.9 (#2165) * Bump alembic from 1.7.6 to 1.7.7 (#2161) * Bump @alephdata/followthemoney from 2.8.3 to 2.8.4 in /ui (#2151) * Add French translations into Aleph * Fix helm build following recommendation and switching from using @master to @v0 * Bump @blueprintjs/core from 3.52.0 to 3.54.0 in /ui (#2172) * Bump @formatjs/intl-relativetimeformat from 9.5.2 to 10.0.1 in /ui (#2184) * Bump @blueprintjs/select from 3.18.11 to 3.19.1 in /ui (#2181) * Bump flask-talisman from 0.8.1 to 1.0.0 (#2167) * Bump @alephdata/followthemoney from 2.8.4 to 2.9.0 in /ui (#2197) * Bump normality from 2.3.1 to 2.3.2 (#2177) * Bump followthemoney from 2.8.5 to 2.9.0 (#2186) * Fixed Gunicorn worker timout issue (#2226) Co-authored-by: Grypus <grypus@Grypus.local> * Remove ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl (#2242) * Remove ALEPH_APP_TITLE and ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl * ALEPH_APP_TITLE back Co-authored-by: Matvey <realsmych@gmail.com> * Bump followthemoney from 2.9.0 to 2.9.1 (#2221) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump normality from 2.3.2 to 2.3.3 (#2212) Bumps [normality](https://github.com/pudo/normality) from 2.3.2 to 2.3.3. - [Release notes](https://github.com/pudo/normality/releases) - [Commits](pudo/normality@2.3.2...2.3.3) --- updated-dependencies: - dependency-name: normality dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.9.0 to 2.9.1 in /ui (#2230) Bumps [@alephdata/followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: "@alephdata/followthemoney" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jsonschema from 4.4.0 to 4.5.1 (#2258) Bumps [jsonschema](https://github.com/python-jsonschema/jsonschema) from 4.4.0 to 4.5.1. - [Release notes](https://github.com/python-jsonschema/jsonschema/releases) - [Changelog](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst) - [Commits](python-jsonschema/jsonschema@v4.4.0...v4.5.1) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump file-selector from 0.2.4 to 0.6.0 in /ui (#2253) Bumps [file-selector](https://github.com/react-dropzone/file-selector) from 0.2.4 to 0.6.0. - [Release notes](https://github.com/react-dropzone/file-selector/releases) - [Commits](react-dropzone/file-selector@v0.2.4...v0.6.0) --- updated-dependencies: - dependency-name: file-selector dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump sqlalchemy from 1.4.32 to 1.4.36 (#2240) Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.4.32 to 1.4.36. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update cryptography requirement (#2241) Updates the requirements on [cryptography](https://github.com/pyca/cryptography) to permit the latest version. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](pyca/cryptography@36.0.0...37.0.0) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump apispec from 5.1.1 to 5.2.1 (#2247) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.1.1 to 5.2.1. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.1.1...5.2.1) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add config file examples for traefik/keycloak/minio setup (#2260) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS (#2246) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS * Move is_auto_admin to aleph.util * Add newline Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Tarashish Mishra <sunu@users.noreply.github.com> * Bump followthemoney from 2.9.1 to 2.9.2 (#2267) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.1 to 2.9.2. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.1...v2.9.2) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the FtM version, should fix trips (#2279) * Bump apispec from 5.2.1 to 5.2.2 (#2272) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.2.1...5.2.2) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump babel from 2.9.1 to 2.10.1 (#2224) Bumps [babel](https://github.com/python-babel/babel) from 2.9.1 to 2.10.1. - [Release notes](https://github.com/python-babel/babel/releases) - [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES.rst) - [Commits](python-babel/babel@v2.9.1...v2.10.1) --- updated-dependencies: - dependency-name: babel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Concatenate error messages for the same path (#2273) * Concatenate error messages for the same path * Simplify tests Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Steve Haffenden <steve.haffenden@gmail.com> Co-authored-by: Till Prochaska <mail@tillprochaska.de> Co-authored-by: PitaHat <79198460+PitaHat@users.noreply.github.com> Co-authored-by: Grypus <grypus@Grypus.local> Co-authored-by: Matvey Smychkov <msmych@yandex.com> Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Marina Brown <catskillmarina@gmail.com>
* Bump flask from 2.0.2 to 2.0.3 (#2136) Bumps [flask](https://github.com/pallets/flask) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](pallets/flask@2.0.2...2.0.3) --- updated-dependencies: - dependency-name: flask dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.8.2 to 2.8.3 in /ui (#2142) * Bump followthemoney from 2.8.2 to 2.8.3 (#2141) * Bump servicelayer[amazon,google] from 1.18.2 to 1.19.0 (#2143) * Set the node-sass version to 6.0.1 until we can start using dart instead (#2145) * Bump normality from 2.2.5 to 2.3.1 (#2153) * Bump sqlalchemy from 1.4.31 to 1.4.32 (#2148) * Fix search handler on home screen The `HomeScreen` component needs to be wrapped in the `withRouter` HOC in order to have access to the `navigate` prop. * Bump followthemoney from 2.8.3 to 2.8.5 (#2166) * Bump urllib3 from 1.26.8 to 1.26.9 (#2165) * Bump alembic from 1.7.6 to 1.7.7 (#2161) * Bump @alephdata/followthemoney from 2.8.3 to 2.8.4 in /ui (#2151) * Add French translations into Aleph * Fix helm build following recommendation and switching from using @master to @v0 * Bump @blueprintjs/core from 3.52.0 to 3.54.0 in /ui (#2172) * Bump @formatjs/intl-relativetimeformat from 9.5.2 to 10.0.1 in /ui (#2184) * Bump @blueprintjs/select from 3.18.11 to 3.19.1 in /ui (#2181) * Bump flask-talisman from 0.8.1 to 1.0.0 (#2167) * Bump @alephdata/followthemoney from 2.8.4 to 2.9.0 in /ui (#2197) * Bump normality from 2.3.1 to 2.3.2 (#2177) * Bump followthemoney from 2.8.5 to 2.9.0 (#2186) * Fixed Gunicorn worker timout issue (#2226) Co-authored-by: Grypus <grypus@Grypus.local> * Remove ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl (#2242) * Remove ALEPH_APP_TITLE and ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl * ALEPH_APP_TITLE back Co-authored-by: Matvey <realsmych@gmail.com> * Bump followthemoney from 2.9.0 to 2.9.1 (#2221) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump normality from 2.3.2 to 2.3.3 (#2212) Bumps [normality](https://github.com/pudo/normality) from 2.3.2 to 2.3.3. - [Release notes](https://github.com/pudo/normality/releases) - [Commits](pudo/normality@2.3.2...2.3.3) --- updated-dependencies: - dependency-name: normality dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.9.0 to 2.9.1 in /ui (#2230) Bumps [@alephdata/followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: "@alephdata/followthemoney" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jsonschema from 4.4.0 to 4.5.1 (#2258) Bumps [jsonschema](https://github.com/python-jsonschema/jsonschema) from 4.4.0 to 4.5.1. - [Release notes](https://github.com/python-jsonschema/jsonschema/releases) - [Changelog](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst) - [Commits](python-jsonschema/jsonschema@v4.4.0...v4.5.1) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump file-selector from 0.2.4 to 0.6.0 in /ui (#2253) Bumps [file-selector](https://github.com/react-dropzone/file-selector) from 0.2.4 to 0.6.0. - [Release notes](https://github.com/react-dropzone/file-selector/releases) - [Commits](react-dropzone/file-selector@v0.2.4...v0.6.0) --- updated-dependencies: - dependency-name: file-selector dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump sqlalchemy from 1.4.32 to 1.4.36 (#2240) Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.4.32 to 1.4.36. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update cryptography requirement (#2241) Updates the requirements on [cryptography](https://github.com/pyca/cryptography) to permit the latest version. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](pyca/cryptography@36.0.0...37.0.0) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump apispec from 5.1.1 to 5.2.1 (#2247) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.1.1 to 5.2.1. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.1.1...5.2.1) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add config file examples for traefik/keycloak/minio setup (#2260) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS (#2246) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS * Move is_auto_admin to aleph.util * Add newline Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Tarashish Mishra <sunu@users.noreply.github.com> * Bump followthemoney from 2.9.1 to 2.9.2 (#2267) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.1 to 2.9.2. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.1...v2.9.2) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the FtM version, should fix trips (#2279) * Bump apispec from 5.2.1 to 5.2.2 (#2272) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.2.1...5.2.2) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump babel from 2.9.1 to 2.10.1 (#2224) Bumps [babel](https://github.com/python-babel/babel) from 2.9.1 to 2.10.1. - [Release notes](https://github.com/python-babel/babel/releases) - [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES.rst) - [Commits](python-babel/babel@v2.9.1...v2.10.1) --- updated-dependencies: - dependency-name: babel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Concatenate error messages for the same path (#2273) * Concatenate error messages for the same path * Simplify tests Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tarashish Mishra <sunu0000@gmail.com> Co-authored-by: Till Prochaska <mail@tillprochaska.de> Co-authored-by: PitaHat <79198460+PitaHat@users.noreply.github.com> Co-authored-by: Grypus <grypus@Grypus.local> Co-authored-by: Matvey Smychkov <msmych@yandex.com> Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Marina Brown <catskillmarina@gmail.com> Co-authored-by: Tarashish Mishra <sunu@users.noreply.github.com>
Role#load_or_create()
tosettings#is_admin()
. Not sure if functions are allowed/welcome there, otherwise it can be moved to a more appropriate place. Reason for extraction: not to mix persistence logic with business logic, especially when there's alreadyis_admin
param available.is_admin
param default value fromNone
toFalse
, movedrole.is_admin
assignment to role creation blockis_admin
param from API and OAuth