9 Commits

Author SHA1 Message Date
Daniel Tomé Fernández
dc66123341 #13 - Added privacy metadata translations 2022-02-17 09:13:29 +01:00
Jordi Pujol-Ahulló
2c2ba642c8 Merge pull request #14 from SREd-URV/13-added-privacy-provider
13 - Added privacy provider file
2022-02-16 21:09:33 +01:00
Daniel Tomé Fernández
0618160ac1 13 - Added privacy provider file 2022-02-16 16:52:30 +01:00
Jordi Pujol-Ahulló
b17f083c5a add releasing badge 2021-08-13 14:20:48 +02:00
Jordi Pujol-Ahulló
44e6261d5b Add badge 2021-08-13 14:19:14 +02:00
Jordi Pujol Ahulló
7f2386a387 #12 - use github actions to pass CI and release plugin version
#12 - fix test API

 #12 - update minimum required Moodle version

 #12 - update CHANGES.md
2021-08-11 09:30:04 +02:00
Dani Tome
ccd177ed57 Updated version from version.php 2018-05-30 15:38:10 +02:00
Jordi Pujol-Ahulló
84cfa962c3 Merge pull request #10 from SREd-URV/moodle-34-support
Added support to Moodle v3.3+
2018-05-30 13:49:11 +02:00
Dani Tome
6d30969f42 Added support to Moodle v3.3+ 2018-05-30 12:57:25 +02:00
14 changed files with 281 additions and 139 deletions

119
.github/workflows/moodle-ci.yml vendored Normal file
View File

@@ -0,0 +1,119 @@
name: Moodle Plugin CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
# https://tracker.moodle.org/browse/MDL-72131
image: mariadb:10.5
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
strategy:
fail-fast: false
matrix:
include:
- php: '7.4'
moodle-branch: 'MOODLE_311_STABLE'
database: 'pgsql'
extensions: "mbstring, pgsql"
- php: '7.3'
moodle-branch: 'MOODLE_310_STABLE'
database: 'mariadb'
extensions: "mbstring, mysqli"
- php: '7.2'
moodle-branch: 'MOODLE_39_STABLE'
database: 'pgsql'
extensions: "mbstring, pgsql"
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
path: plugin
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
coverage: none
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
- name: Install moodle-plugin-ci
run: |
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
- name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint
- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd
- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpmd
- name: Moodle Code Checker
if: ${{ false }}
run: moodle-plugin-ci codechecker --max-warnings 0
- name: Moodle PHPDoc Checker
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpdoc
- name: Validating
if: ${{ always() }}
run: moodle-plugin-ci validate
- name: Check upgrade savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints
- name: Mustache Lint
if: ${{ always() }}
run: moodle-plugin-ci mustache
- name: Grunt
if: ${{ false }}
run: moodle-plugin-ci grunt --max-lint-warnings 0
- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit
- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome

66
.github/workflows/moodle-release.yml vendored Normal file
View File

@@ -0,0 +1,66 @@
#
# Whenever a new tag starting with "v" is pushed, add the tagged version
# to the Moodle Plugins directory at https://moodle.org/plugins
#
# revision: 2021070201
#
name: Releasing in the Plugins directory
on:
push:
tags:
- 2*
workflow_dispatch:
inputs:
tag:
description: 'Tag to be released'
required: true
defaults:
run:
shell: bash
jobs:
release-at-moodle-org:
runs-on: ubuntu-latest
env:
PLUGIN: auth_ip
CURL: curl -s
ENDPOINT: https://moodle.org/webservice/rest/server.php
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
FUNCTION: local_plugins_add_version
steps:
- name: Call the service function
id: add-version
run: |
if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then
TAGNAME="${{ github.event.inputs.tag }}"
elif [[ $GITHUB_REF = refs/tags/* ]]; then
TAGNAME="${GITHUB_REF##*/}"
fi
if [[ -z "${TAGNAME}" ]]; then
echo "No tag name has been provided!"
exit 1
fi
ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}"
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
--data-urlencode "wsfunction=${FUNCTION}" \
--data-urlencode "moodlewsrestformat=json" \
--data-urlencode "frankenstyle=${PLUGIN}" \
--data-urlencode "zipurl=${ZIPURL}" \
--data-urlencode "vcssystem=git" \
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--data-urlencode "vcstag=${TAGNAME}" \
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
--data-urlencode "altdownloadurl=${ZIPURL}")
echo "::set-output name=response::${RESPONSE}"
- name: Evaluate the response
id: evaluate-response
env:
RESPONSE: ${{ steps.add-version.outputs.response }}
run: |
jq <<< ${RESPONSE}
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null

