| 1 |
# Copyright: (c) 2020, Jordan Borean (@jborean93) <[email protected]> |
| 2 |
# MIT License (see LICENSE or https://opensource.org/licenses/MIT) |
| 3 |
|
| 4 |
import json |
| 5 |
import logging |
| 6 |
import logging.config |
| 7 |
import os |
| 8 |
|
| 9 |
from spnego._context import ( |
| 10 |
ContextProxy, |
| 11 |
ContextReq, |
| 12 |
IOVUnwrapResult, |
| 13 |
IOVWrapResult, |
| 14 |
UnwrapResult, |
| 15 |
WinRMWrapResult, |
| 16 |
WrapResult, |
| 17 |
) |
| 18 |
from spnego._credential import ( |
| 19 |
Credential, |
| 20 |
CredentialCache, |
| 21 |
KerberosCCache, |
| 22 |
KerberosKeytab, |
| 23 |
NTLMHash, |
| 24 |
Password, |
| 25 |
) |
| 26 |
from spnego.auth import client, server |
| 27 |
from spnego.exceptions import NegotiateOptions |
| 28 |
|
| 29 |
__all__ = [ |
| 30 |
"ContextProxy", |
| 31 |
"ContextReq", |
| 32 |
"Credential", |
| 33 |
"CredentialCache", |
| 34 |
"IOVUnwrapResult", |
| 35 |
"IOVWrapResult", |
| 36 |
"KerberosCCache", |
| 37 |
"KerberosKeytab", |
| 38 |
"NTLMHash", |
| 39 |
"Password", |
| 40 |
"NegotiateOptions", |
| 41 |
"UnwrapResult", |
| 42 |
"WinRMWrapResult", |
| 43 |
"WrapResult", |
| 44 |
"client", |
| 45 |
"server", |
| 46 |
] |
| 47 |
|
| 48 |
|
| 49 |
def _setup_logging(logger: logging.Logger) -> None: |
| 50 |
log_path = os.environ.get("PYSPNEGO_LOG_CFG", None) |
| 51 |
|
| 52 |
if log_path is not None and os.path.exists(log_path): # pragma: no cover |
| 53 |
# log log config from JSON file |
| 54 |
with open(log_path, "rt") as f: |
| 55 |
config = json.load(f) |
| 56 |
|
| 57 |
logging.config.dictConfig(config) |
| 58 |
else: |
| 59 |
# no logging was provided |
| 60 |
logger.addHandler(logging.NullHandler()) |
| 61 |
|
| 62 |
|
| 63 |
logger = logging.getLogger(__name__) |
| 64 |
_setup_logging(logger) |