Exemplo n.º 1
0
def get_role_authority(conn):
    pair = {'sso_admin': ['AUTH_TEST']} 
    data = []
    for k in pair:
        role = db2.unique(conn, 'select role_key from sso_roles where name = ?', k) 
        for v in pair[k]:
            auth = db2.unique(conn, 'select authority_key from authorities where code = ?', v)
            data.append((role['ROLE_KEY'], auth['AUTHORITY_KEY']))
            
    for el in data:
        yield el      
Exemplo n.º 2
0
def get_menus(conn, app):
    pair = {'welcome_menu': 'welcomePage'}
    for k in pair:
        resource_name = pair[k]
        resource = db2.unique(conn, 
                              'select resource_key from resources where name = ? and app = ?', resource_name, app)
        
        yield ('welcome_menu', None, resource['RESOURCE_KEY'])
Exemplo n.º 3
0
def sso_roles(conn):
    tenant_key = db2.unique(conn, 'select * from SSO_TENANTS where name = ?', 'default')['TENANT_KEY']
    
    roles = db2.query(conn, '''
        select * from roles
    ''')    
    
    for role in roles:
        yield(role['ROLE_KEY'], role['NAME'], 1, role['DESC'], tenant_key, datetime.datetime.now())
Exemplo n.º 4
0
def sso_users(conn):
    tenant_key = db2.unique(conn, 'select * from SSO_TENANTS where name = ?', 'default')['TENANT_KEY']
    
    users = db2.query(conn, '''
        select * from users
    ''')
    
    for user in users:
        yield (user['USER_KEY'], user['PASSWORD'], user['USER_NAME'], user['USER_NAME'], tenant_key,
               user['CREATE_TS'], user['MODIFY_TS'])    
Exemplo n.º 5
0
def get_authority_resource(conn, app):
    authorities = ['AUTH_TEST']
    for auth in authorities:
        auth = db2.unique(conn, 'select authority_key from authorities where code = ?', auth)
        for resource_key in db2.query(conn, 'select resource_key from resources'):
            yield (auth['AUTHORITY_KEY'], resource_key['RESOURCE_KEY'])
Exemplo n.º 6
0
def get_user(conn, name):
    return db2.unique(conn, 'select * from sso_users where user_name = ?', name)
Exemplo n.º 7
0
def get_role(conn, name):
    return db2.unique(conn, 'select * from sso_roles where name = ?', name)
Exemplo n.º 8
0
def get_tenant(conn, name):
    return db2.unique(conn, 'select * from SSO_TENANTS where name = ?', name)