-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/peace-corpora
- Loading branch information
Showing
67 changed files
with
1,036 additions
and
800 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
name: Bug report | ||
description: Let us know that something isn't working right | ||
labels: | ||
- bug | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thank you for making a bug report! Please fill in this information so we can get to the | ||
bottom of your issue. | ||
- type: textarea | ||
id: what-happened | ||
attributes: | ||
label: What went wrong? | ||
description: Please describe what happened. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: expected | ||
attributes: | ||
label: What did you expect to happen? | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: screenshot | ||
attributes: | ||
label: Screenshot | ||
description: If you can make a screenshot of the issue, please include it! | ||
validations: | ||
required: false | ||
- type: checkboxes | ||
id: instance | ||
attributes: | ||
label: Where did you find the bug? | ||
description: Please add where you found the bug. | ||
options: | ||
- label: https://ianalyzer.hum.uu.nl | ||
- label: https://peopleandparliament.hum.uu.nl | ||
- label: https://peace.sites.uu.nl | ||
- label: a server hosted elsewhere (i.e. not by the research software lab) | ||
- label: a local server | ||
validations: | ||
required: true | ||
- type: input | ||
id: version | ||
attributes: | ||
label: Version | ||
description: | | ||
For third-party and local servers, please add information about the version of the | ||
software, if you know it. A version number (e.g "1.2.3") is great. For a pre-release | ||
build, you can provide the branch or commit hash. | ||
validations: | ||
required: false | ||
- type: textarea | ||
id: to-reproduce | ||
attributes: | ||
label: Steps to reproduce | ||
description: | | ||
How can a developer replicate the issue? Please provide any information you can. For | ||
example: "I went to | ||
https://ianalyzer.hum.uu.nl/search/troonredes?date=1814-01-01:1972-01-01 and then | ||
clicked on Download CSV. I pressed cancel and then I clicked Download CSV again." | ||
validations: | ||
required: true | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,3 +171,5 @@ | |
'url': [('https://dig.hum.uu.nl', 'en')], | ||
}, | ||
} | ||
|
||
SAML_GROUP_NAME = 'uu' |
17 changes: 17 additions & 0 deletions
17
backend/tag/migrations/0003_taggeddocument_unique_document_id_for_corpus.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.1.9 on 2023-08-10 10:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tag', '0002_taggeddocument_delete_taginstance'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddConstraint( | ||
model_name='taggeddocument', | ||
constraint=models.UniqueConstraint(fields=('corpus', 'doc_id'), name='unique_document_ID_for_corpus'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.db import migrations | ||
from users.saml import saml_user_group | ||
|
||
def add_saml_users_to_group(apps, schema_editor): | ||
CustomUser = apps.get_model('users', 'CustomUser') | ||
|
||
saml_users = CustomUser.objects.filter(saml = True) | ||
saml_group = saml_user_group() | ||
|
||
if saml_group: | ||
for user in saml_users: | ||
user.groups.add(saml_group.id) | ||
user.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('users', '0004_userprofile'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
add_saml_users_to_group, | ||
reverse_code=migrations.RunPython.noop | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
from djangosaml2.backends import Saml2Backend | ||
from django.contrib.auth.models import Group | ||
from django.conf import settings | ||
|
||
class CustomSaml2Backend(Saml2Backend): | ||
def get_or_create_user(self, *args, **kwargs): | ||
user, created = super().get_or_create_user(*args, **kwargs) | ||
user.saml = True | ||
|
||
saml_group = saml_user_group() | ||
if saml_group: | ||
user.groups.add(saml_group) | ||
|
||
return user, created | ||
|
||
def saml_user_group(): | ||
group_name = getattr(settings, 'SAML_GROUP_NAME', None) | ||
if group_name: | ||
group, _ = Group.objects.get_or_create(name=group_name) | ||
return group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
# SAML | ||
|
||
In order to login with Solis ID, I-analyzer has SAML integration with ITS. For this, it uses the [djangosaml2 library](https://djangosaml2.readthedocs.io/). More information on working with SAML, setting up a local environment to test the SAML integration, etc. can be found [here](https://github.com/UUDigitalHumanitieslab/dh-info/blob/master/SAML.md) | ||
|
||
The urls exposed by DjangoSaml2 are included as part of our `users` application, e.g., `<hostname>/users/saml2/login`. DjangoSaml2 takes care of consuming the response from the Identity Provider and logging in the user. The `SAML_ATTRIBUTE_MAPPING` variable contains a dictionary of the data coming in from the identity provider, e.g., `uushortid`, and translating that to the corresponding column in the user table, e.g., `username`. Moreover, the setting `SAML_CREATE_UNKNOWN_USER = True` makes sure that we create a user in our database if it's not present yet. | ||
|
||
The only tweaks added on top of the DjangoSaml2 package are: | ||
- the logic to set the `saml` column to `True` for a user logging in with SAML. The `CustomSaml2Backend` overrides DjangoSaml2's `get_or_create_user` function to take care of this. Note that in the future, we could also turn this field into a `CharField` to keep track of multiple identity providers here. | ||
- overriding DjangoSaml2's `LogoutView` to make its `post` method `csrf_exempt`. The response from the ITS Identity Provider does not send the csrf cookie in a way that it can be consumed by Django at the moment. | ||
|
||
### Authorisation | ||
|
||
If you define a `SAML_GROUP_NAME` in settings, SAML users will always be added to a group with that name when they create an account. (The group will be created if it does not exist.) This can be used to give permissions to SAML users. The group is not used to handle authentication, so you can add non-SAML users to it as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.