forked from ansible/django-ansible-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide certain plugins from /authenticator_plugins/
Be able to have some authenticator plugins be marked as "internal" and thus not shown in the UI as an option when configuring an authenticator. Signed-off-by: Rick Elrod <[email protected]>
- Loading branch information
Showing
4 changed files
with
41 additions
and
4 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
24 changes: 24 additions & 0 deletions
24
test_app/tests/fixtures/authenticator_plugins/definitely_not_public.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
from django.contrib.auth import get_user_model | ||
|
||
from ansible_base.authentication.authenticator_plugins.base import AbstractAuthenticatorPlugin | ||
|
||
logger = logging.getLogger('test_app.tests.fixtures.authenticator_plugins.definitely_not_public') | ||
|
||
|
||
class AuthenticatorPlugin(AbstractAuthenticatorPlugin): | ||
configuration_encrypted_fields = [] | ||
type = "internal" | ||
category = "password" | ||
|
||
def __init__(self, database_instance=None, *args, **kwargs): | ||
super().__init__(database_instance, *args, **kwargs) | ||
self.set_logger(logger) | ||
|
||
def authenticate(self, request, username=None, password=None, **kwargs): | ||
if username == "admin" and password == "hello123": | ||
user = get_user_model().objects.get(username=username) | ||
return user | ||
|
||
return None |