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

Different settings for different URL's #244

Open
aboueleyes opened this issue May 4, 2024 · 6 comments
Open

Different settings for different URL's #244

aboueleyes opened this issue May 4, 2024 · 6 comments

Comments

@aboueleyes
Copy link

Would it be possible to have different configs for different auth methods?
for example, for a web login I would like to enable IP blocking
for mobile I don't and so

What do you think? If you are OK with it I would be happy to implement it.

@kencochrane
Copy link
Collaborator

Currently, it isn't possible.

How would you tell the difference between web and mobile logins? Do you mean mobile browser or mobile via a native mobile app?

@aboueleyes
Copy link
Author

Currently, it isn't possible.

How would you tell the difference between web and mobile logins? Do you mean mobile browser or mobile via a native mobile app?

Mainly different endpoints

@kencochrane
Copy link
Collaborator

I see. So, depending on the endpoint, they would have a different configuration. How do you propose that we make the settings configurable based on the endpoint?

@aboueleyes
Copy link
Author

@kencochrane

I think it might be something like this

DEFNDER_CONFIG = {
	"default": {
	    "DEFENDER_DISABLE_IP": env.bool("DJANGO_DEFEBDER_DISABLE_IP", True),
	},
    "special_endpoint": {
	    "DEFENDER_DISABLE_IP": env.bool("DJANGO_SPECIAL_ENDPOINT_DEFEBDER_DISABLE_IP", True),
	},
}

default is the old to be backward compatible/global config
and we can add others as stated, and we can add them as prefixes in cache keys

in code, we would do,

settings.DEFENDER_CONFIG.get('speical_config_name', settings.DEFENDER_CONIG['default'])

the speical_config_name would be an optioanl parameter that is used in utils
Added to models maybe?

@kencochrane
Copy link
Collaborator

Ok, that seems like a big change because we would have to move all settings from the top level to a new DEFENDER_CONFIG setting and support both going forward, and deprecate the old way.

Before we do something this dramatic, is this a feature other people think is useful for them?

@aboueleyes
Copy link
Author

@kencochrane I don't know, so let's keep the issue open if anyone thought it's useful, he would react to the messages : )

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