sixsq.slipstream.client.api.deprecated-authn

Provides a utility to log into the SlipStream server and to recover an access token. No logout function is provided as the access can be removed by just destroying the token.

NOTE: This API is deprecated. Use the supported API in the namespace sixsq.slipstream.client.api.authn.

The library API functions in namespaces under sixsq.slipstream.client.run-impl.lib use dynamic context defined in this namespace. To bootstrap the API with the context use login!. Each time when called, it alters the root of the context with the new authentication token obtained after performing basic authn with the username/password provided to login!.

(with-context new-context (api-function ...)) can be used to rebind the global context to the new provided one for the time of the invocation of a specific API function. The new context can, for example, be obtained by

{:serviceurl "https://my.slipstream"
 :cookie (login username password)}

Full example

(require '[sixsq.slipstream.client.api.authn :as a])
(require '[sixsq.slipstream.client.api.lib.app :as p])
(require '[sixsq.slipstream.client.api.lib.run :as r])

(def my-slipstream
  {:serviceurl "https://my.slipstream"
   :cookie (a/login username password)}

(def run-uuid
  (last
    (clojure.string/split
      (with-context my-slipstream (p/deploy "my/app")))))

(with-context my-slipstream
  (r/get-run-info run-uuid))

To contact server in an insecure mode (i.e. w/o checking the authenticity of the remote server) before calling login functions, re-set the root of the authentication context with

(require '[sixsq.slipstream.client.api.authn :as a])

(a/set-context! {:insecure? true})
(a/login username password)

or wrap the API call for the local rebinding of the authentication context as follows

(a/with-context {:insecure? true}
  (a/login! username password))

*context*

dynamic

default-context

default-login-url

default-url

endpoint-from-url

(endpoint-from-url url)

extract-response

(extract-response result)

login

(login username password)(login username password login-url)

Synchronous login to the server. Directly returns the access token. Not available in clojurescript.

login!

(login! username password)(login! username password login-url)

Synchronous login to the server. Alters the root of the global dynamic authentication context used in the namespaces under sixsq.slipstream.client.api.lib to interact with the service. Returns the access token. Not available in clojurescript.

login-async

(login-async username password)(login-async username password login-url)

Uses the given username and password to log into the SlipStream server.

This method returns a channel that will contain the results as a tuple of the status and token (cookie). Depending on the underlying HTTP client, the token may be nil even when the login request succeeded.

If called without an explicit login-url, then the default on Nuvla is used.

FIXME: Ideally the login-url should be discovered from the cloud entry point.

login-async-with-status

(login-async-with-status username password)(login-async-with-status username password login-url)

Uses the given username and password to log into the SlipStream server.

This method returns a channel that will contain the results as a map with the keys :login-status and :token. Depending on the underlying HTTP client, the token may be nil even when the login request succeeded.

If called without an explicit login-url, then the default on Nuvla is used.

FIXME: Ideally the login-url should be discovered from the cloud entry point.

login-resource

logout-async-with-status

(logout-async-with-status)(logout-async-with-status logout-url)

Removes cached credentials and tokens from the http client.

result-tuple

(result-tuple result)

select-context

(select-context context)

set-context!

(set-context! context)

Should be called to provide service URL and connection token. The following map is expected

{:serviceurl "https://nuv.la"
 :cookie     "cookie"}

to-login-url

(to-login-url service-url)

with-context

macro

(with-context context & body)