moodle-auth_jwt/README.md

92 lines
2.8 KiB
Markdown
Raw Normal View History

2016-08-18 23:59:16 +00:00
Log in to Moodle using one time user key.
=========================================
Auth plugin for organising simple one way SSO(single sign on) between moodle and your external web
application. The main idea is to make a web call to moodle and provide one of the possible matching
2016-08-19 00:07:16 +00:00
fields to find required user and generate one time login URL. A user can be redirected to this
URL to be log in to Moodle without typing username and password.
2016-08-18 23:59:16 +00:00
Using
-----
1. Install the plugin as usual.
2. Enable and configure just installed plugin. Set required Mapping field, User key life time,
User key life time and Redirect after logout.
3. Configure Moodle web services as described here http://docs.moodle.org/en/Web_services
4. Add function "auth_userkey_request_login_url" to your enabled web service.
5. Configure your external application to make a web call to get login URL.
6. Redirect your users to this URL to be logged in to Moodle.
Configuration
-------------
**Mapping field**
Required data structure for web call is related to mapping field you configured.
For example XML-RPC (PHP structure) description for different mapping field settings:
***User name***
2016-08-19 00:07:16 +00:00
2016-08-19 00:24:41 +00:00
[user] =>
Array
(
[username] => string
)
2016-08-18 23:59:16 +00:00
***Email Address***
2016-08-19 00:07:16 +00:00
2016-08-19 00:23:28 +00:00
[user] =>
Array
(
[email] => string
)
2016-08-18 23:59:16 +00:00
***ID number***
2016-08-19 00:07:16 +00:00
2016-08-19 00:23:28 +00:00
[user] =>
Array
(
[idnumber] => string
)
2016-08-18 23:59:16 +00:00
2016-08-19 00:24:41 +00:00
***Web service will return following structure or standard Moodle webservice error message.***
2016-08-19 00:07:16 +00:00
2016-08-18 23:59:16 +00:00
Array
(
[loginurl] => string
)
Please navigate to API documentation to get full description for "auth_userkey_request_login_url" function.
e.g. http://yourmoodle.com/admin/webservice/documentation.php
2016-08-19 00:07:16 +00:00
You can amend login URL by "wantsurl" parameter to redirect user after theu logged in to Moodle.
2016-08-19 00:31:50 +00:00
2016-08-19 00:07:16 +00:00
E.g. http://yourmoodle.com/auth/userkey/login.php?key=uniquekey&wantsurl=http://yourmoodle.com/course/view.php?id=3
Wantsurl maybe internal and external.
2016-08-18 23:59:16 +00:00
**User key life time**
This setting describes for how long a user key will be valid. If you try to use expired key then you will
get an error.
**IP restriction**
If this setting is set to yes, then user have to use the same remote IP address to generate a user key (make
a web call) as well as then log in using this key. If IP address is different a user will get an error.
**Redirect after logout**
2016-08-19 00:23:28 +00:00
You can set URL to redirect users after they logged out from Moodle. For example you can redirect them
to logout script of your web application to log users out from it as well. This setting is optional.
2016-08-18 23:59:16 +00:00
2016-08-19 00:31:50 +00:00
TODO:
-----
1. Add users provisioning.
2. Implement logout webservice to be able to call it from external application.
3. Add a test client code to README.