{{icon:status}} Application servers guide

Documentazione lato server

La documentazione di {{label:productName}} è disponibile solo in inglese.

Cambi lingua (in alto a destra) per visualizzarla.

Server documentation

This page describes the interaction between customer’s web application(s) server(s) and {{label:productName}}.

The whole traffic between application server and {{label:productName}} server occurs under HTTPS.

Available interactions are:

  1. Book an authentication session
  2. Verify authentication
  3. Advanced: Push a custom ID

Formats

{{label:productName}} input supports:

Contacting the server

The server is contacted by web application through the URI https://base/server:action/lpublic=public-token, e.g.: https://fastauthentication.org/server:book/lpublic=555-b79c58bf116303b3

Available actions are book (to book an authentication session), verify (to verify an authentication status).

The possible input formats are json and HTTP POST (UTF-8 encoded POST data).

Regardless of the format, the content must be a set of keys/values, e.g.:

json: { "key1":"value 1", "key2":"value 2", …}

Content must always include server private key with parameter name “lprivate”.
Provide it always in POST content, never use a GET parameter for it, for security reasons: POST body content is encrypted by HTTPS, and this voids also the “man-in-the-middle” attack.
JSON string must be well-formed.
All properties and all non-numeric values must be quoted with the standard «"».
Unquoted keys/values or quotation performed with the single «'» will produce an error.
Content-Type is expected to be “application/json”.

“book”: Booking an authentication session

In order to book an authentication session application server must contach {{label:productName}} server.
The URL to POST is: https://base/server:book/lpublic=public-token

Parameters that can be used, with both HTTP POST or JSON POST, are:

E.g.: post to https://base/server:book/lpublic=967-badae3567f630b60 a JSON like this:

{
	"lprivate" : "dcdd5e57e888ac904dc009d18c1ea89c59889c3e68bfb3f7",
	"lcallback" : "http://mycompany.com/myapp/auth.php?type=success",
	"lcallbackfail" : "http://mycompany.com/myapp/auth.php?type=failure"
}
JSON POST must use a Content-Type «application/json», UTF-8 encoded.

Or the equivalent HTTP POST:

lprivate=dcdd5e57e888ac904dc009d18c1ea89c59889c3e68bfb3f7&lcallback=http%3A%2F%2Fmycompany.com%2Fmyapp%2Fauth.php%3Ftype%3Dsuccess&lcallbackfail=http%3A%2F%2Fmycompany.com%2Fmyapp%2Fauth.php%3Ftype%3Dfailure
In case lpublic/lprivate keys mismatch an HTTP 401 error is returned.

If the booking process is succesful (server public/private keys match), the response will be a JSON like this:

{
	"client" : {
		"auth" : "authentication-URI",
		"reauth" : "authentication-URI"
	},
	"server" : {
		"verify" : "verification-URI",
		"append" : "parameter-name"
	}
}

The meaning is:

Currently response.server.append is normally valued “lauthsession”.
In case you want to skip holding the temporary response from book process you can assume this value to be static.
It will vary only in case your “callback” URI contains yet an “lauthsession” GET parameter.

Once the authentication session has been booked redirect user’s browser to the appropriate response.client.auth or response.client.reauth URL, e.g.: https://base/auth:index/ltoken=token

Authentication session has a maximum duration of 5 minutes.

About “lcallback”

Once tha authentication process is complete, user’s browser will be sent to customer’s “lcallback” URI.
It will be a GET request, added with the “lauthsession” parameter.

“lcallback” parameter can be declared at “book” level, if not it will default to “lcallback” parameter defined at customer level.

The “lcallback” parameter is a string representing a complete URI.
Starts with protocol (hopefully “https”), can use GET parameters as well as an “#” part.
At user redirection a parameter is added for “lauthsession” code.

Customizing “lcallback” URI

There is the option to use the literal text “{{token}}” within “lcallback” string to identify auth-session-token.
In this case response.server.append is valued “{{CustomURI}}” and no longer used, while the “lauthsession” value replaces “{{token}}” text in callback URI without any other consideration.
This syntax allow the parameter to be part of URI, GET parameters as well as of “#” hashmap, e.g.:

The value of the token will be the “lauthsession” value necessary to verify the actual authentication.

“verify”: Verify the success of an authentication session

Once authentication process is over, if succesfull user’s browser will be redirected to customer’s application server at the “lcallback” URI.

