78 Commits

Author SHA1 Message Date
Ilya Tregubov
38230b57e4
Merge branch 'MDL-77840-master' of https://github.com/davewoloszyn/moodle 2023-05-16 09:46:05 +08:00
David Woloszyn
b318ce307d MDL-77840 mnet: Avoid passing nulls to base64_encode 2023-05-02 13:46:41 +10:00
Matt Porritt
02826f4395 MDL-76929 Libraries: Upgrade phpxmlrpc to 4.10.1 2023-03-14 14:45:42 +11:00
Eloy Lafuente (stronk7)
621d75dbce MDL-76053 admin: Remove various warnings related to MNet
This partially reverts MDL-73270, where some useful environmental
checks and notifications in the admin UI were added to inform
about different parts of Moodle relying on the "unsupported"
php-xmlrpc extension.

Since then, some changes have happened in core, only available
for Moodle 4.1 and up (see the MDL-70889 mini-epic). Namely:

  - MNet (SSO, roaming, auth, enrol and Mahara portfolio) are not
    using the php-xmlrpc extension anymore, but a pure php library.
  - The xmlrpc webservices protocol, has been move from core to
    the plugins directory, although it continues using the php-xmlrpc
    extension.

Because of that here we are removing all the checks and notifications
related with MNet (not using the extension anymore), but keeping the
webservice plugin ones (still using the extension). Surely if some day the
protocol stops using the extension, we'll be able to remove the
corresponding checks too. But that's future.

Note the associated lang strings have been also removed (not deprecated)
because they were highly specific and hardly reusable:
  - xmlrpcmaharaenabled
  - xmlrpcmnetauthenticationenabled
  - xmlrpcmnetenabled

And very same applies, because MNet doesn't contain anything deprecated
or not supported anymore, hence, straight deletion, to the function:
  - mnet_get_deprecation_notice()

Also, related tests using any of the removed stuff above have been deleted.

In the other side, the "check_xmlrpc_usage" continues existing and
being used both by environment checks and admin notifications but,
as commented above, now it only looks for the xmlrpc webservice
protocol now.
2022-11-08 16:49:18 +01:00
Eloy Lafuente (stronk7)
73bc677346 MDL-76055 mnet: Switch the keyswap to use the library
This service is different from the rest because it
doesn't run encrypted, but plain xmlrpc. Hence, we
cannot use the normal mnet_xmlrpc_client (that provides
on-the-fly encryption and signing).

So, instead, let's instantiate a custom client here
and use it for this pure xmlrpc request and response.

PS: It's curious that this exact sevice has support
for proxies but the mnet_xmlrpc_client one has not. I'm not
going to modify that here, but have left a comment
in the code about that.

PS: Some small style changes have been applied around
the modified code (spacing, &&, comments...)
2022-11-02 15:56:38 +01:00
Eloy Lafuente (stronk7)
856b593796 MDL-75645 mnet: Stop caching OpenSSLAsymmetricKey keys
The mnet_environment->keypair array contains the following
elements (and more, just focussing on these):
- keypair_PEM : textual representation of the private key.
- certificate : textual representation of the public key.
- privatekey  : OpenSSLAsymmetricKey representation of the private key,
                generated from keypair_PEM. See get_private_key().
- publickey   : OpenSSLAsymmetricKey representation if the public key,
                generated from certificate. See get_public_key().

The last 2 elements in the array are only used as "caching", to avoid
having to call to openssl_pkey_get_private() and
openssl_pkey_get_public() to convert from the textual representation
to the OpenSSLAsymmetricKey representation that is the one required
by a number of openssl functions.

Problems arrive when, as part of the MNet protocol, the mnet_environment
is serialised, because, since PHP 8.0 those OpenSSLAsymmetricKey objects
aren't serialisable any more.

So, as far as they are only used for internal caching it's perfectly ok
to remove the caching bits and use the openssl_pkey_get_xxx() methods
to calculate them under demand.

The alternative to this would be to implement into the mnet_environment
some custom serialisation, skipping those OpenSSLAsymmetricKey
instances, using __sleep(), the Serializabla interface or __serialize(),
but that seems unnecessary because, as explained above, the uses are
really limited and easily replaceable.

That's what this patch does.
2022-10-18 14:30:50 +02:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
Adam Olley
c24922fb40 MDL-74394 mnet: Better check for openssl_get_publickey() failure
In PHP8, this func now returns an object of type OpenSSLAsymmetricKey, not a
resource.

Reference:
https://www.php.net/manual/en/function.openssl-pkey-get-public.php
2022-04-01 14:32:50 +10:30
Víctor Déniz
8890a730fc Merge branch 'MDL-73517' of https://github.com/stronk7/moodle 2022-02-03 22:02:39 +00:00
Eloy Lafuente (stronk7)
b524f21b44 MDL-73517 mnet: add some openssl missing parameters
Since php80 the 5th parameter (cypher) in the following functions:
  - openssl_seal
  - openssl_open
is mandatory, hence:
  - adding it.
  - with value 'RC4' to keep BC.
2022-01-28 20:10:52 +01:00
Huong Nguyen
683375af8b MDL-73270 admin: Warn about xmlrpc webservice protocol enabled
Co-authored-by: Andrew Lyons <andrew@nicols.co.uk>
2022-01-28 09:32:08 +07:00
Eloy Lafuente (stronk7)
d2ad5e8461 MDL-73523 libraries: openssl_free_xxx() methods are deprecated in php80
So we are putting them under a standard PHP_MAJOR_VERSION < 8 condition.

Also, added TODO comments to remember to delete that block of code when
php80 becomes the minimum required versions in the future (Moodle 4.3?).

When possible, an issue has been created upstream, else a comment in
readme_moodle files has been added.

Finally, when the keys being freed were class or object attributes, also
nullify them (but when the calls were part of destructor methods).
2022-01-20 14:48:22 +01:00
David Mudrák
2b604286b5 MDL-57775 xmlrpc: Pass escaping to xmlrpc_encode_request() calls
This patch adds the missing 'escaping' option to all remaining
xmlrpc_encode_request() calls in the moodle core code.

Without this, the xmlrpc_decode_request() call on the server side may
lead to wrongly decoded non-ascii characters.
2017-08-15 21:43:34 +02:00
Vadim Dvorovenko
28d20df9ba MDL-48779 MNet: multibyte substr in certificate generation
Using core_text::substr instead of substr for trimming certificate
data. Is needed for sites with long unicode sitename to prevent
breaking line between unicode pair.
2015-01-16 09:37:19 +07:00
Mark Nelson
601c998c64 MDL-44746 core_events: removed incorrect uses of snapshots 2014-03-29 15:25:49 -07:00
Petr Škoda
9ede00db18 MDL-44500 detect context-courseid inconsistencies in new events 2014-03-14 12:08:12 +08:00
Mark Nelson
0b7422f366 MDL-40051 core_mnet: replaced add_to_log calls with events 2014-01-19 18:30:40 -08:00
Sam Hemelryk
f44e7d0a77 Merge branch 'MDL-36357' of git://github.com/danpoltawski/moodle
Conflicts:
	user/view.php
2013-01-09 09:34:22 +13:00
Petr Škoda
63a15b38ad MDL-36893 fix mnet E_STRICT issue 2012-12-27 14:32:31 +01:00
Dan Poltawski
0e35ba6ffc MDL-36357 cleanup - remove double semicolons 2012-11-15 09:51:26 +08:00
David Mudrak
8a6f2291f2 MDL-30170 MNet peers administration - highlight the undelete widget
The patch highlights the undelete radio selector at the host edit form.
It moves it to the end of the form (near the submit button) and displays
an explanation above the radio selector.

Also, the list of deleted hosts is now displayed below the table of
active peers at the Manage peers page.

The data returned by mnet_get_hosts() function now contain the deleted
status, too. It is possible to obtain deleted hosts from that function
now.
2011-12-15 21:51:31 +01:00
David Mudrak
a014e3bcd8 MDL-27107 auth_mnet - consider all incoming roaming users as confirmed
The 'confirmed' field can't be optional. If the identity provider did
not export it, the new remote user would be created with 'confirmed' set
to default zero and as such could be a subject of scheduled deletion.
2011-08-28 02:44:45 +02:00
David Mudrak
35d76df31d MDL-25367 user images are sent a received over MNet during SSO again 2010-11-26 09:19:55 +00:00
David Mudrak
13b78fda00 Profile fields to be synced via MNet now respect the 'use defaults' option 2010-11-26 09:19:44 +00:00
Petr Skoda
a9637e7df4 MDL-14679 fixed a lot more old style uses of insert_record() 2010-09-03 17:47:41 +00:00
David Mudrak
4378e6a2ff MDL-23600 MNet: do not rely on existing user record with ID 1 2010-08-08 10:58:38 +00:00
Dan Marsden
2c0b7ba20e MNET MDL-23001 bad use of get_config causing mnet SSO fail. 2010-06-30 02:08:35 +00:00
Penny Leach
fd1972490e mnet MDL-14117 truncate values in $dn to the RFC 3280 lengths when making new mnet keys
merged from MOODLE_19_STABLE
2010-02-18 03:11:51 +00:00
Penny Leach
f867d2aa77 mnet NOBUG added some phpdocs 2010-02-17 01:37:55 +00:00
Penny Leach
fc363065cb mnet MDL-21582 fixing notices 2010-02-16 02:37:42 +00:00
Penny Leach
61506902f3 mnet MDL-20660 allow admins to configure fields to be sent over mnet 2010-02-16 02:05:30 +00:00
jerome mouneyrac
c044e281b5 mnet MDL-21582 fix empty mnet debug variable that display a notice on the peer services page 2010-02-11 08:20:27 +00:00
Penny Leach
d36fa8159b mnet MDL-21256 reworked some more of admin/mnet to use forms and new output stuff 2010-02-11 02:50:28 +00:00
Penny Leach
96bd292127 mnet MDL-21256 & the start of a proper fix for MDL-20660
Unfortunately these are tangled up together a bit
2010-02-11 02:49:11 +00:00
Penny Leach
71f61c41f3 mnet MDL-15505 added new mnet_debug function and started migrating to it 2010-02-05 03:56:45 +00:00
Penny Leach
287efec6f6 mnet MDL-21276 get rid of all the $MNET* globals 2010-02-02 03:13:40 +00:00
Penny Leach
de260e0f7b mnet MDL-21261 large overhaul. This commit changes:
- The way that mnet rpc functions are registered.  Plugins must now
  create db/mnet.php which is an array, similar to services.php.  This
  *replaces* the old mnet_publishes() functions.  version.php must be
  bumped to trigger this.