View File

@@ -1,67 +0,0 @@
language: php
sudo: required
addons:
firefox: "47.0.1"
postgresql: "9.3"
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
cache:
directories:
- $HOME/.composer/cache
- $HOME/.npm
php:
- 7.0
- 7.1
env:
matrix:
- DB=pgsql MOODLE_BRANCH=MOODLE_32_STABLE
- DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE
- DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
- DB=pgsql MOODLE_BRANCH=master
- DB=mysqli MOODLE_BRANCH=MOODLE_32_STABLE
- DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE
- DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE
- DB=mysqli MOODLE_BRANCH=master
matrix:
include:
- php: 5.6
env: DB=pgsql MOODLE_BRANCH=MOODLE_32_STABLE
- php: 5.6
env: DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE
- php: 5.6
env: DB=mysqli MOODLE_BRANCH=MOODLE_32_STABLE
- php: 5.6
env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE
allow_failures:
- env: MOODLE_BRANCH=master
before_install:
- phpenv config-rm xdebug.ini
- nvm install 8.9
- nvm use 8.9
- cd ../..
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
install:
- moodle-plugin-ci install
script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
# - moodle-plugin-ci codechecker
- moodle-plugin-ci validate
- moodle-plugin-ci savepoints
- moodle-plugin-ci mustache
# - moodle-plugin-ci grunt
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat

15
CHANGES.md Normal file
View File

@@ -0,0 +1,15 @@
Release notes
=============
1. (#12) Minimum Moodle version supported is 3.3.
1. (#12) Use Github Actions to pass tests and update release on Moodle Plugins directory.
1. (#13) Added privacy metadata file.
Contributors
============
Maintained by:
* Jordi Pujol-Ahulló (at SREd, Universitat Rovira i Virgili).
[See all Github contributors](https://github.com/SREd-URV/moodle-auth_ip/graphs/contributors)

View File

@@ -1,3 +1,5 @@
[![Moodle Plugin CI](https://github.com/SREd-URV/moodle-auth_ip/actions/workflows/moodle-ci.yml/badge.svg)](https://github.com/SREd-URV/moodle-auth_ip/actions/workflows/moodle-ci.yml) [![Releasing in the Plugins directory](https://github.com/SREd-URV/moodle-auth_ip/actions/workflows/moodle-release.yml/badge.svg)](https://github.com/SREd-URV/moodle-auth_ip/actions/workflows/moodle-release.yml)
Authentication plugin restricted by IP Authentication plugin restricted by IP
=== ===

View File

@@ -123,21 +123,6 @@ class auth_plugin_ip extends auth_plugin_manual {
return false; return false;
} }
/**
* Prints a form for configuring this authentication plugin.
*
* This function is called from admin/auth.php, and outputs a full page with
* a form for configuring this plugin.
*
* @param array $config An object containing all the data for this page.
* @param string $error
* @param array $user_fields
* @return void
*/
function config_form($config, $error, $user_fields) {
include 'config.html';
}
/** /**
* Updates the list of IPs and sends a notification by email. * Updates the list of IPs and sends a notification by email.
* *

View File

@@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace auth_ip\privacy;
defined('MOODLE_INTERNAL') || die();
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}

View File

@@ -1,52 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Configuration settings form
*
* @package auth
* @subpackage ip
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Robert Boloc <robert.boloc@urv.cat>
* @author Jordi Pujol-Ahulló <jordi.pujol@urv.cat>
* @copyright 2013 onwards Servei de Recursos Educatius (http://www.sre.urv.cat)
*/
// set to defaults if undefined
if (!isset($config->valid_ips)) {
$config->valid_ips = '';
}
?>
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top">
<td align="right"><?php print_string('auth_ipvalidips', 'auth_ip') ?></td>
<td>
<textarea name="valid_ips" cols="70" rows="10"><?php echo $config->valid_ips ?></textarea>
<br>
<?php
print_string('auth_ipexampleips', 'auth_ip');
if (isset($err['valid_ips'])) {
formerr($err['valid_ips']);
}
?>
</td>
<td></td>
</tr>
</table>

View File

@@ -31,3 +31,4 @@ $string['auth_ipmailsubject'] = 'Plugin autenticació restringit per IP: IPs can
$string['auth_ipmailtext'] = 'S\'han actualitzat les IPs acceptades pel plugin d\'autenticació restringit per IP'; $string['auth_ipmailtext'] = 'S\'han actualitzat les IPs acceptades pel plugin d\'autenticació restringit per IP';
$string['auth_ipvalidips'] = 'IPs vàlides'; $string['auth_ipvalidips'] = 'IPs vàlides';
$string['pluginname'] = 'Autenticació per IP'; $string['pluginname'] = 'Autenticació per IP';
$string['privacy:metadata'] = 'El plugin Autenticació per IP no emmagatzema cap dada personal.';

View File

@@ -31,3 +31,4 @@ $string['auth_ipmailsubject'] = 'IPs changed on authentication plugin by IP';
$string['auth_ipmailtext'] = 'Accepted IPs for the authentication plugin by IP have been updated.'; $string['auth_ipmailtext'] = 'Accepted IPs for the authentication plugin by IP have been updated.';
$string['auth_ipvalidips'] = 'Valid IPs'; $string['auth_ipvalidips'] = 'Valid IPs';
$string['pluginname'] = 'Authentication by IP'; $string['pluginname'] = 'Authentication by IP';
$string['privacy:metadata'] = 'The Authentication by IP plugin does not store any personal data.';

View File

@@ -31,3 +31,4 @@ $string['auth_ipmailsubject'] = 'Plugin de autenticación restringido por IP: IP
$string['auth_ipmailtext'] = 'Se han actualizado las IPs aceptadas por el plugin de autenticación restringido por IP'; $string['auth_ipmailtext'] = 'Se han actualizado las IPs aceptadas por el plugin de autenticación restringido por IP';
$string['auth_ipvalidips'] = 'IPs válidas'; $string['auth_ipvalidips'] = 'IPs válidas';
$string['pluginname'] = 'Autenticación por IP'; $string['pluginname'] = 'Autenticación por IP';
$string['privacy:metadata'] = 'El plugin Autenticación por IP no almacena ningún dato personal.';

40
settings.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @author Daniel Tomé <danieltomefer@gmail.com>
* @copyright 2017 Servei de Recursos Educatius (http://www.sre.urv.cat)
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(
new admin_setting_heading(
'auth_ip/auth_ipdescription',
'',
new lang_string('auth_ipdescription', 'auth_ip')
)
);
$settings->add(
new admin_setting_configtextarea(
'auth_ip/valid_ips',
new lang_string('auth_ipvalidips', 'auth_ip'),
new lang_string('auth_ipexampleips', 'auth_ip'),
''
)
);
}

View File

@@ -22,7 +22,7 @@ require_once($CFG->dirroot.'/auth/ip/auth.php');
class auth_ip_testcase extends advanced_testcase { class auth_ip_testcase extends advanced_testcase {
protected $authplugin; protected $authplugin;
protected function setUp() { protected function setUp() : void {
$this->authplugin = new auth_plugin_ip(); $this->authplugin = new auth_plugin_ip();
} }

View File

@@ -27,9 +27,8 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017020800; // The current plugin version (Date: YYYYMMDDXX) $plugin->version = 2022021700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012120300; // Requires this Moodle version (2.4) $plugin->requires = 2017051500; // Requires this Moodle version (3.3) for changes in settings.php.
$plugin->component = 'auth_ip'; // Full name of the plugin (used for diagnostics) $plugin->component = 'auth_ip'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->release = '1.3 (Build: 2017020800)'; $plugin->release = '2022021700';