italia / spid-cie-oidc-django

The SPID/CIE OIDC Federation SDK, written in Python
Apache License 2.0
27 stars 28 forks source link

Errors Installing spid-cie-oidc-django on Windows #286

Closed jaysea57 closed 10 months ago

jaysea57 commented 10 months ago

I am trying to install a spid/cie Openid Provider on my windows computer for developing and testing purposes. I want to develop a spid/cie Service Provider application, which for testing purposes needs to make requests towards such an Openid identity provider.

I tried following the instructions on https://github.com/italia/spid-cie-oidc-django/blob/main/docs/SETUP.md, choosing to create a new project instead of adding to an existent project. So I followed the instructions given after paragraph "Install Django Bootstrap italia template". These are some of the steps:

cp $project_name/settingslocal.py.example $project_name/settingslocal.py
then customize (optional) $project_name/settingslocal.py
./manage.py migrate
./manage.py loaddata dumps/example.json
./manage.py createsuperuser
./manage.py runserver 0.0.0.0:8000

The command "pip install "design-django-theme==v1.4.8"" was successful. I chose $project_name = "provider". The "manage.py migrate" was successful, but I get this error on the "manage.py loaddata dumps/example.json" command:

Traceback (most recent call last):
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\options.py", line 681, in get_field
    return self.fields_map[field_name]
KeyError: 'trust_mark_issuers'

During handling of the above exception, another exception occurred:

