Plugin Directory

Changeset 3094861


Ignore:
Timestamp:
05/29/2024 11:34:58 PM (22 months ago)
Author:
ider
Message:

New v2.1 release

Location:
ider-login
Files:
106 added
9 edited

Legend:

Unmodified
Added
Removed
  • ider-login/trunk/composer.lock

    r3092775 r3094861  
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "dfb71de64d041af8650a961adc2497f6",
     7    "content-hash": "5805eb0b1c391a5c0754fc62eae66df2",
    88    "packages": [
    99        {
    1010            "name": "jlmsrl/ider-openid-client-php",
    11             "version": "1.1.3",
     11            "version": "1.1.4",
    1212            "source": {
    1313                "type": "git",
    14                 "url": "https://github.com/iDUCKsrl/ider-openid-client-php.git",
    15                 "reference": "208b926e77c4ccc200da5acbd5e1bfc8bebc361b"
     14                "url": "https://github.com/iDuckSRL/ider-openid-client-php.git",
     15                "reference": "a7c1603c1084b83f87cc0d94f5194621e4950f53"
    1616            },
    1717            "dist": {
    1818                "type": "zip",
    19                 "url": "https://api.github.com/repos/iDUCKsrl/ider-openid-client-php/zipball/208b926e77c4ccc200da5acbd5e1bfc8bebc361b",
    20                 "reference": "208b926e77c4ccc200da5acbd5e1bfc8bebc361b",
     19                "url": "https://api.github.com/repos/iDuckSRL/ider-openid-client-php/zipball/a7c1603c1084b83f87cc0d94f5194621e4950f53",
     20                "reference": "a7c1603c1084b83f87cc0d94f5194621e4950f53",
    2121                "shasum": ""
    2222            },
     
    4646            "description": "IDER OpenID Generic Client for PHP",
    4747            "support": {
    48                 "issues": "https://github.com/iDUCKsrl/ider-openid-client-php/issues",
    49                 "source": "https://github.com/iDUCKsrl/ider-openid-client-php/tree/v1.1.3"
     48                "issues": "https://github.com/iDuckSRL/ider-openid-client-php/issues",
     49                "source": "https://github.com/iDuckSRL/ider-openid-client-php/tree/v1.1.4"
    5050            },
    51             "time": "2024-05-12T03:59:48+00:00"
     51            "time": "2024-05-29T23:09:00+00:00"
    5252        },
    5353        {
  • ider-login/trunk/includes/IDER_Helpers.php

    r3092775 r3094861  
    5757        fclose($handle);
    5858    }
    59 
    60 
    61     static function isJSON($string){
    62         return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
    63     }
    6459}
  • ider-login/trunk/includes/IDER_UserInfoManager.php

    r3092775 r3094861  
    11<?php
     2
     3use IDERConnect\IDERHelpers;
    24
    35/**
     
    1012 *
    1113 */
    12 
    1314class IDER_UserInfoManager
    1415{
    15 
    16 
    1716    static function normalize($user_info)
    1817    {
    19         $user_info = (array)$user_info;
     18        $user_info = IDERHelpers::toArray($user_info);
     19        $user_info = IDERHelpers::remapFields($user_info);
    2020
    2121        // explode json packed claims
    22         $user_info = self::_checkJsonfields($user_info);
     22        $user_info = self::_flattenFields($user_info);
    2323
    2424        // remap openID fields into local fields
    2525        $user_info = self::_fieldsMap($user_info);
    2626
    27         $user_info = (object)$user_info;
     27        $user_info = (object) $user_info;
    2828
    2929        return $user_info;
    3030    }
    31 
    3231
    3332    private static function _fieldsMap($userdata)
     
    4746    }
    4847
     48    private static function _flattenFields($userdata)
     49    {
     50        $result = [];
    4951
    50     private static function _checkJsonfields($userdata)
    51     {
    52 
    53         foreach ($userdata as $key => $claim) {
    54             if (IDER_Helpers::isJSON($claim)) {
    55                 $subclaims = json_decode($claim);
    56 
    57                 // break down the claim
    58                 foreach ($subclaims as $subkey => $subclaim) {
    59                     $userdata[$key . '.' . $subkey] = $subclaim;
     52        $flatten = function ($data, $parentKey = '') use (&$flatten, &$result) {
     53            foreach ($data as $key => $value) {
     54                $newKey = $parentKey === '' ? $key : $parentKey . '.' . $key;
     55                if (is_array($value) || is_object($value)) {
     56                    $flatten((array)$value, $newKey);
     57                } else {
     58                    $result[$newKey] = $value;
    6059                }
    61 
    62                 // delete the original claim
    63                 unset($userdata[$key]);
    6460            }
    65         }
    66 
    67         return $userdata;
     61        };
     62   
     63        $flatten($userdata);
     64   
     65        return $result;
    6866    }
    69 
    70 
    7167}
  • ider-login/trunk/readme.md

    r3092775 r3094861  
    33Requires at least: 4.6
    44Tested up to: 6.5.3
    5 Stable tag: 2.0
     5Stable tag: 2.1
    66License: Apache License, Version 2.0 or later
    77License URI: http://directory.fsf.org/wiki/License:Apache2.0
  • ider-login/trunk/vendor/composer/installed.json

    r3092775 r3094861  
    33                {
    44                        "name": "jlmsrl/ider-openid-client-php",
    5                         "version": "1.1.3",
    6                         "version_normalized": "1.1.3.0",
     5                        "version": "1.1.4",
     6                        "version_normalized": "1.1.4.0",
    77                        "source": {
    88                                "type": "git",
    9                                 "url": "https://github.com/iDUCKsrl/ider-openid-client-php.git",
    10                                 "reference": "208b926e77c4ccc200da5acbd5e1bfc8bebc361b"
     9                                "url": "https://github.com/iDuckSRL/ider-openid-client-php.git",
     10                                "reference": "a7c1603c1084b83f87cc0d94f5194621e4950f53"
    1111                        },
    1212                        "dist": {
    1313                                "type": "zip",
    14                                 "url": "https://api.github.com/repos/iDUCKsrl/ider-openid-client-php/zipball/208b926e77c4ccc200da5acbd5e1bfc8bebc361b",
    15                                 "reference": "208b926e77c4ccc200da5acbd5e1bfc8bebc361b",
     14                                "url": "https://api.github.com/repos/iDuckSRL/ider-openid-client-php/zipball/a7c1603c1084b83f87cc0d94f5194621e4950f53",
     15                                "reference": "a7c1603c1084b83f87cc0d94f5194621e4950f53",
    1616                                "shasum": ""
    1717                        },
     
    2222                                "phpseclib/phpseclib": "^2.0.47"
    2323                        },
    24                         "time": "2024-05-12T03:59:48+00:00",
     24                        "time": "2024-05-29T23:09:00+00:00",
    2525                        "type": "library",
    2626                        "installation-source": "dist",
     
    4343                        "description": "IDER OpenID Generic Client for PHP",
    4444                        "support": {
    45                                 "issues": "https://github.com/iDUCKsrl/ider-openid-client-php/issues",
    46                                 "source": "https://github.com/iDUCKsrl/ider-openid-client-php/tree/v1.1.3"
     45                                "issues": "https://github.com/iDuckSRL/ider-openid-client-php/issues",
     46                                "source": "https://github.com/iDuckSRL/ider-openid-client-php/tree/v1.1.4"
    4747                        },
    4848                        "install-path": "../jlmsrl/ider-openid-client-php"
  • ider-login/trunk/vendor/composer/installed.php

    r3092775 r3094861  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '1351ab3c6721dcd1c9cdde602f92ba33e4d21de5',
     6        'reference' => 'bf4c8ef431ca828518887822c464fdfb835eb3c6',
    77        'type' => 'project',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '1351ab3c6721dcd1c9cdde602f92ba33e4d21de5',
     16            'reference' => 'bf4c8ef431ca828518887822c464fdfb835eb3c6',
    1717            'type' => 'project',
    1818            'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'jlmsrl/ider-openid-client-php' => array(
    23             'pretty_version' => '1.1.3',
    24             'version' => '1.1.3.0',
    25             'reference' => '208b926e77c4ccc200da5acbd5e1bfc8bebc361b',
     23            'pretty_version' => '1.1.4',
     24            'version' => '1.1.4.0',
     25            'reference' => 'a7c1603c1084b83f87cc0d94f5194621e4950f53',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../jlmsrl/ider-openid-client-php',
  • ider-login/trunk/vendor/jlmsrl/ider-openid-client-php/composer.json

    r3092775 r3094861  
    33    "description": "IDER OpenID Generic Client for PHP",
    44    "type": "library",
    5     "version": "1.1.3",
     5    "version": "1.1.4",
    66    "license": "Apache-2.0",
    77    "authors": [
  • ider-login/trunk/vendor/jlmsrl/ider-openid-client-php/src/IDERHelpers.php

    r3092775 r3094861  
    8585        return strtr($base64url, '-_', '+/');
    8686    }
     87
     88    /**
     89     * Remap fields for user information.
     90     *
     91     * This function is called by every integration. It checks if the user information contains an address,
     92     * and if the address is in the US, it maps the postal code to the corresponding state.
     93     *
     94     * @param array $userinfo The user information array containing address details.
     95     * @return array The updated user information with the state mapped from the postal code if the address is in the US.
     96     */
     97    static function remapFields($userinfo)
     98    {
     99        // this function will be called by every integration
     100        if (
     101            key_exists('address', $userinfo)
     102        ) {
     103
     104            // US remap
     105            if (
     106                $userinfo['address'] &&
     107                key_exists('country', $userinfo['address']) && $userinfo['address']['country'] === 'US' &&
     108                key_exists('postal_code', $userinfo['address']) && $userinfo['address']['postal_code']
     109            ) {
     110                $user_zip_code = intval($userinfo['address']['postal_code']);
     111
     112                $us_zip_ranges = [
     113                    'AL' => [[35000, 36999]],
     114                    'AK' => [[99500, 99999]],
     115                    'AZ' => [[85000, 86999]],
     116                    'AR' => [[71600, 72999], [75502, 75502]],
     117                    'CA' => [[90000, 96199]],
     118                    'CO' => [[80000, 81699]],
     119                    'CT' => [[6000, 6999]],
     120                    'DE' => [[19700, 19999]],
     121                    'FL' => [[32000, 34999]],
     122                    'GA' => [[30000, 31999], [39800, 39999]],
     123                    'HI' => [[96700, 96999]],
     124                    'ID' => [[83200, 83999]],
     125                    'IL' => [[60000, 62999]],
     126                    'IN' => [[46000, 47999]],
     127                    'IA' => [[50000, 52999]],
     128                    'KS' => [[66000, 67999]],
     129                    'KY' => [[40000, 42999]],
     130                    'LA' => [[70000, 71599]],
     131                    'ME' => [[3900, 4999]],
     132                    'MD' => [[20600, 21999]],
     133                    'MA' => [[1000, 2799], [5500, 5599]],
     134                    'MI' => [[48000, 49999]],
     135                    'MN' => [[55000, 56999]],
     136                    'MS' => [[38600, 39999]],
     137                    'MO' => [[63000, 65999]],
     138                    'MT' => [[59000, 59999]],
     139                    'NE' => [[68000, 69999]],
     140                    'NV' => [[88900, 89999]],
     141                    'NH' => [[3000, 3899]],
     142                    'NJ' => [[7000, 8999]],
     143                    'NM' => [[87000, 88499]],
     144                    'NY' => [[10000, 14999]],
     145                    'NC' => [[27000, 28999]],
     146                    'ND' => [[58000, 58999]],
     147                    'OH' => [[43000, 45999]],
     148                    'OK' => [[73000, 74999]],
     149                    'OR' => [[97000, 97999]],
     150                    'PA' => [[15000, 19699]],
     151                    'RI' => [[2800, 2999]],
     152                    'SC' => [[29000, 29999]],
     153                    'SD' => [[57000, 57999]],
     154                    'TN' => [[37000, 38599]],
     155                    'TX' => [[75000, 79999], [88500, 88599]],
     156                    'UT' => [[84000, 84999]],
     157                    'VT' => [[5000, 5999]],
     158                    'VA' => [[20100, 20199], [22000, 24699]],
     159                    'WA' => [[98000, 99499]],
     160                    'WV' => [[24700, 26899]],
     161                    'WI' => [[53000, 54999]],
     162                    'WY' => [[82000, 83199]],
     163                    'DC' => [[20000, 20099]],
     164                    'AS' => [[96799, 96799]],
     165                    'GU' => [[96910, 96932]],
     166                    'MP' => [[96950, 96952]],
     167                    'PR' => [[600, 799], [900, 999]],
     168                    'VI' => [[800, 899]],
     169                ];
     170
     171                foreach ($us_zip_ranges as $us_state => $us_ranges) {
     172                    foreach ($us_ranges as $us_range) {
     173                        if ($user_zip_code >= $us_range[0] && $user_zip_code <= $us_range[1]) {
     174                            // improper, but it will do it
     175                            $userinfo['address']['state'] = $us_state;
     176                        }
     177                    }
     178                }
     179            } else {
     180                if (key_exists('region', $userinfo['address'])) {
     181                    $userinfo['address']['state'] = $userinfo['address']['region'];
     182                }
     183            }
     184
     185            return $userinfo;
     186        }
     187    }
     188
     189    /**
     190     * Convert object to array.
     191     */
     192    static function toArray($data)
     193    {
     194        if (is_object($data)) {
     195            $data = get_object_vars($data);
     196        }
     197   
     198        if (is_array($data)) {
     199            foreach ($data as $key => $value) {
     200                if (is_string($value) && self::isJSON($value)) {
     201                    $data[$key] = json_decode($value, true);
     202                } else {
     203                    $data[$key] = self::toArray($value);
     204                }
     205            }
     206        }
     207   
     208        return $data;
     209    }
     210
     211    /**
     212     * Check if a string is a JSON.
     213     */
     214    static function isJSON($string){
     215        return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
     216    }
    87217}
  • ider-login/trunk/wp-ider-login-client.php

    r3092775 r3094861  
    44 * Plugin Name: IDer Login
    55 * Plugin URI: https://www.ider.com
    6  * Version: 2.0
     6 * Version: 2.1
    77 * Description: Provides Single Sign On via IDer Identity Server
    88 * Author: iDuck SRL
Note: See TracChangeset for help on using the changeset viewer.