- More information about each rpc-available function is stored in the
  database, including the class it belongs to, the file it is found in,
  and whether or not it is static.  Methods that are not static must be
  in a class with a constructor that takes no arguments (this can easily
  be achieved with a small wrapper if necessary)

- The xmlrpc dispatcher has been rewritten to remove all the
  dependencies on hardcoded information about auth,mnet,portfolio and
  repository, and just use the information in the database.

- The old hardcoded hidden mnet/testclient.php has been moved to the
  Admin menu under "Development" and rewritten.

- The xmlrpc introspection method profiling is now using php and zend
  reflection - which is a lot nicer than the old way, which was using a
  php-based php parser.  This fixes some inconsistent handling of
  methods without arguments that were advertising their return value as
  the only method parameter.  While this is a *fix*, it breaks BC
  slightly - the old 1.9 broken mnet/testclient.php will now not work
  properly with 2.0

- Dangerous mode is still supported, but old mod/*/rpclib.php is
  now unsupported, due to the fact that any plugin can export mnet
  functions with db/mnet.php.  This is a slight BC break.

Still TODO:

- TEST TEST TEST
- Document the two small BC breaks in release notes
- Document the contract for db/mnet.php
2010-01-28 05:25:50 +00:00
Penny Leach
939ea0bc44 mnet MDL-21294 change errors to exceptions in mnet server 2010-01-13 01:08:38 +00:00
Penny Leach
47c18e9b98 mnet MDL-17735 changed signature method url to rsa, not dsa 2010-01-12 01:59:47 +00:00
Penny Leach
bac44e6dc9 mnet MDL-19239 changed all instances of fetching config from db to use get_config 2010-01-11 22:53:11 +00:00
Petr Skoda
3f226cc99f MDL-20639 fixed mnet security trouble - credit goes to Adrian Schlegel 2009-11-17 17:32:17 +00:00
Petr Skoda
1d42298086 MDL-20700 coding style cleanup - cvs keywords removed, closign php tag removed, trailing whitespace cleanup 2009-11-01 12:22:45 +00:00
danmarsden
45e4294df2 MNET MDL-13503 allow path to openssl.cnf to be set in config so that windows installs and packages can reliably enable networking. 2009-09-11 10:01:14 +00:00
skodak
0a127169fe MDL17980 reverting last commit - other devs agreed, to be explained in tracker 2009-08-03 07:35:41 +00:00
peterbulmer
1b509b3699 MDL17980 mnet improvements
* Allow multiple roles to be allocated by identity provider
* Allow existing enrolment plugins to manage mnet enrolments


Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
2009-08-03 03:38:23 +00:00
nicolasconnault
6dbcaceef1 MDL-19418 Replaced ereg* by preg* 2009-06-22 01:22:37 +00:00
skodak
1caea91efb MDL-17457 moved a lot of code into lib/db/install.php + other refactoring and cleanup 2009-01-11 09:41:48 +00:00
skodak
b636fdfbc1 MDL-14123 Full IPv6 support - replaced mnet ip_in_range() by standard ipv6 compatible address_in_subnet(); replaced $_SERVER['REMOTE_ADDR'] with standard getremoteaddr() 2009-01-09 21:41:47 +00:00
jonathanharker
078c1134bf MDL-17548 MNET: Fix email links for sites with path component in wwwroot
Where Moodle sites had a path in their wwwroot, the MNET function that
forced remote users to go via their identity provider (to make sure they
were logged in) previously directed the user back to a URL like
contentprovider.com/moodle/moodle/mod/forum/view.php?f=7 where there
should only be one /moodle in the middle of the URL.
2008-12-14 22:50:22 +00:00
skodak
eb7f89bc15 MDL-17419 misconfigured openssl extension blocks installation - openssl.cnf missing?? 2008-11-28 12:54:15 +00:00