296 if( isset( $_REQUEST[
'form_key'] ) and strpos( $_REQUEST[
'form_key_value'],
'general_register_page' ) !==
false ) {
298 if(!isset($_SERVER[
'HTTPS']) or $_SERVER[
'HTTPS'] !=
"on") {
299 $datahelper->displayMessage(
'OpenID Connect requires https. This extension will not work if your website uses http only.',
"ERROR");
303 if($_POST[
'gluu_user_role']){
304 $this->
update_query(
'gluu/oxd/gluu_user_role', trim($_POST[
'gluu_user_role']));
306 if($_POST[
'gluu_users_can_register']==1){
307 $this->
update_query(
'gluu/oxd/gluu_users_can_register', $_POST[
'gluu_users_can_register']);
308 if(!empty(array_values(array_filter($_POST[
'gluu_new_role'])))){
309 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(array_values(array_filter($_POST[
'gluu_new_role']))));
310 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
311 array_push($config[
'config_scopes'],
'permission');
312 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
314 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(null));
317 if($_POST[
'gluu_users_can_register']==2){
318 $this->
update_query(
'gluu/oxd/gluu_users_can_register', 2);
319 if(!empty(array_values(array_filter($_POST[
'gluu_new_role'])))){
320 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(array_values(array_filter($_POST[
'gluu_new_role']))));
321 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
322 array_push($config[
'config_scopes'],
'permission');
323 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
325 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(null));
326 $datahelper->displayMessage(
'Please enter a role to use for automatic registration or choose one of the other enrollment options.',
"ERROR");
331 if($_POST[
'gluu_users_can_register']==3){
332 $this->
update_query(
'gluu/oxd/gluu_users_can_register', 3);
334 if(!empty(array_values(array_filter($_POST[
'gluu_new_role'])))){
335 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(array_values(array_filter($_POST[
'gluu_new_role']))));
336 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
337 array_push($config[
'config_scopes'],
'permission');
338 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
340 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(null));
343 if (empty($_POST[
'gluu_oxd_port'])) {
344 $datahelper->displayMessage(
'All the fields are required. Please enter valid entries.',
"ERROR");
348 else if (intval($_POST[
'gluu_oxd_port']) > 65535 && intval($_POST[
'gluu_oxd_port']) < 0) {
349 $datahelper->displayMessage(
'Enter your oxd host port (Min. number 1, Max. number 65535)',
"ERROR");
353 else if (!empty($_POST[
'gluu_provider'])) {
354 if (filter_var($_POST[
'gluu_provider'], FILTER_VALIDATE_URL) ===
false) {
355 $datahelper->displayMessage(
'Please enter valid OpenID Provider URI.',
"ERROR");
360 if (!empty($_POST[
'gluu_custom_logout'])) {
361 if (filter_var($_POST[
'gluu_custom_logout'], FILTER_VALIDATE_URL) ===
false) {
362 $datahelper->displayMessage(
'Please enter valid Custom URI.',
"ERROR");
364 $this->
update_query(
'gluu/oxd/gluu_custom_logout', trim($_POST[
'gluu_custom_logout']));
370 if (isset($_POST[
'gluu_provider']) and !empty($_POST[
'gluu_provider'])) {
371 $gluu_provider = trim($_POST[
'gluu_provider']);
372 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
373 $arrContextOptions=array(
375 "verify_peer"=>
false,
376 "verify_peer_name"=>
false,
379 $json = file_get_contents($gluu_provider.
'/.well-known/openid-configuration',
false, stream_context_create($arrContextOptions));
380 $obj = json_decode($json);
381 if(!empty($obj->userinfo_endpoint)){
383 if(empty($obj->registration_endpoint)){
384 $datahelper->displayMessage(
'Please enter your client_id and client_secret.',
"SUCCESS");
385 $gluu_config = json_encode(array(
386 "gluu_oxd_port" =>$_POST[
'gluu_oxd_port'],
387 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
388 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
389 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
390 "config_scopes" => [
"openid",
"profile",
"email"],
391 "gluu_client_id" =>
"",
392 "gluu_client_secret" =>
"",
395 if($_POST[
'gluu_users_can_register']==2){
396 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
397 array_push($config[
'config_scopes'],
'permission');
398 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
400 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', $gluu_config),
true);
401 if(isset($_POST[
'gluu_client_id']) and !empty($_POST[
'gluu_client_id']) and
402 isset($_POST[
'gluu_client_secret']) and !empty($_POST[
'gluu_client_secret'])){
403 $gluu_config = json_encode(array(
404 "gluu_oxd_port" =>$_POST[
'gluu_oxd_port'],
405 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
406 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
407 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
408 "config_scopes" => [
"openid",
"profile",
"email"],
409 "gluu_client_id" => $_POST[
'gluu_client_id'],
410 "gluu_client_secret" => $_POST[
'gluu_client_secret'],
413 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', $gluu_config),
true);
414 if($_POST[
'gluu_users_can_register']==2){
415 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
416 array_push($config[
'config_scopes'],
'permission');
417 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
421 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
422 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
423 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
424 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
425 $get_scopes = json_encode($obj->scopes_supported);
426 if(!empty($obj->acr_values_supported)){
427 $get_acr = json_encode($obj->acr_values_supported);
428 $get_acr = $this->
update_query(
'gluu/oxd/gluu_acr', $get_acr);
434 if(!empty($obj->scopes_supported)){
435 $get_scopes = json_encode($obj->scopes_supported);
436 $get_scopes = $this->
update_query(
'gluu/oxd/gluu_scopes', $get_scopes);
443 $register_site->setRequestClientSecret($_POST[
'gluu_client_secret']);
445 if ($status[
'message'] ==
'invalid_op_host') {
446 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
450 if (!$status[
'status']) {
451 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
455 if ($status[
'message'] ==
'internal_error') {
456 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
462 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
464 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
467 $register_site_admin->setRequestOpHost($gluu_provider);
468 $register_site_admin->setRequestAuthorizationRedirectUri(Mage::getBaseUrl().
'admin?option=getOxdAdminLogin');
469 $register_site_admin->setRequestLogoutRedirectUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
470 $register_site_admin->setRequestContacts([$gluu_config[
'admin_email']]);
471 $register_site_admin->setRequestClientLogoutUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
472 $register_site_admin->setRequestAcrValues($gluu_config[
'config_acr']);
473 $register_site_admin->setRequestScope($gluu_config[
'config_scopes']);
474 $register_site_admin->setRequestClientId(trim($_POST[
'gluu_client_id']));
475 $register_site_admin->setRequestClientSecret(trim($_POST[
'gluu_client_secret']));
476 $register_site_admin->request();
477 $gluu_oxd_id_admin = $this->
update_query(
'gluu/oxd/gluu_oxd_id_admin', $register_site_admin->getResponseOxdId());
479 $datahelper->displayMessage(
'Your settings are saved successfully.',
"SUCCESS");
483 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
496 $gluu_config = json_encode(array(
497 "gluu_oxd_port" =>trim($_POST[
'gluu_oxd_port']),
498 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
499 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
500 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
501 "config_scopes" => [
"openid",
"profile",
"email"],
502 "gluu_client_id" =>
"",
503 "gluu_client_secret" =>
"",
506 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', $gluu_config),
true);
507 if(trim($_POST[
'gluu_users_can_register'])==2){
508 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
509 array_push($config[
'config_scopes'],
'permission');
510 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
514 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
515 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
516 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
517 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
518 $get_scopes = json_encode($obj->scopes_supported);
519 if(!empty($obj->acr_values_supported)){
520 $get_acr = json_encode($obj->acr_values_supported);
521 $get_acr = json_decode($this->
update_query(
'gluu/oxd/gluu_acr', $get_acr));
527 if(!empty($obj->scopes_supported)){
528 $get_scopes = json_encode($obj->scopes_supported);
529 $get_scopes = json_decode($this->
update_query(
'gluu/oxd/gluu_scopes', $get_scopes));
537 if ($status[
'message'] ==
'invalid_op_host') {
538 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
542 if (!$status[
'status']) {
543 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
547 if ($status[
'message'] ==
'internal_error') {
548 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
554 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
556 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
559 $register_site_admin->setRequestOpHost($gluu_provider);
560 $register_site_admin->setRequestAuthorizationRedirectUri(Mage::getBaseUrl().
'admin?option=getOxdAdminLogin');
561 $register_site_admin->setRequestLogoutRedirectUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
562 $register_site_admin->setRequestContacts([$gluu_config[
'admin_email']]);
563 $register_site_admin->setRequestClientLogoutUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
564 $register_site_admin->setRequestAcrValues($gluu_config[
'config_acr']);
565 $register_site_admin->setRequestScope($gluu_config[
'config_scopes']);
566 $register_site_admin->request();
567 $gluu_oxd_id_admin = $this->
update_query(
'gluu/oxd/gluu_oxd_id_admin', $register_site_admin->getResponseOxdId());
569 $datahelper->displayMessage(
'Your settings are saved successfully.',
"SUCCESS");
574 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
581 $datahelper->displayMessage(
'Please enter correct URI of the OpenID Provider.',
"ERROR");
588 $gluu_config = json_encode(array(
589 "gluu_oxd_port" =>trim($_POST[
'gluu_oxd_port']),
590 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
591 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
592 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
593 "config_scopes" => [
"openid",
"profile",
"email"],
594 "gluu_client_id" =>
"",
595 "gluu_client_secret" =>
"",
598 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', $gluu_config),
true);
599 if(trim($_POST[
'gluu_users_can_register'])==2){
600 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
601 array_push($config[
'config_scopes'],
'permission');
602 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
605 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
606 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
607 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
610 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
613 if ($status[
'message'] ==
'invalid_op_host') {
614 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
618 if (!$status[
'status']) {
619 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
623 if ($status[
'message'] ==
'internal_error') {
624 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
630 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
632 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
633 $arrContextOptions=array(
635 "verify_peer"=>
false,
636 "verify_peer_name"=>
false,
639 $json = file_get_contents($gluu_provider.
'/.well-known/openid-configuration',
false, stream_context_create($arrContextOptions));
640 $obj = json_decode($json);
643 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
644 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
645 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
646 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
648 $get_scopes = json_encode($obj->scopes_supported);
649 if(!empty($obj->acr_values_supported)){
650 $get_acr = json_encode($obj->acr_values_supported);
651 $get_acr = $this->
update_query(
'gluu/oxd/gluu_acr', $get_acr);
657 if(!empty($obj->scopes_supported)){
658 $get_scopes = json_encode($obj->scopes_supported);
659 $get_scopes = $this->
update_query(
'gluu/oxd/gluu_scopes', $get_scopes);
666 if ($status[
'message'] ==
'invalid_op_host') {
667 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
671 if (!$status[
'status']) {
672 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
676 if ($status[
'message'] ==
'internal_error') {
677 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
683 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
686 $register_site_admin->setRequestOpHost($gluu_provider);
687 $register_site_admin->setRequestAuthorizationRedirectUri(Mage::getBaseUrl().
'admin?option=getOxdAdminLogin');
688 $register_site_admin->setRequestLogoutRedirectUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
689 $register_site_admin->setRequestContacts([$gluu_config[
'admin_email']]);
690 $register_site_admin->setRequestClientLogoutUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
691 $register_site_admin->setRequestAcrValues($gluu_config[
'config_acr']);
692 $register_site_admin->setRequestScope($gluu_config[
'config_scopes']);
693 $register_site_admin->request();
694 $gluu_oxd_id_admin = $this->
update_query(
'gluu/oxd/gluu_oxd_id_admin', $register_site_admin->getResponseOxdId());
696 $datahelper->displayMessage(
'Your settings are saved successfully.',
"SUCCESS");
701 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
707 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
713 else if( isset( $_REQUEST[
'form_key'] ) and strpos( $_REQUEST[
'form_key_value'],
'general_oxd_id_reset' ) !==
false and !empty($_REQUEST[
'resetButton'])) {
717 $datahelper->displayMessage(
'Configurations deleted Successfully.',
"SUCCESS");
720 else if (isset( $_REQUEST[
'form_key'] ) and strpos( $_REQUEST[
'form_key_value'],
'general_oxd_edit' ) !==
false) {
721 if(trim($_POST[
'gluu_user_role'])){
722 $this->
update_query(
'gluu/oxd/gluu_user_role', trim($_POST[
'gluu_user_role']));
724 if(trim($_POST[
'gluu_users_can_register'])==1){
725 $this->
update_query(
'gluu/oxd/gluu_users_can_register', trim($_POST[
'gluu_users_can_register']));
726 if(!empty(array_values(array_filter($_POST[
'gluu_new_role'])))){
727 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(array_values(array_filter($_POST[
'gluu_new_role']))));
728 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
729 array_push($config[
'config_scopes'],
'permission');
730 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
732 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(null));
735 if($_POST[
'gluu_users_can_register']==2){
736 $this->
update_query(
'gluu/oxd/gluu_users_can_register', 2);
737 if(!empty(array_values(array_filter($_POST[
'gluu_new_role'])))){
738 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(array_values(array_filter($_POST[
'gluu_new_role']))));
739 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
740 array_push($config[
'config_scopes'],
'permission');
741 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
743 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(null));
744 $datahelper->displayMessage(
'Please enter a role to use for automatic registration or choose one of the other enrollment options.',
"ERROR");
749 if($_POST[
'gluu_users_can_register']==3){
750 $this->
update_query(
'gluu/oxd/gluu_users_can_register', 3);
752 if(!empty(array_values(array_filter($_POST[
'gluu_new_role'])))){
753 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(array_values(array_filter($_POST[
'gluu_new_role']))));
754 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
755 array_push($config[
'config_scopes'],
'permission');
756 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
758 $this->
update_query(
'gluu/oxd/gluu_new_role', json_encode(null));
761 $get_scopes = json_encode(array(
"openid",
"profile",
"email"));
762 $get_scopes = $this->
update_query(
'gluu/oxd/get_scopes', $get_scopes);
764 $gluu_acr = json_encode(array(
"none"));
765 $gluu_acr = $this->
update_query(
'gluu/oxd/gluu_acr', $gluu_acr);
767 if(!isset($_SERVER[
'HTTPS']) or $_SERVER[
'HTTPS'] !=
"on") {
768 $datahelper->displayMessage(
'OpenID Connect requires https. This extension will not work if your website uses http only.',
"ERROR");
772 if (empty(trim($_POST[
'gluu_oxd_port']))) {
773 $datahelper->displayMessage(
'All the fields are required. Please enter valid entries.',
"ERROR");
777 else if (intval($_POST[
'gluu_oxd_port']) > 65535 && intval($_POST[
'oxd_port']) < 0) {
778 $datahelper->displayMessage(
'Enter your oxd host port (Min. number 0, Max. number 65535).',
"ERROR");
782 if (!empty(trim($_POST[
'gluu_custom_logout']))) {
783 if (filter_var(trim($_POST[
'gluu_custom_logout']), FILTER_VALIDATE_URL) ===
false) {
784 $datahelper->displayMessage(
'Please enter valid Custom URI.',
"ERROR");
786 $this->
update_query(
'gluu/oxd/gluu_custom_logout', trim($_POST[
'gluu_custom_logout']));
791 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id',
'');
792 $gluu_config = array(
793 "gluu_oxd_port" =>$_POST[
'gluu_oxd_port'],
794 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
795 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
796 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
797 "config_scopes" => [
"openid",
"profile",
"email"],
798 "gluu_client_id" =>
"",
799 "gluu_client_secret" =>
"",
803 $gluu_config = $this->
update_query(
'gluu/oxd/gluu_config', json_encode($gluu_config));
804 if($_POST[
'gluu_users_can_register']==2){
805 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
806 array_push($config[
'config_scopes'],
'permission');
807 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
809 $gluu_provider = $this->
select_query(
'gluu/oxd/gluu_provider');
810 if (!empty($gluu_provider)) {
811 $arrContextOptions=array(
813 "verify_peer"=>
false,
814 "verify_peer_name"=>
false,
817 $json = file_get_contents($gluu_provider.
'/.well-known/openid-configuration',
false, stream_context_create($arrContextOptions));
818 $obj = json_decode($json);
819 if(!empty($obj->userinfo_endpoint)){
820 if(empty($obj->registration_endpoint)){
821 if(isset($_POST[
'gluu_client_id']) and !empty($_POST[
'gluu_client_id']) and
822 isset($_POST[
'gluu_client_secret']) and !empty($_POST[
'gluu_client_secret']) and !$obj->registration_endpoint){
823 $gluu_config = array(
824 "gluu_oxd_port" => trim($_POST[
'gluu_oxd_port']),
825 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
826 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
827 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
828 "gluu_client_id" => trim($_POST[
'gluu_client_id']),
829 "gluu_client_secret" => trim($_POST[
'gluu_client_secret']),
830 "config_scopes" => [
"openid",
"profile",
"email"],
833 $gluu_config1 = $this->
update_query(
'gluu/oxd/gluu_config', json_encode($gluu_config));
834 if($_POST[
'gluu_users_can_register']==2){
835 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
836 array_push($config[
'config_scopes'],
'permission');
837 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
842 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
843 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
844 $register_site->setRequestContacts([$GLOBALS[
'current_user']->email1]);
845 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
846 if(!empty($obj->acr_values_supported)){
847 $get_acr = json_encode($obj->acr_values_supported);
848 $gluu_config = $this->
update_query(
'gluu/oxd/gluu_acr', $gluu_acr);
850 if(!empty($obj->scopes_supported)){
851 $get_scopes = json_encode($obj->scopes_supported);
852 $gluu_config = $this->
update_query(
'gluu/oxd/get_scopes', $get_scopes);
857 $register_site->setRequestClientId(trim($_POST[
'gluu_client_id']));
858 $register_site->setRequestClientSecret(trim($_POST[
'gluu_client_secret']));
860 if ($status[
'message'] ==
'invalid_op_host') {
861 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
865 if (!$status[
'status']) {
866 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
870 if ($status[
'message'] ==
'internal_error') {
871 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
877 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
879 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
894 $datahelper->displayMessage(
'Your settings are saved successfully.',
"SUCCESS");
898 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
904 $_SESSION[
'openid_error_edit'] =
'Error506';
910 $gluu_config = array(
911 "gluu_oxd_port" =>trim($_POST[
'gluu_oxd_port']),
912 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
913 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
914 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
915 "config_scopes" => [
"openid",
"profile",
"email"],
916 "gluu_client_id" =>
"",
917 "gluu_client_secret" =>
"",
920 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($gluu_config)),
true);
921 if($_POST[
'gluu_users_can_register']==2){
922 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
923 array_push($config[
'config_scopes'],
'permission');
924 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
928 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
929 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
930 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
931 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
932 $get_scopes = json_encode($obj->scopes_supported);
933 if(!empty($obj->acr_values_supported)){
934 $get_acr = json_encode($obj->acr_values_supported);
935 $get_acr = json_decode($this->
update_query(
'gluu/oxd/gluu_acr', $get_acr));
941 if(!empty($obj->scopes_supported)){
942 $get_scopes = json_encode($obj->scopes_supported);
943 $get_scopes = json_decode($this->
update_query(
'gluu/oxd/gluu_scopes', $get_scopes));
951 if ($status[
'message'] ==
'invalid_op_host') {
952 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
956 if (!$status[
'status']) {
957 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
961 if ($status[
'message'] ==
'internal_error') {
962 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
968 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
970 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
973 $register_site_admin->setRequestOpHost($gluu_provider);
974 $register_site_admin->setRequestAuthorizationRedirectUri(Mage::getBaseUrl().
'admin?option=getOxdAdminLogin');
975 $register_site_admin->setRequestLogoutRedirectUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
976 $register_site_admin->setRequestContacts([$gluu_config[
'admin_email']]);
977 $register_site_admin->setRequestClientLogoutUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
978 $register_site_admin->setRequestAcrValues($gluu_config[
'config_acr']);
979 $register_site_admin->setRequestScope($gluu_config[
'config_scopes']);
980 $register_site_admin->request();
981 $gluu_oxd_id_admin = $this->
update_query(
'gluu/oxd/gluu_oxd_id_admin', $register_site_admin->getResponseOxdId());
983 $datahelper->displayMessage(
'Your settings are saved successfully.',
"SUCCESS");
988 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
995 $datahelper->displayMessage(
'Please enter correct URI of the OpenID Provider.',
"ERROR");
1001 $gluu_config = array(
1002 "gluu_oxd_port" =>trim($_POST[
'gluu_oxd_port']),
1003 "admin_email" => Mage::getSingleton(
'admin/session')->getUser()->getEmail(),
1004 "authorization_redirect_uri" => Mage::getBaseUrl().
'customer/account/login?option=getOxdSocialLogin',
1005 "post_logout_redirect_uri" => Mage::helper(
'customer')->getLogoutUrl(),
1006 "config_scopes" => [
"openid",
"profile",
"email"],
1007 "gluu_client_id" =>
"",
1008 "gluu_client_secret" =>
"",
1011 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($gluu_config)),
true);
1012 if($_POST[
'gluu_users_can_register']==2){
1013 $config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
1014 array_push($config[
'config_scopes'],
'permission');
1015 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', json_encode($config)),
true);
1018 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
1019 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
1020 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
1023 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
1026 if ($status[
'message'] ==
'invalid_op_host') {
1027 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
1031 if (!$status[
'status']) {
1032 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
1036 if ($status[
'message'] ==
'internal_error') {
1037 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
1043 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
1045 $gluu_provider1 = $this->
update_query(
'gluu/oxd/gluu_provider', $gluu_provider);
1046 $arrContextOptions=array(
1048 "verify_peer"=>
false,
1049 "verify_peer_name"=>
false,
1052 $json = file_get_contents($gluu_provider.
'/.well-known/openid-configuration',
false, stream_context_create($arrContextOptions));
1053 $obj = json_decode($json);
1056 $register_site->setRequestAuthorizationRedirectUri($gluu_config[
'authorization_redirect_uri']);
1057 $register_site->setRequestLogoutRedirectUri($gluu_config[
'post_logout_redirect_uri']);
1058 $register_site->setRequestContacts([$gluu_config[
'admin_email']]);
1059 $register_site->setRequestClientLogoutUri($gluu_config[
'post_logout_redirect_uri']);
1061 $get_scopes = json_encode($obj->scopes_supported);
1062 if(!empty($obj->acr_values_supported)){
1063 $get_acr = json_encode($obj->acr_values_supported);
1064 $get_acr = $this->
update_query(
'gluu/oxd/gluu_acr', $get_acr);
1070 if(!empty($obj->scopes_supported)){
1071 $get_scopes = json_encode($obj->scopes_supported);
1072 $get_scopes = $this->
update_query(
'gluu/oxd/gluu_scopes', $get_scopes);
1079 if ($status[
'message'] ==
'invalid_op_host') {
1080 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json',
"ERROR");
1084 if (!$status[
'status']) {
1085 $datahelper->displayMessage(
'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.',
"ERROR");
1089 if ($status[
'message'] ==
'internal_error') {
1090 $datahelper->displayMessage(
'ERROR: '.$status[
'error_message'],
"ERROR");
1096 $gluu_oxd_id = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $gluu_oxd_id);
1099 $register_site_admin->setRequestOpHost($gluu_provider);
1100 $register_site_admin->setRequestAuthorizationRedirectUri(Mage::getBaseUrl().
'admin?option=getOxdAdminLogin');
1101 $register_site_admin->setRequestLogoutRedirectUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
1102 $register_site_admin->setRequestContacts([$gluu_config[
'admin_email']]);
1103 $register_site_admin->setRequestClientLogoutUri(Mage::getBaseUrl().
'gluufolder/adminhtml_index/logoutfromall');
1104 $register_site_admin->setRequestAcrValues($gluu_config[
'config_acr']);
1105 $register_site_admin->setRequestScope($gluu_config[
'config_scopes']);
1106 $register_site_admin->request();
1107 $gluu_oxd_id_admin = $this->
update_query(
'gluu/oxd/gluu_oxd_id_admin', $register_site_admin->getResponseOxdId());
1109 $datahelper->displayMessage(
'Your settings are saved successfully.',
"SUCCESS");
1114 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
1120 $datahelper->displayMessage(
'ERROR: OpenID Provider host is required if you don\'t provide it in oxd-default-site-config.json.',
"ERROR");
1126 else if( isset( $_REQUEST[
'form_key'] ) and strpos( $_REQUEST[
'form_key_value'],
'openid_config_page' ) !==
false ) {
1127 $params = $_REQUEST;
1128 $message_success =
'';
1130 if($_POST[
'send_user_type']){
1131 $gluu_auth_type = trim($_POST[
'send_user_type']);
1132 $gluu_auth_type = $this->
update_query(
'gluu/oxd/gluu_auth_type', $gluu_auth_type);
1134 $gluu_auth_type = $this->
update_query(
'gluu/oxd/gluu_auth_type',
'default');
1136 $gluu_send_user_check = trim($_POST[
'send_user_check']);
1137 $gluu_send_user_check = $this->
update_query(
'gluu/oxd/gluu_send_user_check', $gluu_send_user_check);
1139 $gluu_send_admin_check = trim($_POST[
'send_admin_check']);
1140 $gluu_send_admin_check = $this->
update_query(
'gluu/oxd/gluu_send_admin_check', $gluu_send_admin_check);
1141 if(!empty($params[
'scope']) && isset($params[
'scope'])){
1142 $gluu_config = json_decode($this->
select_query(
"gluu/oxd/gluu_config"),
true);
1143 $gluu_config[
'config_scopes'] = $params[
'scope'];
1144 $gluu_config = json_encode($gluu_config);
1145 $gluu_config = json_decode($this->
update_query(
'gluu/oxd/gluu_config', $gluu_config),
true);
1147 if(!empty($params[
'scope_name']) && isset($params[
'scope_name'])){
1148 $get_scopes = json_decode($this->
select_query(
'gluu/oxd/gluu_scopes'),
true);
1149 foreach($params[
'scope_name'] as $scope){
1150 if($scope && !in_array($scope,$get_scopes)){
1151 array_push($get_scopes, $scope);
1154 $get_scopes = json_encode($get_scopes);
1155 $get_scopes = json_decode($this->
update_query(
'gluu/oxd/gluu_scopes', $get_scopes),
true);
1157 $gluu_acr = json_decode($this->
select_query(
'gluu/oxd/gluu_acr'),
true);
1159 if(!empty($params[
'acr_name']) && isset($params[
'acr_name'])){
1160 $get_acr = json_decode($this->
select_query(
'gluu/oxd/gluu_acr'),
true);
1161 foreach($params[
'acr_name'] as $scope){
1162 if($scope && !in_array($scope,$get_acr)){
1163 array_push($get_acr, $scope);
1166 $get_acr = json_encode($get_acr);
1167 $get_acr = json_decode($this->
update_query(
'gluu/oxd/gluu_acr', $get_acr),
true);
1169 $gluu_config = json_decode($this->
select_query(
'gluu/oxd/gluu_config'),
true);
1170 $gluu_oxd_id = $this->
select_query(
'gluu/oxd/gluu_oxd_id');
1182 $get_scopes = $this->
update_query(
'gluu/oxd/gluu_oxd_id', $new_oxd_id);
1185 $datahelper->displayMessage(
'Your OpenID connect configuration has been saved.',
"SUCCESS");
1186 $this->
redirect(
"*/*/openidconfigpage");
select_query($action)
Definition: IndexController.php:1227
getDataHelper()
Definition: IndexController.php:287
redirect($url)
Definition: IndexController.php:271
$update_site_registration
Definition: Update_site_registration_test.php:7
$register_site
Definition: Register_site_test.php:7
update_query($action, $value)
Definition: IndexController.php:1237
resetConfigAction()
Definition: IndexController.php:1190
$_SESSION['id_token']
Definition: Get_tokens_by_code_test.php:15
getOxdUpdateSiteRegistrationHelper()
Definition: IndexController.php:158
getOxdRegisterSiteHelper()
Definition: IndexController.php:65