`Traceback (most recent call last):
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\json.py", line 70, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\python.py", line 141, in Deserializer
    field = Model._meta.get_field(field_name)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\options.py", line 683, in get_field
    raise FieldDoesNotExist(
django.core.exceptions.FieldDoesNotExist: FederationEntityConfiguration has no field named 'trust_mark_issuers'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\jayse\lavoro\auth_server\spid-cie-oidc-django\examples\provider\manage.py", line 22, in <module>
    main()
  File "C:\Users\jayse\lavoro\auth_server\spid-cie-oidc-django\examples\provider\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\loaddata.py", line 102, in handle
    self.loaddata(fixture_labels)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\loaddata.py", line 163, in loaddata
    self.load_label(fixture_label)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\loaddata.py", line 251, in load_label
    for obj in objects:
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\json.py", line 74, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture 'C:\Users\jayse\lavoro\auth_server\spid-cie-oidc-django\examples\provider\dumps\example.json':
go/examples/provider >

I would appreciate some help on this issue, and also I'd appreciate alternative suggestions for getting an Openid compliant identity provider running for the purpose of testing a SPID Service Provider using the Openid protocol (as opposed to the SAML protocol).

I have already tried installing the docker version described in https://github.com/italia/spid-cie-oidc-django#docker, but that also errors out.

rglauco commented 10 months ago

Hello, trust_mark_issuers changes was one of the most recent PR adopted. Did you cloned the repository as of today?

I've tried the same process in Windows right now and i have no problems in any step (screenshot attached). test-python-windows-oidc-django

jaysea57 commented 10 months ago

Hi, I cloned yesterday. I recloned today with: git clone https://github.com/italia/spid-cie-oidc-django.git This is the result:

go/examples/provider >cp provider/settingslocal.py.example provider/settingslocal.py
go/examples/provider >python ./manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions, spid_cie_oidc_accounts, spid_cie_oidc_authority, spid_cie_oidc_entity, spid_cie_oidc_provider
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying spid_cie_oidc_accounts.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying sessions.0001_initial... OK
  Applying spid_cie_oidc_accounts.0002_remove_user_taxpayer_id_user_attributes... OK
  Applying spid_cie_oidc_accounts.0003_alter_user_attributes... OK
  Applying spid_cie_oidc_entity.0001_initial... OK
  Applying spid_cie_oidc_authority.0001_initial... OK
  Applying spid_cie_oidc_authority.0002_alter_federationentityprofile_trust_mark_template... OK
  Applying spid_cie_oidc_authority.0003_alter_federationdescendantcontact_entity_and_more... OK
  Applying spid_cie_oidc_authority.0004_federationdescendant_jwks_and_more... OK
  Applying spid_cie_oidc_authority.0005_alter_federationdescendant_jwks... OK
  Applying spid_cie_oidc_authority.0006_stafftoken... OK
  Applying spid_cie_oidc_authority.0007_stafftoken_expire_at... OK
  Applying spid_cie_oidc_authority.0008_alter_stafftoken_token... OK
  Applying spid_cie_oidc_authority.0009_delete_stafftoken... OK
  Applying spid_cie_oidc_authority.0010_federationdescendant_metadata_and_more... OK
  Applying spid_cie_oidc_authority.0011_federationdescendant_issue_x509_and_more... OK
  Applying spid_cie_oidc_authority.0012_remove_federationdescendant_issue_x509... OK
  Applying spid_cie_oidc_entity.0002_fetchedentitystatement... OK
  Applying spid_cie_oidc_entity.0003_federationentityconfiguration_constraints... OK
  Applying spid_cie_oidc_entity.0004_alter_federationentityconfiguration_authority_hints_and_more... OK
  Applying spid_cie_oidc_entity.0005_alter_federationentityconfiguration_constraints... OK
  Applying spid_cie_oidc_entity.0006_remove_trustchain_resultant_metadata_and_more... OK
  Applying spid_cie_oidc_entity.0007_alter_trustchain_unique_together_and_more... OK
  Applying spid_cie_oidc_entity.0008_fetchedentitystatement_jwt... OK
  Applying spid_cie_oidc_entity.0009_trustchain_trust_marks_and_more... OK
  Applying spid_cie_oidc_entity.0010_federationentityconfiguration_entity_type... OK
  Applying spid_cie_oidc_entity.0011_alter_trustchain_status... OK
  Applying spid_cie_oidc_entity.0012_delete_publicjwk... OK
  Applying spid_cie_oidc_entity.0013_alter_federationentityconfiguration_metadata... OK
  Applying spid_cie_oidc_entity.0014_alter_trustchain_unique_together_and_more... OK
  Applying spid_cie_oidc_entity.0015_alter_trustchain_unique_together_trustchain_type_and_more... OK
  Applying spid_cie_oidc_entity.0016_alter_trustchain_unique_together_and_more... OK
  Applying spid_cie_oidc_entity.0017_remove_federationentityconfiguration_jwks_and_more... OK
  Applying spid_cie_oidc_entity.0018_trustchain_jwks... OK
  Applying spid_cie_oidc_entity.0019_stafftoken... OK
  Applying spid_cie_oidc_entity.0020_alter_federationentityconfiguration_jwks_core_and_more... OK
  Applying spid_cie_oidc_entity.0021_federationhistoricalkey_squashed_0026_alter_federationhistoricalkey_jwk... OK
  Applying spid_cie_oidc_entity.0027_alter_federationhistoricalkey_revocation_motivation... OK
  Applying spid_cie_oidc_entity.0028_federationentityconfiguration_issue_x509... OK
  Applying spid_cie_oidc_entity.0029_alter_federationentityconfiguration_entity_type_and_more... OK
  Applying spid_cie_oidc_entity.0030_remove_federationentityconfiguration_issue_x509... OK
  Applying spid_cie_oidc_provider.0001_initial... OK
  Applying spid_cie_oidc_provider.0002_remove_oidcsession_user_claims... OK
  Applying spid_cie_oidc_provider.0003_remove_oidcsession_sub_issuedtoken_expires_and_more... OK
  Applying spid_cie_oidc_provider.0004_alter_oidcsession_user... OK
  Applying spid_cie_oidc_provider.0005_oidcsession_sid... OK
  Applying spid_cie_oidc_provider.0006_oidcsession_acr... OK
  Applying spid_cie_oidc_provider.0007_alter_issuedtoken_options_alter_oidcsession_options... OK
go/examples/provider >
go/examples/provider >
go/examples/provider >
go/examples/provider >python ./manage.py loaddata dumps/example.json
Traceback (most recent call last):
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\options.py", line 681, in get_field
    return self.fields_map[field_name]
KeyError: 'trust_mark_issuers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\json.py", line 70, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\python.py", line 141, in Deserializer
    field = Model._meta.get_field(field_name)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\options.py", line 683, in get_field
    raise FieldDoesNotExist(
django.core.exceptions.FieldDoesNotExist: FederationEntityConfiguration has no field named 'trust_mark_issuers'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\jayse\lavoro\auth_server\spid-cie-oidc-django\examples\provider\manage.py", line 22, in <module>
    main()
  File "C:\Users\jayse\lavoro\auth_server\spid-cie-oidc-django\examples\provider\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\loaddata.py", line 102, in handle
    self.loaddata(fixture_labels)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\loaddata.py", line 163, in loaddata
    self.load_label(fixture_label)
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\loaddata.py", line 251, in load_label
    for obj in objects:
  File "C:\Users\jayse\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\json.py", line 74, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture 'C:\Users\jayse\lavoro\auth_server\spid-cie-oidc-django\examples\provider\dumps\example.json':
go/examples/provider >

So the error remains the same

Any help appreciated J

rglauco commented 10 months ago

Comparing the two outputs it seems you don't have 2 last migrations: spid_cie_oidc_authority.0013 spid_cie_oidc_entity.0031 Can you find the migration files within the project folders ./spid_cie_oidc/authority/migrations/ and ./spid_cie_oidc/entity/migrations/?

jaysea57 commented 10 months ago

Hi, I've now managed to get it working.

Previously I had not done the following steps from https://github.com/italia/spid-cie-oidc-django/blob/main/docs/SETUP.md, because I thought that they were not needed for the example applications, but Giuseppe told me to do them:

virtualenv -p python3 env
source env/bin/activate

and also I hadn't done this:

pip install -e .

So I tried all from scratch: a new git clone, new installation steps.

This time the step:

./manage.py loaddata dumps/example.json Did not give any errors, and I was able to successfully start the "federation_authority" example application.

I was also able to do a "SPID Login", using "spid-cie-oidc-java" github demo application for OIDC Relying parties.

jaysea57 commented 10 months ago

So am closing this issue. Thanks to Giuseppe and Glauco for their help