Skip to content
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

Configuration error #5

Open
AlexMorra opened this issue Sep 20, 2024 · 10 comments
Open

Configuration error #5

AlexMorra opened this issue Sep 20, 2024 · 10 comments

Comments

@AlexMorra
Copy link

According to the introduction section, an error occurs when launching the application (make run):

image

But if you import BackendAuthentication, RefreshAuthentication directly into the simple_jwt method, it will start.

dependencies:
python=3.11
uvicorn=0.30.6
esmerald=3.4.1
esmerald-simple-jwt=0.2.0

@tarsil
Copy link
Contributor

tarsil commented Sep 20, 2024

@AlexMorra thank you for reporting this. I find this odd. In your make run, are you exposing the ESMERALD_MODULE_SETTINGS to the Dev one?

@tarsil
Copy link
Contributor

tarsil commented Sep 20, 2024

Can you provide more details how you setup your configs here, please? Just to replicate and address this.

@AlexMorra
Copy link
Author

Yes, of course. The default configuration from directives

esmerald createproject esmerald_auth
esmerald createapp accounts

then everything is according to the section Introduction.

I can share an example project if it would be an easier way to show it.

@tarsil
Copy link
Contributor

tarsil commented Sep 20, 2024

Yes, of course. The default configuration from directives

esmerald createproject esmerald_auth esmerald createapp accounts

then everything is according to the section Introduction.

I can share an example project if it would be an easier way to show it.

That would be great. This way I can debug it and find the root cause

@AlexMorra
Copy link
Author

here is an example, I used make run
https://github.com/AlexMorra/esmerald_auth_example

@tarsil
Copy link
Contributor

tarsil commented Sep 20, 2024

Thank you, allow us some time to investigate and come back to you

@AlexMorra
Copy link
Author

@tarsil
hi, is there any news or is the library not relevant?

@tarsil
Copy link
Contributor

tarsil commented Oct 25, 2024

@AlexMorra apologies as I got stuck in a few things in the last couple of months. The library is pretty much relevant as I'm actively using it as well. I will come back to you as soon as possible. Apologies for taking so long

@tarsil
Copy link
Contributor

tarsil commented Oct 25, 2024

@AlexMorra after checking and testing your code, you actually did everything correctly and there is something I need to update in the library (also needs some internal updates anyway, but more requirements). This is due to the esmerald_simple_jwt imports that you had commented there were correct in the AppSettings. So basically that bit I need to update and the docs as well.

In the configs/settings.py

@property
    def simple_jwt(self) -> SimpleJWT:

        from esmerald_auth.apps.accounts.backends import (
            BackendAuthentication,
            RefreshAuthentication,
        )

        return SimpleJWT(
            signing_key=self.secret_key,
            backend_authentication=BackendAuthentication,
            backend_refresh=RefreshAuthentication,
        )

This shouldn't impact anything anyway and the reason for it its because its only done once on the up running. Hence also not updating this bit (not sure if the docs actually mention this but I assume not or else this wouldn't be an issue).

If you import like you were doing before, that will work. I will try to rework the internals for the future releases but again, this is not performance issue by doing like this.

Another thing I noticed. In the Makefile you can change the run to:

.PHONY: run
run: ## Starts the local server with production settings
	ESMERALD_SETTINGS_MODULE=esmerald_auth.configs.development.settings.DevelopmentAppSettings esmerald runserver -p 8009

I would also strongly advise you to use the latest Esmerald as well. There was a lot of cleaning and nice features that came out. For instance the auto generated Makefile is no longer supported but instead its the taskfile along other new things that came out in the meantime.

Apologies for taking so long but you can do as we discussed here and I will also update the next release and docs as it can be misleading.

Thank you for reporting this.

@AlexMorra
Copy link
Author

AlexMorra commented Oct 25, 2024

@tarsil Thanks a lot, I got it!
It would be nice to have an authentication section in emerald docs in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants