Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion quest/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'download_options',
'get_active_project',
'get_api_version',
'get_auth_status',
'get_collections',
'get_datasets',
'get_features',
Expand Down Expand Up @@ -56,7 +57,6 @@
'save_settings',
'set_active_project',
'stage_for_download',
'stage_for_publish',
'unauthenticate_provider',
'update_metadata', # replaces update_collection, update_feature, update_dataset
'update_settings',
Expand Down Expand Up @@ -150,6 +150,7 @@
get_services,
add_provider,
delete_provider,
get_auth_status,
authenticate_provider,
unauthenticate_provider,
)
Expand Down
26 changes: 24 additions & 2 deletions quest/api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from __future__ import absolute_import
from __future__ import print_function
from ..api.database import get_db, db_session
from .. import util
import os
import requests
Expand Down Expand Up @@ -167,7 +168,28 @@ def delete_provider(uri):
return msg


def authenticate_provider(uri):
def get_auth_status(uri):
"""Check to see if a provider has been authenticated

Args:
uri (string, Required):
uri of 'user service'
Returns:
True on success
False on not authenticated

"""
db = get_db()
with db_session:
p = db.Providers.select().filter(provider=uri).first()

if p is None:
return False

return True


def authenticate_provider(uri, **kwargs):
"""Authenticate the user.

Args:
Expand All @@ -178,7 +200,7 @@ def authenticate_provider(uri):

"""
driver = util.load_providers()[uri]
driver.authenticate_me()
driver.authenticate_me(**kwargs)


def unauthenticate_provider(uri):
Expand Down
5 changes: 2 additions & 3 deletions quest/services/cuahsi_hs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from shapely.geometry import Point, box
from ..api.metadata import get_metadata
from ..util import param_util
from getpass import getpass
import pandas as pd
import param
import os
Expand Down Expand Up @@ -260,8 +259,8 @@ def get_hs(self, auth=None, require_valid_auth=False):

def authenticate_me(self, **kwargs):

username = input("Enter Username: ")
password = getpass("Enter Password: ")
username = kwargs['username']
password = kwargs['password']

try:
auth = HydroShareAuthBasic(username=username, password=password)
Expand Down
4 changes: 2 additions & 2 deletions quest/services/kitware_girder.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def get_gc(self):

def authenticate_me(self, **kwargs):
connection_info = 'https://data.kitware.com/api/v1'
username = input("Enter Username: ")
password = getpass("Enter Password: ")
username = kwargs['username']
password = kwargs['password']

try:
gc = girder_client.GirderClient(apiUrl=connection_info)
Expand Down