def authenticate(self, settings: EnterpriseRuntimeOptions): config = Configuration() config.host = settings.host config.verify_ssl = settings.verify_ssl if settings.auth_type == EnterpriseRuntimeAuthType.session_cookie: auth = SessionAuthenticator(config) # TODO can we use just cookie_str in API client cookie_str = auth.authenticate(settings.user, settings.password) ckies: cookies.SimpleCookie = cookies.SimpleCookie() ckies.load(cookie_str) token = ckies["authservice_session"].value cookie_str = f"authservice_session={token}" api_client = ApiClient(config, cookie=cookie_str) self.api_client = api_client elif settings.auth_type == EnterpriseRuntimeAuthType.oidc: if not settings.verify_ssl: os.environ["CURL_CA_BUNDLE"] = "" config.oidc_client_id = settings.oidc_client_id config.oidc_server = settings.oidc_server auth = OIDCAuthenticator(config) config.access_token = auth.authenticate(settings.user, settings.password) api_client = ApiClient(config) self.api_client = api_client else: raise ValueError(f"Unknown auth type {settings.auth_type}")
def init_api(): config = Configuration() config.host = deploy_api_host config.oidc_client_id = oidc_client_id config.oidc_server = oidc_server config.username = oidc_username config.password = oidc_password config.oidc_client_secret = oidc_client_secret config.auth_method = oidc_auth_method if not config.auth_method or config.auth_method is None: config.auth_method = 'password_grant' if not config.host or config.host is None: print('No DEPLOY_API_HOST - will not look up metadata from Deploy') return if not config.oidc_server or config.oidc_server is None: print( 'No OIDC_PROVIDER - auth will not be used in connecting to metadata' ) return auth = None if config.oidc_server: auth = OIDCAuthenticator(config) config.access_token = auth.authenticate() api_client = ApiClient(configuration=config, authenticator=auth) env_api = EnvironmentApi(api_client) print('connected to deploy') print(env_api.read_user()) global metadata_api metadata_api = ModelMetadataServiceApi(api_client)
def init_api(): config = Configuration() config.host = deploy_api_host config.oidc_client_id = oidc_client_id config.oidc_server = oidc_server config.username = oidc_username config.password = oidc_password config.oidc_client_secret = oidc_client_secret config.oidc_resource = oidc_resource config.auth_method = oidc_auth_method if verify_ssl.lower() != "true": config.verify_ssl = False os.environ["CURL_CA_BUNDLE"] = "" if not config.auth_method: config.auth_method = "password_grant" if not config.host: print("No DEPLOY_API_HOST - will not look up metadata from Deploy") return if not config.oidc_server: print( "No OIDC_PROVIDER - auth will not be used in connecting to metadata" ) auth = None if config.oidc_server: auth = OIDCAuthenticator(config) config.access_token = auth.authenticate() api_client = ApiClient(configuration=config, authenticator=auth) env_api = EnvironmentApi(api_client) print("connected to deploy") print(env_api.read_user()) global metadata_api metadata_api = ModelMetadataServiceApi(api_client)
from seldon_deploy_sdk.rest import ApiException import os config = Configuration() config.host = os.getenv('DEPLOY_API_HOST') config.oidc_client_id = os.getenv('CLIENT_ID') config.oidc_server = os.getenv('OIDC_PROVIDER') config.username = os.getenv('OIDC_USERNAME') config.password = os.getenv('OIDC_PASSWORD') config.auth_method = 'password_grant' config.scope = os.getenv('OIDC_SCOPES') #to use client credential set above to client_credentials and uncomment and set config.oidc_client_secret #config.oidc_client_secret = 'xxxxx' #note client has to be configured in identity provider for client_credentials auth = OIDCAuthenticator(config) config.access_token = auth.authenticate() print(config.access_token) api_client = ApiClient(configuration=config, authenticator=auth) api_instance = ModelMetadataServiceApi(api_client) models = [ # To test e2e have to use wizard to deploy some of below AFTER running this script # Use names, uris and artifact types below when filling in wizard. # Same model different versions { "uri": "gs://test-model-beta-v2.0.0", "name": "iris", "version": "v1.0.0", "artifact_type": "SKLEARN",