forked from aker-gateway/Aker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IdPFactory.py
54 lines (41 loc) · 1.16 KB
/
IdPFactory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ahmed Nazmy
#
# Meta
__license__ = "AGPLv3"
__author__ = 'Ahmed Nazmy <[email protected]>'
import logging
import importlib
import sys
import os
class IdPFactory(object):
@staticmethod
def getIdP(choice):
logging.info(
"IdPFactory: trying dynamic loading of module : {0} ".format(choice))
# load module from subdir idp
idp = "idp." + choice
try:
idp_module = importlib.import_module(idp)
idp_class = getattr(idp_module, choice)
except Exception as e:
logging.error(
"IdPFactory: error loading module : {0}".format(
e.message))
return idp_class
class IdP(object):
'''
Base class to implement shared functionality
This should enable different identity providers
'''
def __init__(self, username, gateway_hostgroup):
self._all_ssh_hosts = {}
self._allowed_ssh_hosts = {}
self.user = username
self.gateway_hostgroup = gateway_hostgroup
def list_allowed(self):
pass
def _load_all_hosts(self):
pass