Skip to content

Commit e8540f9

Browse files
committed
update README
1 parent 68011de commit e8540f9

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

README.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1-
# OAuth2 Server Plugin for Moodle
1+
# OAuth2/OpenID Connect Server Plugin for Moodle
22

3-
It provides an [OAuth2](https://tools.ietf.org/html/rfc6749 "RFC6749") server so that a user can use its Moodle account to log in to your application.
4-
Oauth2 Library has been taken from https://github.com/bshaffer/oauth2-server-php
3+
It provides an [OAuth2](https://tools.ietf.org/html/rfc6749 "RFC6749") [OpenID Connect](https://openid.net/specs/openid-connect-core-1_0-final.html) server so that a user can use its Moodle account to log in to your application.
4+
So if you want give all you moodle users access to other website:
5+
6+
* You can't use LTI for this
7+
* You can't use a existing IdP. That can be used by Moodle via auth plugin, and also would works for you other application.
8+
* Website support OAuth2 or OpenID Connect
9+
10+
Then this plugin might be the solution for you.
11+
12+
This plugin uses the php library https://github.com/bshaffer/oauth2-server-php to make moodle a OAuht/OpenID Connect IDP
13+
14+
This plugin is used in Production by AT Computing. But we are still working on it. So its' has *MATURITY* status of *ALPHA*
15+
16+
## What is different from the original
17+
18+
This plug was original created by: https://github.com/projectestac/moodle-local_oauth
19+
20+
This difference between this plugin and the original are:
21+
22+
* It not only follows OAuth2 but also the OpenID connection specifications.
23+
* Besides haveing scopes for the OpenID Connect claims: openid, profile, email, address And phone.
24+
It also implemnt a new claim enrolments. That gives client a list of course the user is enroled in.
25+
* Is has some update to follow the current Moodle plugin best practices.
26+
- replacemnt of deprecated function like `print_error`
27+
- implement privacy api
28+
- follow reconmendation from [moodle-plugin-ci](https://github.com/moodlehq/moodle-plugin-ci)
29+
* Move php dependencie bshaffer/oauth2-server-php. to vendor directory to make it easier to upgrade
530

631
## Requirements
7-
* #### Moodle 2.8 o higher installed
32+
* #### Moodle 4.0 or higher installed
833
* #### Admin account
934

1035
## Instalation steps
@@ -26,29 +51,30 @@ Oauth2 Library has been taken from https://github.com/bshaffer/oauth2-server-php
2651

2752
9. Fill in the form. Your Client Identifier and Client Secret (which will be given later) will be used for you to authenticate. The Redirect URL must be the URL mapping to your client that will be used.
2853

29-
## How to use
54+
## How to use
3055

3156
1. From your application, redirect the user to this URL: `http://moodledomain.com/local/oauth/login.php?client_id=EXAMPLE&response_type=code` *(remember to replace the URL domain with the domain of Moodle and replace EXAMPLE with the Client Identifier given in the form.)*
3257

3358
2. The user must log in to Moodle and authorize your application to use its basic info.
3459

3560
3. If it went all ok, the plugin should redirect the user to something like: `http://yourapplicationdomain.com/foo?code=55c057549f29c428066cbbd67ca6b17099cb1a9e` *(that's a GET request to the Redirect URL given with the code parameter)*
3661

37-
4. Using the code given, your application must send a POST request to `http://moodledomain.com/local/oauth/token.php` having the following parameters: `{'code': '55c057549f29c428066cbbd67ca6b17099cb1a9e', 'client_id': 'EXAMPLE', 'client_secret': 'codeGivenAfterTheFormWasFilled', 'grant_type': 'authorization_code', 'scope': 'user_info'}`.
62+
4. Using the code given, your application must send a POST request to `http://moodledomain.com/local/oauth/token.php` having the following parameters: `{'code': '55c057549f29c428066cbbd67ca6b17099cb1a9e', 'client_id': 'EXAMPLE', 'client_secret': 'codeGivenAfterTheFormWasFilled', 'grant_type': 'authorization_code', 'scope': 'user_info'}`.
3863

3964
5. If the correct credentials were given, the response should a JSON be like this: `{"access_token":"79d687a0ea4910c6662b2e38116528fdcd65f0d1","expires_in":3600,"token_type":"Bearer","scope":"user_info","refresh_token":"c1de730eef1b2072b48799000ec7cde4ea6d2af0"}`
4065

41-
6. Finally, send a POST request to `http://moodledomain.com/local/oauth/user_info.php` passing the access token as a parameter, like: `{'access_token':'79d687a0ea4910c6662b2e38116528fdcd65f0d1'}`.
66+
6. Finally, send a POST request to `http://moodledomain.com/local/oauth/user_info.php` passing the access token as a parameter, like: `{'access_token':'79d687a0ea4910c6662b2e38116528fdcd65f0d1'}`.
4267

4368
7. If the token given is valid, a JSON containing the user information is returned. Ex: `{"id":"22","username":"foobar","idnumber":"","firstname":"Foo","lastname":"Bar","email":"[email protected]","lang":"en","phone1":"5551619192"}`
4469

4570

4671

47-
**This plugin has been tested on Moodle 2.8 and Moodle 3.0**
72+
**This plugin has been tested on Moodle 4
4873

4974

5075
## Contributors
51-
Apart from people in this repository, also have contributed:
5276

77+
- [projectestac] (https://github.com/projectestac/moodle-local_oauth) original plugin
78+
- [examus] (https://github.com/examus/moodle-local_oauth). This project i original found and forked from
5379
- [igorpf] (https://github.com/igorpf)
5480

tests/privacy/provider_test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ private function setup_test_scenario_data($userid) {
258258

259259
$client = "dummy_client";
260260
$scope = "dummy_scopes";
261+
262+
// Test will fail if not all refreshtoken are unique.
261263
$refreshtoken = bin2hex(openssl_random_pseudo_bytes(10));
262264

263265
// Fill local_oauth_access_tokens table.

version.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
$plugin->version = 2022031102; // The (date) version of this plugin.
2727
$plugin->requires = 2011021900; // Requires this Moodle version.
2828
$plugin->component = 'local_oauth';
29+
$plugin->maturity = MATURITY_ALPHA;

0 commit comments

Comments
 (0)