Skip to content

2.0.0: Client Secret Hasher Migration vs. Swapped Application Models #1146

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

Closed
2 tasks done
josephabrahams opened this issue Apr 27, 2022 · 3 comments · Fixed by #1147
Closed
2 tasks done

2.0.0: Client Secret Hasher Migration vs. Swapped Application Models #1146

josephabrahams opened this issue Apr 27, 2022 · 3 comments · Fixed by #1147
Labels
Milestone

Comments

@josephabrahams
Copy link
Member

Describe the bug

The forward migration introduced in #1093 to hash all previously saved client secrets runs on apps that use a custom application model and produces the following error:

AttributeError: Manager isn't available; 'oauth2_provider.Application' has been swapped for 'oauth.Application'

To Reproduce

Define a custom application model in settings.py:

OAUTH2_PROVIDER_APPLICATION_MODEL = "oauth.Application"

Migrate the database:

$ python manage.py migrate

Expected behavior

Migrations run when using a swappable application model without throwing an error.

Version 2.0

  • I have tested with the latest published release and it's still a problem.
  • I have tested with the master branch and it's still a problem.
@josephabrahams
Copy link
Member Author

Potential fix to only run the migration when not using a custom application model in josephabrahams@a123285.

@n2ygk
Copy link
Member

n2ygk commented Apr 27, 2022

@josephabrahams Thanks for this report. Swappable models are the hardest part with this stuff!

Please submit your proposed fix as a PR where we can discuss.

Thanks.

@n2ygk n2ygk added this to the 2.0.1 milestone Apr 27, 2022
@n2ygk n2ygk pinned this issue Apr 27, 2022
@n2ygk n2ygk changed the title Client Secret Hasher Migration Runs on Swapped Application Models 2.0.0: Client Secret Hasher Migration vs. Swapped Application Models Apr 27, 2022
@n2ygk
Copy link
Member

n2ygk commented May 27, 2022

I've been staring at this and I'm thinking the change should simply be:

from oauth2_provider import settings

# ...

    Application = apps.get_model(settings.APPLICATION_MODEL)

Furthermore all the migrations may need to be fixed for swappable models. See #634 where all hope is lost ;-(

@n2ygk n2ygk modified the milestones: 2.0.1, 2.1.0 Jun 3, 2022
@n2ygk n2ygk unpinned this issue Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants