Ejemplo n.º 1
0
def status():
    uuid, current_auth_url, metadata = get_storage(check=False)

    print("\n\n# Global configuration\n")
    print(f"uuid: {uuid}")
    print(f"auth_url: {current_auth_url}")

    if nm_available():
        active_uuid, status = connection_status(get_client())
        print(f"VPN connection active: {bool(active_uuid)}")
        print(f"VPN NM status is: {status}")
        print(f"Active VPN connection is EduVPN: {bool(uuid == active_uuid)}")

    print("\n\n## Previous connection properties\n")

    for auth_url, props in get_all_metadatas().items():
        if auth_url == current_auth_url:
            print(" ** CURRENT ACTIVE CONFIGURATION **")
        print(f"auth_url {auth_url}")
        for t in [
                'api_url', 'display_name', 'support_contact', 'profile_id',
                'token_endpoint', 'authorization_endpoint', 'con_type',
                'country_id'
        ]:
            print(f"{t}: {props[t]}")
        print(f"token.token_type: {props['token']['token_type']}")
        print(f"token.expires_in: {props['token']['expires_in']}")
        print(f"token.expires_at: {props['token']['expires_at']}")
        print("\n\n")
Ejemplo n.º 2
0
 def all_configured(self) -> Iterable[ConfiguredServer]:
     "Return all configured servers."
     for key, data in storage.get_all_metadatas().items():
         if data['con_type'] == storage.ConnectionType.INSTITUTE:
             yield InstituteAccessServer(
                 base_url=data['api_base_uri'],
                 display_name=data['display_name'],
                 support_contact=data['support_contact'],
                 keyword_list=None,  # TODO
             )
         elif data['con_type'] == storage.ConnectionType.SECURE:
             secure_internet = SecureInternetServer(
                 base_url=data['api_base_uri'],
                 public_key_list=[],  # TODO
                 country_code=data['country_id'],
                 support_contact=data['support_contact'],
                 authentication_url_template=None,  # TODO
             )
             organisation = OrganisationServer(
                 secure_internet_home=data['api_base_uri'],
                 display_name=data['display_name'],
                 org_id='',  # TODO
                 keyword_list={},
             )
             yield SecureInternetLocation(organisation, secure_internet)
         elif data['con_type'] == storage.ConnectionType.OTHER:
             yield CustomServer(data['api_base_uri'])
         else:
             raise ValueError(data)