1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Class for loading/storing oauth2 endpoints from the DB. 19 * 20 * @package core 21 * @copyright 2017 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace core\oauth2; 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 use core\persistent; 29 use lang_string; 30 31 /** 32 * Class for loading/storing oauth2 endpoints from the DB 33 * 34 * @copyright 2017 Damyon Wiese 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class endpoint extends persistent { 38 39 const TABLE = 'oauth2_endpoint'; 40 41 /** 42 * Return the definition of the properties of this model. 43 * 44 * @return array 45 */ 46 protected static function define_properties() { 47 return array( 48 'issuerid' => array( 49 'type' => PARAM_INT 50 ), 51 'name' => array( 52 'type' => PARAM_ALPHANUMEXT, 53 ), 54 'url' => array( 55 'type' => PARAM_URL, 56 ) 57 ); 58 } 59 60 /** 61 * Custom validator for end point URLs. 62 * Because we send Bearer tokens we must ensure SSL. 63 * 64 * @param string $value The value to check. 65 * @return lang_string|boolean 66 */ 67 protected function validate_url($value) { 68 if (strpos($value, 'https://') !== 0) { 69 return new lang_string('sslonlyaccess', 'error'); 70 } 71 return true; 72 } 73 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body