-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added no security store for static logins
- Loading branch information
1 parent
0e28f8d
commit 28e24db
Showing
4 changed files
with
64 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import logging | ||
from typing import List, Optional | ||
|
||
from ... import manager | ||
from ..model import User | ||
from .base_store import BaseStore | ||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
class NoSecurityStore(BaseStore): | ||
def __init__(self, user: str, roles: List[str]): | ||
self.user = user | ||
self.roles = roles | ||
|
||
def load_from_request(self, req): | ||
return User(id=self.user, roles=self.roles) | ||
|
||
|
||
def create(): | ||
# Check if the security store is enabled. | ||
# Why do we do this here and not in the __init__.py? | ||
# Because the configuration is merged after the registry is loaded, | ||
# such that no keys are available (except tdp_core keys). | ||
if manager.settings.tdp_core.security.store.no_security_store.enable: | ||
_log.info("Adding NoSecurityStore") | ||
return NoSecurityStore( | ||
manager.settings.tdp_core.security.store.no_security_store.user, | ||
manager.settings.tdp_core.security.store.no_security_store.roles, | ||
) | ||
|
||
return None |
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