For now to implement Opinsys Authentication to a external service you must receive a shared secret from Opinsys support tuki @ opinsys.fi
. To receive it you must provide following:
Once the shared sercret is in place the external service may redirect user's web browser to https://api.opinsys.fi/v3/sso
with a return_to
query string key which determines where user is redirected back. The hostname of the return_to
URL must match with the fqdn provided to us.
Example redirect URL might be:
https://api.opinsys.fi/v3/sso?return_to=http%3A%2F%2Fexample.com
When user is authenticated he/she will be redirected to the URL specified in the return_to
query string key. The URL is augmented with a jwt
query string key which will contain a JSON Web Token. The external service is expected to decode this token, validate it with the given shared secret and make sure that it is not issued too long a ago or in future. The token will contain following claims:
iat
Identifies the time at which the JWT was issued as unix timestampjti
A unique identifier for the JWTid
Unique identifier for the userusername
first_name
last_name
email
User emailprimary_school_id
schools
List of school objects user belongs toid
Unique identifier for the schoolname
Human readable school nameabbreviation
Valid POSIX name for the schoolroles
List of roles (String) user has in the schoolteacher
, staff
, student
, visitor
, parent
, admin
, schooladmin
or testuser
groups
List of group objects user has in the schoolid
Unique identifier for the schoolname
Human readable group nameabbreviation
Valid POSIX name for the grouptype
Type of the group (String)teaching group
, year class
, administrative group
, course
, archive users
or other groups
organisation_name
organisation_domain
jyvaskyla.opinsys.fi
.In addition to those above, there are some "extra" fields that can be used, but you should NOT rely on their existence (they might not always exist). These are:
puavo_id
id
, but this field gives it an explicit name.external_id
preferred_language
en
, fi
, sv
, de
and so on) identifying the language this user primarily speaks. Can be used to localize the environment.year_class
null
(the actual JSON NULL value, not a string!) for non-students and students who are not in a Primus-enabled school.By default external services are not activated for all Opinsys organisations. Each organisation or individual schools must activate the external services on their behalf. They can do this directly from their management interface.
If the external service knows in advance from which organisation the user is coming from it can make the login bit easier by specifying an additional query string key organisation
to the redirect URL:
https://api.opinsys.fi/v3/sso?organisation=kehitys.opinsys.fi&return_to=http%3A%2F%2Fexample.com
Using this users don't have to manually type their organisation during login.
When user is coming from a Opinsys managed desktop Kerberos will be used for the authentication. User will not even see the Opinsys login form in this case. He/she will be directly redirected back to return_to
url with a jwt
key. The organisation presetting is ignored when Kerberos is active because the organisation will read from the Kerberos ticket. This is enabled by default for all external services using Opinsys Authentication.
If you need to relay some custom fields through the Authentication service you can just add them to the return_to
URL. Just remember to escape the value.
Example:
https://api.opinsys.fi/v3/sso?return_to=http%3A//example.com/path%3Fcustom_field%3Dbar
Redirects user to:
http://example.com/path?custom_field=bar&jwt=<the jwt token>
Feel free to contact us at dev @ opinsys.fi
or open up an issue on Github if you have any trouble implementing this. You can also send a pull request to this document if you feel it is missing something.