-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from open-zaak/feature/remove-adfs
Feature/remove adfs
- Loading branch information
Showing
9 changed files
with
56 additions
and
112 deletions.
There are no files selected for viewing
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
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
59 changes: 5 additions & 54 deletions
59
src/nrc/accounts/migrations/0004_migrate_from_auth_adfs_db.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 |
---|---|---|
@@ -1,67 +1,18 @@ | ||
# Generated by Django 3.2.13 on 2022-06-21 06:41 | ||
|
||
import sys | ||
|
||
from django.db import migrations | ||
|
||
from django_auth_adfs.config import provider_config, settings as auth_adfs_settings | ||
from mozilla_django_oidc_db.forms import OpenIDConnectConfigForm | ||
|
||
|
||
def from_auth_adfs_to_mozilla_oidc(apps, schema_editor): | ||
ADFSConfig = apps.get_model("django_auth_adfs_db", "ADFSConfig") | ||
OpenIDConnectConfig = apps.get_model( | ||
"mozilla_django_oidc_db", "OpenIDConnectConfig" | ||
) | ||
|
||
adfs_config = ADFSConfig.objects.first() | ||
if adfs_config is None: | ||
return | ||
|
||
oidc_config = OpenIDConnectConfig.objects.first() | ||
if oidc_config and oidc_config.oidc_op_discovery_endpoint: | ||
print("Existing OIDC config found, not overwriting it.", file=sys.stderr) | ||
return | ||
elif oidc_config is None: | ||
oidc_config = OpenIDConnectConfig() | ||
|
||
config_url = f"https://{auth_adfs_settings.SERVER}/{auth_adfs_settings.TENANT_ID}/" | ||
provider_config.load_config() | ||
|
||
# copy configuration over | ||
form = OpenIDConnectConfigForm( | ||
instance=oidc_config, | ||
data={ | ||
"enabled": adfs_config.enabled, | ||
"oidc_rp_client_id": adfs_config.client_id, | ||
"oidc_rp_client_secret": adfs_config.client_secret, | ||
"oidc_rp_sign_algo": "RS256", | ||
"oidc_op_discovery_endpoint": config_url, | ||
"username_claim": adfs_config.username_claim, | ||
"claim_mapping": adfs_config.claim_mapping, | ||
"groups_claim": "roles", | ||
"sync_groups": adfs_config.sync_groups, | ||
"sync_groups_glob_pattern": "*", | ||
}, | ||
) | ||
|
||
if not form.is_valid(): | ||
print("Could not automatically migrate the ADFS config", file=sys.stderr) | ||
return | ||
|
||
form.save() | ||
adfs_config.enabled = False | ||
adfs_config.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
# migration is made no-op in the 1.6.x release series - on 1.4.x this copied | ||
# over the configuration from auth_adfs to mozilla_oidc. | ||
# This migration is kept for historical reasons to not mess with the migration | ||
# history of existing installs. See #1139 for more context. | ||
dependencies = [ | ||
("accounts", "0003_add_adfs_admin_index"), | ||
("django_auth_adfs_db", "0003_auto_20210323_1441"), | ||
("mozilla_django_oidc_db", "0008_auto_20220422_0849"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(from_auth_adfs_to_mozilla_oidc, migrations.RunPython.noop), | ||
] | ||
operations = [] |
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