authClient module

class authClient.authClient[source]

Bases: object

AUTHCLIENT – Client-side methods to access the Data Lab
Authentication Service.
debug(debug_val)[source]
get_profile()[source]

Get the requested service profile.

Parameters:None
Returns:profile – The currently requested service profile.
Return type:str

Example

from dl import authMgr
profile = authMgr.client.get_profile ()
get_service()[source]

Return the currently-used Authentication Service URL.

Parameters:None
Returns:service_url – The currently-used Authentication Service URL.
Return type:str

Example

from dl import authMgr
service_url = authMgr.client.get_service ()
hasAccess(user, resource)[source]

See whether the user has access to the named Resource. Returns True if the user owns the Resource, or if the Resource grants group permissions to a Group to which the user belongs.

isAlive(svc_url)[source]

Check whether the AuthManager service at the given URL is alive and responding. This is a simple call to the root service URL or ping() method.

isTokenLoggedIn(token)[source]

See whether the user identified by the token is currently logged in.

isUserLoggedIn(user)[source]

See whether the user identified by the token is currently logged in.

isValidPassword(user, password)[source]

See whether the password is valid for the user.

isValidToken(token)[source]

See whether the current token is valid.

isValidUser(user)[source]

See whether the specified user is valid.

list_profiles(token)[source]

List the service profiles which can be accessed by the user.

Parameters:token (str) – Valid auth service token.
Returns:profiles
Return type:JSON string

Example

from dl import authMgr
profiles = authMgr.client.list_profiles (token)
login(username, password, debug=False, verbose=False)[source]
Authenticate the user with the Authentication Service.
We first check for a valid login token in the user’s $HOME/.datalab/ directory and simply return that rather than make a service call to get a new token. If a token exists but is invalid, we remove it and get a new token. In either case, we save the token for later use.
Parameters:
  • username (str) – User login name.
  • password (str) – User password. If not given, a valid ID token will be searched for in the $HOME/.datalab directory.
  • debug (bool) – Method debug flag.
  • verbose (bool) – Initialize session to print verbose output messages.
Returns:

token – One-time security token for valid user (identified via ‘username’ and ‘password’).

Return type:

str

Example

from dl import authMgr
token = authMgr.login ('dldemo', 'dldemo')   # get security token
logout(token)[source]

Log the user out of the Data Lab.

passwordReset(token, username, password)[source]

Reset a user password reset. We require that the user provide either a valid ‘root’ token or the token for the account being reset.

retBoolValue(url)[source]

Utility method to call a boolean service at the given URL.

set_profile(profile)[source]

Set the requested service profile.

Parameters:profile (str) – Requested service profile string.
Returns:
Return type:Nothing

Example

from dl import authMgr
token = authMgr.client.set_profile ("dev")
set_service(svc_url)[source]

Set the URL of the Authentication Service to be used.

Parameters:svc_url (str) – Authentication service base URL to call.
Returns:
Return type:Nothing

Example

from dl import authMgr
authMgr.client.set_service ("http://localhost:7001/")
exception authClient.dlAuthError(message)[source]

Bases: exceptions.Exception

A throwable error class.

authClient.getClient()[source]
authClient.get_profile()[source]
authClient.get_service()[source]
authClient.hasAccess(user, resource)[source]
authClient.isAlive(svc_url='https://dlsvcs.datalab.noao.edu/auth')[source]
authClient.isTokenLoggedIn(token)[source]
authClient.isUserLoggedIn(user)[source]
authClient.isValidPassword(user, password)[source]
authClient.isValidToken(token)[source]
authClient.isValidUser(user)[source]
authClient.list_profiles(token)[source]
authClient.login(user, password=None, debug=False, verbose=False)[source]
authClient.logout(token)[source]
authClient.passwordReset(token, username, password)[source]
authClient.set_profile(profile)[source]
authClient.set_service(svc_url)[source]