Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ Víðir Valberg Guðmundsson
Will Beaufoy
pySilver
Łukasz Skarżyński
Yuri Savin
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### WARNING
* If you are going to revert migration 0006 make note that previously hashed client_secret cannot be reverted

### Added
* #1185 Add middleware for adding access token to request
* #1273 Add caching of loading of OIDC private key.
Expand All @@ -24,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- ### Fixed
* #1284 Allow to logout whith no id_token_hint even if the browser session already expired
* #1296 Added reverse function in migration 0006_alter_application_client_secret

## [2.3.0] 2023-05-31

Expand Down
17 changes: 15 additions & 2 deletions oauth2_provider/migrations/0006_alter_application_client_secret.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import logging

from django.db import migrations
from oauth2_provider import settings

import oauth2_provider.generators
import oauth2_provider.models
from oauth2_provider import settings


logger = logging.getLogger()


def forwards_func(apps, schema_editor):
Expand All @@ -14,6 +20,13 @@ def forwards_func(apps, schema_editor):
application.save(update_fields=['client_secret'])


def reverse_func(apps, schema_editor):
warning_color_code = "\033[93m"
end_color_code = "\033[0m"
msg = f"\n{warning_color_code}The previously hashed client_secret cannot be reverted, and it remains hashed{end_color_code}"
logger.warning(msg)


class Migration(migrations.Migration):

dependencies = [
Expand All @@ -26,5 +39,5 @@ class Migration(migrations.Migration):
name='client_secret',
field=oauth2_provider.models.ClientSecretField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, help_text='Hashed on Save. Copy it now if this is a new secret.', max_length=255),
),
migrations.RunPython(forwards_func),
migrations.RunPython(forwards_func, reverse_func),
]