Content must include server private key with parameter name “lprivate”.

The “lauthsession” parameter will be added (GET) to such URL, this parameter is named in response.server.append described above (in «book»).
Append such parameter value to response.server.verify URL returned by «book» process and issue a POST request to verify the actual authentication.
The resulting URL to POST will be something like: https://base/server:verify/lpublic=public-token/lauthsession=auth-session-token

Currently book’s response.server.append is normally valued “lauthsession”.
In case you want to skip holding the temporary response from book process you can assume this value to be static.
It will vary only in case your “callback” URI contains yet an “lauthsession” GET parameter.

It’s mandatory to add the “lprivate” parameter valued with your server’s private key.
You can use json or HTTP POST (UTF-8 encoded POST data) to add it.

Optionally HTTP POST data or JSON POST data could also contain the “lauthsession” pair key/value, in this case it’s not necessary to report it in URL. E.g.:

URL: https://base/server:verify/lpublic=public-token

HTTP POST data: lprivate=lprivate server key&lauthsession=lauthsession token
or
JSON POST data: {"lprivate":"lprivate server key","lauthsession":"lauthsession token"}
JSON string must be well-formed.
All properties and all non-numeric values must be quoted with the standard «"».
Unquoted keys/values or quotation performed with the single «'» will produce an error.
Content-Type is expected to be “application/json”.

The response will be a JSON like one of these:

{
	"status":"success",
	"authenticated": {
		"ldisplay":"identity string",
		"lidentity":"identity details",
		"ltype":"id-type, e.g: email"
	}
	"verifiedby": {
		"ldisplay":"identity string",
		"lidentity":"identity details",
		"ltype":"id-type, e.g: email"
	}
}
{
	"status":"failure",
	"error":"description"
}

The «error» key is included always and only in case of authentication failure.

The «authenticated» and «verifiedby» keys are included always and only in case of authentication success.

Both «authenticated» and «verifiedby» are valued with:

In both cases more informations could be included.

In case of error additional fields could be used for debugging, while in case of successful authentication you could have:

{
	"status":"success",
	"authenticated": {"lidentity":"identity","ltype":"id-type, e.g: email"},
	"name":"Person name, e.g.: John Doe",
	"alt":[
		{"lidentity":"identity","ltype":"id-type, e.g: email"},
		{"lidentity":"identity","ltype":"id-type, e.g: email"}
	],
	"xFastAuthentication":{
		"authID":"UUID",
		"personID":"UUID"
	}
}

Optional additional properties are:

All the additional/alternative identities provided with “alt” have been verified.
In case your web application cannot accept the authenticated identity it’s up to you to decide whether you want to crawl alternative identities to see if you can match an acceptable one.

“pushid”: Push a custom ID for authenticated user

Once a user is authenticated customer’s web application server can “push” on the authenticated person profile a custom ID.

This can be done by POSTing to URI https://base/server:pushid/lpublic=public-token/ a JSON like this:

{
	"lprivate":"server private key",
	"lauthsession":"auth-session-token",
	"jidentity":{
		"lidentity":"your custom ID",
		"ltype":"Your custom type"
	}
}

In order to associate an authenticated user to a custom identity, you could:

  1. Book the authentication
  2. Send the user to authentication
  3. Verify the authentication

In case the verification doesn’t report a suitable ID you can desume from “authenticated” or “alt”, you can:

  1. Push the custom ID on the session
  2. Verify again authentication

The response of second verification will include in “alt” array the custom identity, without a new authentication for the user.

Beware of custom IDs: in case the custom ID string is the same of another authentication (e.g.: an email) then you’re opening a security breach: someone could authenticate with the same ID, and act as the authenticated person with your server.
Always use a custom ID that cannot be confused with a “regular” authentication, e.g.: “username#appname.company”.

Known limitations

When an authentication is in place only one digital identity per customer can be associated per each user.

This could be an issue only in case a user interacts using the same browser with multiple web applications of the same customer, and wants to use different identities at the same time.

If you want to be able to verify different digital identites per user and to keep them active for verification at the same time (e.g.: without forcing the user to re-authenticate), then you should register two different servers: two customers, each one with own lpublic/lprivate keys.

This is intentional: once a user is authenticated he/she’ll be able to keep the same digital identity with the same customer (and the same browser) regardless of the actual web application, making the single-sign-on process more effective.

Powered by: altersoftware.IT
Un servizio di: altersoftware.IT