101 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
29a541724f
MDL-65292 style: Fix all the function declaration ordering
This has been generated running the following Sniff,
part of the Moodle's CodeSniffer standard:
- PSR2.Methods.MethodDeclaration

It just ensures all the function declarations have
the correct order for:
- abstract and final.
- visibility (public, protected, private).
- static.

So, all the lines modified by this commit are function declarations
and the only changes are in the positions of those keywords.
2024-02-28 23:47:47 +01:00
Jake Dallimore
d20af220f8
MDL-79520 core: update Clever integration to use OpenId Connect
Instead of creating the endpoints manually, and fetching the user info
from several endpoints, which also necessitates the use of a custom
client subclass, use the OpenId configuration endpoint to auto-configure
endpoints, and then use the userinfo endpoint to fetch user info.
2024-02-20 17:07:03 +08:00
Jake Dallimore
189558e80c
MDL-79181 core: update LinkedIn OAuth template to use OIDC
The old method (sign in with linkedin) is deprecated:
https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin

This replaces this with the new method:
https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2

This is not entirely OIDC compliant, however. The well known
openid-configuration isn't present at the issuer root and the 'locale'
claim contains an object instead of a string. These are worked around.
2023-09-11 10:40:34 +08:00
Sara Arjona
026f377993
MDL-78884 theme: Update references to $icon.png
The *.png files in pix/f folder have been removed, so their references
need to be updated to use the proper SVG file or a different icon, as
happened with logo_uri for oauth2 services.
2023-08-23 07:33:58 +02:00
Andrew Nicols
bd214de282 MDL-75552 badges: move apiBase consumption to backpack
The apiBase in .well-known/badgeconnect.json was ignored and it was
causing some failures when connecting or sending badges to an
external backpack.
For OBv2.1, it has been changed to always use the apiBase defined
in the badgeconnect.json backpack provider.
2023-05-09 08:50:42 +02:00
Huong Nguyen
58ced4add0 MDL-75316 core_moodlenet: Share to MoodleNet modal and activity menu
Originally implemented as MDL-75785
2023-04-18 17:05:07 +08:00
Michael Hawkins
77f85ed287 MDL-75316 core: Add activity sender & moodlenet_client to MoodleNet API
This makes it possible to share a single activity to a MoodleNet
instance (which has been enabled for sharing in site admin).
This utilises the core\moodlenet\activity_packager to create an
activity backup, then sends it using the MoodleNet create resource
API specification.

Originally implemented as MDL-75932
2023-04-18 17:04:14 +08:00
Jake Dallimore
bc0bc7ac4c MDL-75650 core: add moodlenet oauth2 service to core 2023-03-08 08:48:20 +08:00
Jake Dallimore
40af893af5 MDL-75650 core: add oauth2 auth server config reader
Simple JSON reader which takes an issuer and reads its metadata. The
class is aware of request-centric rules, such as:
- The position of the well known suffix in the URL (per RFC8414)
- The requirement to have HTTPS auth server issuer URL
- The validity of query strings, paths and fragments in the auth server
issuer URL
,but makes no attempt to validate the config JSON returned.
2023-03-08 08:48:20 +08:00
Meirza
b79231361b MDL-61789 auth_oauth2: Update profile fields based on data mapping.
After the user creation, the system must call an update function to update profile_fields_*.
We also provided two functions into user/profile/lib.php to get available from other areas.
We added PHP unit testing for new public functions and
the Behat tests for custom profile fields with locked and unlocked statuses.

Co-authored-by: Matt Porritt <matt.porritt@moodle.com>
2023-01-07 20:59:26 +07:00
Matt Porritt
6793891887 MDL-61789 auth_oauth2: Allow admin to choose profile fields for mapping
Update oauth2 to allow mapping of provider attributes against
user profile fields. Fields can also be locked to prevent
user changes.

Co-Authored-By: Michael Milette <michael.milette@tngconsulting.ca>
2023-01-06 13:27:11 +07:00
Paul Holden
e0d7ab9989 MDL-76380 tool_oauth2: remove double persistent load on update.
The method already loaded the validated persistent model data on the
previous line, there's no need to do it again (while also trying to
load unvalidated properties).
2022-11-28 19:38:47 +00:00
Huong Nguyen
ea4a582b3d MDL-76326 oauth2: Update Nextcloud logo to the new one 2022-11-17 11:31:16 +07:00
Víctor Déniz
d3e26c1a2a Merge branch 'MDL-76172-master' of https://github.com/sarjona/moodle 2022-11-04 12:06:37 +03:00
Sara Arjona
ae63a2d16b MDL-76172 core: Fix error when userinfo is false
This patch should fix a regression introduced in MDL-75171, raised
while running the OBv2.1 certification.
The new method get_raw_userinfo() can return stdClass or false but
the second one was not taken into account from get_userid() (so an
error was thrown: "Argument 1 passed to
core\oauth2\client::map_userinfo_to_fields() must be an instance
of stdClass, bool given").
2022-11-02 12:28:19 +01:00
Jake Dallimore
b76ac53c9d MDL-61880 core: don't clear issuer fields not present in form data
In cases where we have an id, load the persistent and then set new data
before saving. This ensures we don't delete fields which are missing in
the form data.
2022-11-02 11:11:00 +08:00
Yannick Forget
52d523fa9c MDL-61880 core: Retain OAuth 2.0 user field mappings after issuer update 2022-11-02 11:10:36 +08:00
Tomo Tsuyuki
a6a7b16846 MDL-75171 Auth: extend user logged in event
Co-authored-by: Heena Agheda <heenaagheda@catalyst-au.net>
2022-08-19 18:38:59 +10:00
Ripal Nathuji
79ae21c23f MDL-73767 oauth2: Add clever oauth2 client 2022-05-31 17:17:20 -05:00
Ilya Tregubov
08d2c0fb9f Merge branch 'MDL-73868-master' of https://github.com/sarjona/moodle 2022-02-16 13:04:52 +02:00
Sara Arjona
c4e6ac585d MDL-73868 oauth2: Remove multiple slashes in image URL
There is an issue with the current Badgr manifest because the image
URL contains double slash which is causing an error when storing it
in the database (https://api.test.badgr.com/static//images/logo.png).
This issue parses image URL and removes multiple slashes in URL.
2022-02-14 11:30:19 +01:00
Sara Arjona
3daeecd3d2 MDL-73827 lib: Fix URL blocked error for userinfo endpoint
When the oAuth2 issuer hasn't any userinfo endpoint, a call to
$this->get(false) was done, which was returning "The URL is
blocked".
This is a regression from MDL-70649, which added some cURL security
checks.
2022-02-10 10:43:38 +01:00
Ilya Tregubov
e8898b3bd9 MDL-71593 oauth2: Remove methods that were readded by mistake. 2021-06-21 10:11:16 +02:00
Peter Dias
8e71f6b1f1 MDL-65637 core_oauth2: Introduce a new custom linkedin oauth2 client 2021-06-02 08:11:38 +08:00
Peter Dias
169e1812ed MDL-65637 core_oauth2: Create new oauth2 mapping function
Separated userinfo mapping into a function and new unit test
2021-06-02 08:11:38 +08:00
David Mudrák
03402e3c5d MDL-71580 lang: Fix reworded strings in tests 2021-05-12 17:10:16 +02:00
abgreeve
8a53fe7f6b Merge branch 'MDL-28452-master' of git://github.com/bmbrands/moodle 2021-04-22 09:38:50 +08:00
Bas Brands
f9e1c2587a MDL-28452 core_user: migrate social profile fields
Create a new profile field type, move all existing content of the fields
'icq', 'skype', 'aim', 'yahoo', 'msn' and 'url' in the mdl_user table to
theses new profile fields if needed.

AMOS BEGIN
MOV [aimid,core],[aimid,courseimage,profilefield_social]
MOV [yahooid,core],[yahooid,profilefield_social]
MOV [skypeid,core],[skypeid,profilefield_social]
MOV [icqnumber,core],[icqnumber,profilefield_social]
MOV [msnid,core],[msnid,profilefield_social]
MOV [webpage,core],[webpage,profilefield_social]
AMOS END
2021-04-21 11:22:25 +02:00
Marina Glancy
57a444d31f MDL-71017 oath2: configuration check fix and return types 2021-04-20 12:07:54 +02:00
David Matamoros
5a6f05c605 MDL-71017 tool_oauth2: Small fixes on Oauth 2 services UI and tests 2021-04-20 10:50:44 +02:00
Marina Glancy
0152fdbdff MDL-71017 oauth2: configure some oauth2 services for login only 2021-04-20 10:50:40 +02:00
Sara Arjona
7afda52e62 MDL-70722 oauth2: move Nextcloud methods to service class 2021-03-26 09:20:52 +01:00
Sara Arjona
fdaa958ff7 MDL-70722 oauth2: move Microsoft methods to service class 2021-03-26 09:20:52 +01:00
Sara Arjona
0b53d70ae9 MDL-70722 oauth2: move Facebook methods to service class 2021-03-26 09:20:52 +01:00
Sara Arjona
5d93de8b67 MDL-70722 core_badges: minor fixes from MDL-70689
In MDL-70689, Eloy and Helen suggested some fixes to improve this patch.
As this is a followup issue to move the pending services, this
very first commit will fix pending things raised in the parent issue.
2021-03-26 09:20:52 +01:00
Sara Arjona
0f59f19d3b MDL-70689 oauth2: self-register IMS OBv2.1 services
IMS OBv2.1 services have a registration endpoint to get client id
and secret.
This patch adds and implements the "register" method for the IMS
Open Badges Connect discovery system, to get the proper client id
and secret values.
2021-03-12 12:31:24 +01:00
Sara Arjona
5066c60206 MDL-70689 oauth2: add support to IMS OBv2.1 service
In order to make easier to create and maintain new OAuth2 services,
a couple of classes have been added:

- discovery\* contains methods related to the discovery system. Until
now, only OpenID Connect was supported by Moodle so all the code was
centralised in api.php.
With this patch, as IMS OBv2.1 has a different discovery system, a new
abstract class (base_definition) has been added to be called and let
every discovery system (OpenID Connect, IMS Badge Connect...)
implement their own methods.

- service\* . Instead of keep adding methods to the api, the service
namespace has been created to store all the standard issuer services.
An interface (issuer_interface) has been created and all the services
should implement it.
This patch creates the "IMS OBv2.1" and "Custom" services and moves
the methods for "Google" service because it uses the OpenID connect
discovery system.
2021-03-12 12:31:22 +01:00
Leon Stringer
5070f0d7ce MDL-70282 oauth: Improve error information
If the request to the OAuth 2 token endpoint fails show the response
body the endpoint returned with its HTTP status (when debug: DEVELOPER).
If no response is available show any error returned by Curl.  Previously
none of this information was available making troubleshooting difficult.

If a token refresh fails in \core\oauth2\refresh_system_tokens_task an
exception is now thrown so that the result is shown as "Fail" on
admin/tasklogs.php?filter=core\oauth2\refresh_system_tokens_task
2021-01-28 10:00:18 +00:00
David Mudrák
16d8706e2e MDL-70430 oauth2: Fix storing of the new refresh token
There was a typo - missing underscore. As a result, the new refresh
token was never updated in the database. Depending on the issuer and
whether or when theyu invalidate issued refresh tokens, this might or
might not make the token refresh stop working.
2020-12-08 11:26:23 +01:00
Jake Dallimore
0132037427 MDL-59510 core_oauth2: add autorefresh mode to oauth2\client
Changes:
- The client can now be instantiated with the new mode enabled.
- A user refresh token will be stored if returned as part of the
authorization_code grant but only if the user is authenticated and only
if the mode is enabled.
- If the mode permits it, attempt to exchange a stored refresh token for
a new access token during login checks, allowing access to continue
across sessions without the need to re-grant consent every time.
- Purge all refresh tokens for a given user, issuer and scope on client
log out. This makes sure logout persists across logins.
2020-10-05 09:19:29 +08:00
Mark Nelson
4b0cf053dc MDL-64206 core: updated FB logo URL 2018-12-03 12:20:51 +08:00
Jun Pataleta
69b6e2e9bc Merge branch 'MDL-64079-master' of https://github.com/Dagefoerde/moodle 2018-11-21 22:44:16 +08:00
Jan Dageförde
121fa4381e
MDL-64079 oauth2: Set an arbitrary expiration date for eternal tokens
The oauth2 standard does not require access tokens to have an
expiration date. This assumes a default validity period of 7 days unless
an explicit expiration date is communicated by the server.
2018-11-21 10:07:14 +01:00
Jan Dageförde
3559677cb7
MDL-64078 oauth2: Google service relies on autodiscovery 2018-11-20 16:43:35 +01:00
Jan Dageförde
f11a7d6a05
MDL-63696 oauth2: Store system account access tokens in DB 2018-11-16 11:43:16 +01:00
Jan Dageförde
daef88213b MDL-58943 oauth2: use standard way of URL validation 2018-10-31 10:42:58 +08:00
Tobias Reischmann
3e3e120d3a MDL-58943 oauth2: Added nextcloud to standard issuers
* New button allows to create standard issuer for nextcloud
* Since the endpoints url has to be https and nextcloud relys on the
baseurl to create the endpoints, the baseurl of issuers has now to be
https as well (or empty).
* Google's baseurl was changed to https (there was no reason not to),
whereas Facebook and Microsoft baseurls remain empty.
* In case of the creation of a nextcloud issuer, the baseurl is
required.
* Nextcloud requires the baseurl, therefore a parameter is added to
create_standard_issuer($type, $baseurl = false). That parameter not
required (or used) for anything but Nextcloud.
2018-10-31 10:42:58 +08:00
Tobias Reischmann
fa6cd89b24 MDL-58943 oauth2: Split issuer initialization from endpoint creation
* Splitted the initialization of default values for issuers, the
creation of the issuer, and the creation of its endpoints. This is
a fix for following use case:
 1. A user creates a standard issuer.
 2. She cancels the form.
 3. However, the issuer was already created. Thus, the cancel had no
effect.
* The function create_standard_issuer($type) can still be used to create
issuers programmatically if all required data is known beforehand (e.g.,
during upgrade or in tests).
2018-10-31 10:42:57 +08:00
Jun Pataleta
7766dbed5d MDL-61826 auth: Make Facebook endpoints more maintainable 2018-06-06 12:44:24 +08:00
Łukasz Szeremeta
ac45c16544 MDL-61826 auth: Facebook OAuth2 - getting a better-quality profile photo
Get 200x200 px instead of 50x50 px user profile picture from Facebook OAuth2.
2018-06-06 12:09:09 +08:00