diff --git a/WP_Auth0.php b/WP_Auth0.php index 3bc46c5b..83d2408b 100644 --- a/WP_Auth0.php +++ b/WP_Auth0.php @@ -150,7 +150,7 @@ public static function ready() { */ public static function get_tenant_region( $domain ) { preg_match( '/^[\w\d\-_0-9]+\.([\w\d\-_0-9]*)[\.]*auth0\.com$/', $domain, $matches ); - return !empty($matches[1]) ? $matches[1] : 'us'; + return ! empty( $matches[1] ) ? $matches[1] : 'us'; } /** diff --git a/assets/css/initial-setup.css b/assets/css/initial-setup.css index 41b8e1ab..74983c64 100644 --- a/assets/css/initial-setup.css +++ b/assets/css/initial-setup.css @@ -1 +1 @@ -@font-face{font-family:'avenir roman';src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot");src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot?#iefix") format('embedded-opentype'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.woff") format('woff'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.ttf") format('truetype');font-weight:300;font-style:normal}#lock-wrapper{width:300px;margin:30px auto}.modal-open .modal{background: rgba(0,0,0,0.5)}.modal-open .modal-backdrop{display: none}#wpwrap{background-color:#fff;}#wpwrap .a0-wrap{font-family:'avenir roman';margin-left:-10px;color:rgba(0,0,0,0.86);}#wpwrap .a0-wrap a,#wpwrap .a0-wrap .link{color:#0094c1}#wpwrap .a0-wrap .row > .a0-separator,#wpwrap .a0-wrap .a0-feedback > .a0-separator{border-bottom:1px solid rgba(0,0,0,0.05);margin:30px 0}#wpwrap .a0-wrap .a0-header{text-align:center;border-bottom:1px solid rgba(0,0,0,0.05);}#wpwrap .a0-wrap .a0-header a{outline:none;border:none;box-shadow:none}#wpwrap .a0-wrap .a0-header img.a0-header-logo{height:55px;margin:30px auto}#wpwrap .a0-wrap .modal-body.no-padding-bottom{padding-bottom:0}#wpwrap .a0-wrap #connections .loading{margin:0 -15px 30px;background:#f8edb5;color:#a78e11;text-align:center;line-height:41px;border-radius:3px;}#wpwrap .a0-wrap #connections .loading .a0-spinner-css{width:25px;height:25px;position:relative;top:7px;margin-right:10px;border-top-color:rgba(167,142,17,0.3);border-right-color:rgba(167,142,17,0.3);border-bottom-color:rgba(167,142,17,0.3);border-left-color:rgba(167,142,17,0.9)}@media (min-width:768px){#wpwrap .a0-wrap{margin-left:-20px}}#wpwrap .a0-wrap small,#wpwrap .a0-wrap .small{font-size:70%}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap p{color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap .h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap .h2,#wpwrap .a0-wrap h3,#wpwrap .a0-wrap .h3{margin-top:0}#wpwrap .a0-wrap h3{background:transparent;padding:0}#wpwrap .a0-wrap h1{font-size:32px}#wpwrap .a0-wrap p{font-size:17px;color:rgba(0,0,0,0.36)}#wpwrap .a0-wrap ul.list{font-size:17px;color:rgba(0,0,0,0.36);}#wpwrap .a0-wrap ul.list li{list-style-type:disc;margin-left:25px}#wpwrap .a0-wrap textarea.code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:12px;line-height:19px;padding:10px}#wpwrap .a0-wrap .modal-dialog input[type=text],#wpwrap .a0-wrap .modal-dialog input[type=password],#wpwrap .a0-wrap .modal-dialog textarea{border:1px solid #ccc;line-height:1em;height:40px;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap .a0-buttons{margin:20px 0;}#wpwrap .a0-wrap .a0-buttons.extra-space{margin-top:50px}#wpwrap .a0-wrap form{margin:0}#wpwrap .a0-wrap .container-fluid{padding-top:50px;max-width:750px}#wpwrap .a0-wrap .modal-dialog{margin:100px auto}#wpwrap .a0-wrap .modal-body{padding:30px;font-size:16px}#wpwrap .a0-wrap .modal-header h4{text-align:center;font-weight:bold}#wpwrap .a0-wrap .modal-header .close{margin-top:2px}#wpwrap .a0-wrap .modal-footer{padding:25px}#wpwrap .a0-wrap .bg-danger{padding:17px;font-size:15px;margin:30px 0}#wpwrap .a0-wrap .updated.settings-error{margin:5px 0;}#wpwrap .a0-wrap .updated.settings-error p{font-size:14px;text-align:left;color:rgba(0,0,0,0.86)}#wpwrap .a0-step-text{margin:30px 0 0}#wpwrap .a0-settings-form[data-tab-showing="help"] #submit{display:none}#wpwrap .a0-button,#wpwrap #wpa0_choose_icon{border-radius:3px;border:none;line-height:45px;min-width:150px;text-transform:uppercase;text-decoration:none;font-size:13px;display:inline-block;text-align:center;padding:0 30px;transition:background-color .2s ease;}#wpwrap .a0-button:focus,#wpwrap #wpa0_choose_icon:focus{box-shadow:none;outline:none}#wpwrap .a0-button.link,#wpwrap #wpa0_choose_icon.link{text-transform:none;text-decoration:underline;cursor:pointer;min-width:0;padding:0 10px}#wpwrap .a0-button.primary,#wpwrap #wpa0_choose_icon.primary{color:#fff;background-color:#eb5424;}#wpwrap .a0-button.primary:hover,#wpwrap #wpa0_choose_icon.primary:hover{color:#fff}#wpwrap .a0-button.secondary,#wpwrap #wpa0_choose_icon.secondary{font-weight:bold;color:#32759a;background-color:transparent;text-decoration:underline;}#wpwrap .a0-button.secondary:hover,#wpwrap #wpa0_choose_icon.secondary:hover{color:#32759a}#wpwrap .a0-button.default,#wpwrap #wpa0_choose_icon.default{background:#fff;color:rgba(0,0,0,0.86);border-color:#d0d2d3;text-decoration:none;}#wpwrap .a0-button.default:hover,#wpwrap #wpa0_choose_icon.default:hover{background:#d0d2d3}#wpwrap #wpa0_choose_icon{height:42px;color:#fff;background-color:#eb5424}#wpwrap .a0-steps{background-color:#f2f5f8;padding-top:120px;padding-bottom:120px;height:0;}#wpwrap .a0-steps .a0-progress{border-top:4px solid #dcdfe1;margin:auto;float:none}#wpwrap .a0-steps .steps{position:relative;top:-27px;text-align:center;}#wpwrap .a0-steps .steps span{display:inline-block;width:50px;height:50px;border-radius:30px;line-height:50px;text-align:center;background-color:#dcdfe1;color:#fff;font-weight:bold;font-size:15px}#wpwrap .a0-steps .steps p{display:none;color:#575c60;font-weight:bold;padding-top:10px;font-size:15px;width:105px;margin:auto}#wpwrap .a0-steps .steps .active span{background-color:#eb5424}#wpwrap .a0-steps .steps .active p{display:block}#wpwrap .consent-disclaimer .logo{width:100px;margin:20px 0}#wpwrap .a0-message{line-height:24px;font-size:12px;border-radius:3px;position:relative;color:rgba(0,0,0,0.86);padding:15px;}#wpwrap .a0-message.a0-step-text{font-size:14px}#wpwrap .a0-message.multiline{line-height:25px;padding:10px 20px}#wpwrap .a0-message.a0-notice{background-color:#d0e8f4;color:#32759a}#wpwrap .a0-message.a0-tip{background-color:#e4e6e8;}#wpwrap .a0-message.a0-tip a{color:rgba(0,0,0,0.86)}#wpwrap .a0-message.a0-warning{background:#fff7c9;color:#786600;}#wpwrap .a0-message.a0-warning a.link{color:#786600;font-decoration:underline}#wpwrap .a0-message b{font-weight:bold;text-transform:uppercase}#wpwrap .a0-message a{text-decoration:underline}#wpwrap .a0-message img{position:absolute;left:20px;top:20px}#wpwrap .a0-message .a0-button{border:0;margin:-4px;margin-left:10px;font-size:12px;line-height:12px;padding:10px 15px}#wpwrap .modal-content .a0-message{margin:20px 0}#wpwrap .modal-content .link{line-height:25px;margin-bottom:20px;cursor:pointer}#wpwrap .a0-profiles{margin-top:30px;margin-bottom:30px;}@media (min-width:768px){#wpwrap .a0-profiles .col:nth-of-type(1){padding-left:0;padding-right:10px}#wpwrap .a0-profiles .col:nth-of-type(2){padding-left:10px;padding-right:0}}#wpwrap .a0-profiles .profile{background-color:#f2f5f8;border-radius:3px;padding:25px;text-align:center;margin-bottom:20px;}#wpwrap .a0-profiles .profile h2{font-size:22px}#wpwrap .a0-profiles .profile p{font-size:14px;margin:20px 10px;min-height:6em}#wpwrap .a0-profiles .profile img{width:100px;height:100px;border-radius:50px;margin-bottom:20px}#wpwrap .modal-footer{text-align:center}#wpwrap .enterprise-connections{margin-top:30px;padding:0;}#wpwrap .enterprise-connections .connection{background-color:#f5f7f9;text-align:center;border-radius:3px;padding:20px;margin-bottom:30px;}#wpwrap .enterprise-connections .connection .title-wrapper{min-height:50px}#wpwrap .enterprise-connections .connection h4{line-height:24px;font-size:17px}#wpwrap .enterprise-connections .connection .logo{width:100px;height:100px;border-radius:50px;background-size:55% !important;margin:0 auto 20px}#wpwrap .enterprise-connections .connection a{color:rgba(0,0,0,0.86);cursor:pointer}#wpwrap .connections-wrapper{margin-top:30px;padding:0 15px;}@media (min-width:768px){#wpwrap .connections-wrapper{height:600px;overflow-y:scroll}#wpwrap .connections-wrapper::-webkit-scrollbar{width:14px}#wpwrap .connections-wrapper::-webkit-scrollbar-track{background:#f3f3f3;border-radius:8px;border:3px solid #fff}#wpwrap .connections-wrapper::-webkit-scrollbar-thumb{border:3px solid #fff;border-radius:8px;background:#d9d9de}}#wpwrap .connections{border-top:1px #d0d2d3 solid;border-left:1px #d0d2d3 solid;}#wpwrap .connections .connection{float:left;border-top:none;background-color:#f7f7f7;border-right:1px #d0d2d3 solid;border-bottom:1px #d0d2d3 solid;}#wpwrap .connections .connection .a0-switch{float:right;position:relative;top:35px;right:15px}#wpwrap .connections .connection .logo{width:100px;height:70px;margin:15px;padding-right:15px;padding-left:15px;}#wpwrap .connections .connection .logo .logo-child{width:100px;height:70px;background-repeat:no-repeat;background-position:center center;background-size:80%}#wpwrap .connections .connection .logo[data-logo="SAP"] .logo-child{background-size:80%}#wpwrap .connections .connection .logo[data-logo="Twitter"] .logo-child{background-size:60%}#wpwrap .connections .connection .logo[data-logo="Box"] .logo-child{background-size:70%;transform:translateX(-10%)}#wpwrap .connections .connection .logo[data-logo="vk"] .logo-child{background-size:55%}#wpwrap .a0-switch{display:inline-block;}#wpwrap .a0-switch input{display:none}#wpwrap .a0-switch label{position:relative;display:block;width:50px;height:30px;border-radius:15px;background-color:#a9a9a9}#wpwrap .a0-switch input:checked + label{background-color:#45db5e}#wpwrap .a0-switch label::before{position:absolute;content:" ";width:26px;height:26px;border-radius:13px;top:2px;left:2px;background-color:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,0.25),0 4px 11px 0 rgba(0,0,0,0.08),-1px 3px 3px 0 rgba(0,0,0,0.14);transition:left 300ms cubic-bezier(.42,.8,.58,1.2)}#wpwrap .a0-switch input:checked + label::before{left:22px}#wpwrap .a0-db-connection{padding-right:90px;position:relative;}#wpwrap .a0-db-connection .a0-step-text{margin:30px 0}#wpwrap .a0-db-connection .a0-switch{position:absolute;right:20px;top:60px}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);transform:rotate(360deg)}}#wpwrap .a0-spinner-css{display:inline-block;font-size:10px;position:relative;text-indent:-9999em;border-top:2px solid rgba(0,0,0,0.3);border-right:2px solid rgba(0,0,0,0.3);border-bottom:2px solid rgba(0,0,0,0.3);border-left:2px solid rgba(0,0,0,0.9);-webkit-animation:loaderAnim .8s infinite linear;animation:loaderAnim .8s infinite linear;-webkit-border-radius:50%;border-radius:50%;background-clip:padding-box;width:40px;height:40px}#wpwrap .lock{padding-top:30px;position:relative;}#wpwrap .lock .loading{position:absolute;top:30px;bottom:0;background:rgba(255,255,255,0.5);z-index:9999;margin:auto;width:300px;display:none;}#wpwrap .lock .loading .vcenter-wrapper{display:table;height:100%;margin:auto}#wpwrap .lock .loading .centrix{display:table-cell;vertical-align:middle}#wpwrap .lock.loading .loading{display:block}#wpwrap .lock.loading #a0-lock{overflow:hidden}#wpwrap .lock #a0-lock{margin:auto;width:300px}#wpwrap .a0-admin-creation{margin-top:20px;}#wpwrap .a0-admin-creation input[type=text],#wpwrap .a0-admin-creation input[type=password]{width:100%;border:1px solid rgba(91,102,111,0.54);height:50px;line-height:1em;padding:10px;}#wpwrap .a0-admin-creation input[type=text]#admin-email,#wpwrap .a0-admin-creation input[type=password]#admin-email{border-radius:3px 3px 0 0;background-color:#e5e5e5}#wpwrap .a0-admin-creation input[type=text]#admin-password,#wpwrap .a0-admin-creation input[type=password]#admin-password{border-top:none;border-radius:0 0 3px 3px}#wpwrap .a0-final-step{text-align:center;}#wpwrap .a0-final-step h1{margin-bottom:0;margin-top:30px}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .a0-final-step .checkmark{width:90px;height:90px;border-radius:50%;display:block;stroke-width:2;stroke:#fff;stroke-miterlimit:10;margin:0 auto;box-shadow:inset 0 0 0 #7ac142;-webkit-animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;}#wpwrap .a0-final-step .checkmark .checkmark__check{transform-origin:50% 50%}#wpwrap .a0-final-step .checkmark .checkmark__circle{stroke-dasharray:166;stroke-dashoffset:166;stroke-width:2;stroke-miterlimit:10;stroke:#7ac142;-webkit-animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards;animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards}@-moz-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-o-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .settings h3{margin:30px 0 10px}#wpwrap .settings .a0-message.manage{margin-bottom:30px;margin-top:30px}#wpwrap .settings .nav-tabs{margin:30px 0;}#wpwrap .settings .nav-tabs a{color:#4a4a4a;box-shadow:none;font-size:17px}#wpwrap .settings .a0-step-text{margin:0 0 30px}#wpwrap .settings .top-margin{margin-top:30px}#wpwrap .settings .no-bottom-margin{margin-bottom:0}#wpwrap .settings .form-table th,#wpwrap .settings .form-table label,#wpwrap .settings .form-wrap label{color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password],#wpwrap .settings textarea{border:1px solid #ccc;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password]{height:40px;line-height:1em}#wpwrap .settings #wpa0_icon_url{width:50%;display:inline-block}#wpwrap .settings .subelement{padding:5px 0}#wpwrap .settings .link{font-weight:bold;text-decoration:underline;cursor:pointer}#wpwrap .settings .nav>li>a{padding:10px 0;margin-right:40px;font-size:15px;}@media (max-width:768px){#wpwrap .settings .nav>li>a{margin-right:10px}}#wpwrap .settings .nav>li>a:hover,#wpwrap .settings .nav>li>a:focus{text-decoration:none;background-color:#fff;border-color:transparent transparent #ddd}#wpwrap .settings .nav-tabs>li.active>a,#wpwrap .settings .nav-tabs>li.active>a:hover,#wpwrap .settings .nav-tabs>li.active>a:focus{color:#33b6e3;border-color:transparent transparent #33b6e3}#wpwrap .settings .form-wrap p,#wpwrap .settings p.description,#wpwrap .settings p.help,#wpwrap .settings span.description{font-style:normal;color:rgba(0,0,0,0.36)}#wpwrap .settings label{margin-right:10px}#wpwrap .settings .connections{margin-top:30px}#wpwrap .a0-table{margin:30px;width:initial}#wpwrap #manuallySetToken{margin-right:15px}#wpwrap .a0-feedback{background-color:#f2f5f8;padding:30px;margin-top:30px;border-radius:3px;}#wpwrap .a0-feedback h2{font-size:18px;margin-bottom:15px;}#wpwrap .a0-feedback h2.message{margin:0}#wpwrap .a0-feedback .a0-separator{margin:20px 0}#wpwrap .a0-feedback input.feedback_calification{display:none}#wpwrap .a0-feedback input:checked + .feedback-face{opacity:1}#wpwrap .a0-feedback .a0-buttons{margin:15px 0 0;}#wpwrap .a0-feedback .a0-buttons .a0-button{min-width:auto;cursor:pointer}#wpwrap .a0-feedback textarea{padding:10px;height:90px}#wpwrap .a0-feedback .feedback-face{width:40px;height:40px;display:inline-block;background-size:contain;opacity:.4;margin-right:30px;cursor:pointer;}#wpwrap .a0-feedback .feedback-face:hover{opacity:.7}#wpwrap .a0-feedback .feedback-face.calification-1{background-image:url("../img/rates/01.svg")}#wpwrap .a0-feedback .feedback-face.calification-2{background-image:url("../img/rates/02.svg")}#wpwrap .a0-feedback .feedback-face.calification-3{background-image:url("../img/rates/03.svg")}#wpwrap .a0-feedback .feedback-face.calification-4{background-image:url("../img/rates/04.svg")}#wpwrap .a0-feedback .feedback-face.calification-5{background-image:url("../img/rates/05.svg")}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}} \ No newline at end of file +@font-face{font-family:'avenir roman';src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot");src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot?#iefix") format('embedded-opentype'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.woff") format('woff'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.ttf") format('truetype');font-weight:300;font-style:normal}#lock-wrapper{width:300px;margin:30px auto}.modal-open .modal{background:rgba(0,0,0,0.5)}.modal-open .modal-backdrop{display:none}#wpwrap{background-color:#fff;}#wpwrap .a0-wrap{font-family:'avenir roman';margin-left:-10px;padding-left:2%;padding-right:2%;color:rgba(0,0,0,0.86);}#wpwrap .a0-wrap a,#wpwrap .a0-wrap .link{color:#0094c1}#wpwrap .a0-wrap .row > .a0-separator,#wpwrap .a0-wrap .a0-feedback > .a0-separator{border-bottom:1px solid rgba(0,0,0,0.05);margin:30px 0}#wpwrap .a0-wrap .a0-header{text-align:center;border-bottom:1px solid rgba(0,0,0,0.05);}#wpwrap .a0-wrap .a0-header a{outline:none;border:none;box-shadow:none}#wpwrap .a0-wrap .a0-header img.a0-header-logo{height:55px;margin:30px auto}#wpwrap .a0-wrap .modal-body.no-padding-bottom{padding-bottom:0}#wpwrap .a0-wrap #connections .loading{margin:0 -15px 30px;background:#f8edb5;color:#a78e11;text-align:center;line-height:41px;border-radius:3px;}#wpwrap .a0-wrap #connections .loading .a0-spinner-css{width:25px;height:25px;position:relative;top:7px;margin-right:10px;border-top-color:rgba(167,142,17,0.3);border-right-color:rgba(167,142,17,0.3);border-bottom-color:rgba(167,142,17,0.3);border-left-color:rgba(167,142,17,0.9)}@media (min-width:768px){#wpwrap .a0-wrap{margin-left:-20px}}#wpwrap .a0-wrap small,#wpwrap .a0-wrap .small{font-size:70%}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap p{color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap .h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap .h2,#wpwrap .a0-wrap h3,#wpwrap .a0-wrap .h3{margin-top:0}#wpwrap .a0-wrap h3{background:transparent;padding:0}#wpwrap .a0-wrap h1{font-size:32px}#wpwrap .a0-wrap p{font-size:17px;color:rgba(0,0,0,0.5)}#wpwrap .a0-wrap ul.list{font-size:17px;color:rgba(0,0,0,0.5);}#wpwrap .a0-wrap ul.list li{list-style-type:disc;margin-left:25px}#wpwrap .a0-wrap code{background:#f1f1f1;color:#777;line-height:2em}#wpwrap .a0-wrap textarea.code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:12px;line-height:19px;padding:10px}#wpwrap .a0-wrap .modal-dialog input[type=text],#wpwrap .a0-wrap .modal-dialog input[type=password],#wpwrap .a0-wrap .modal-dialog textarea{border:1px solid #ccc;line-height:1em;height:40px;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap .a0-buttons{margin:20px 0;}#wpwrap .a0-wrap .a0-buttons.extra-space{margin-top:50px}#wpwrap .a0-wrap form{margin:0;}#wpwrap .a0-wrap form [disabled]{opacity:.5;font-size:.9em;margin-top:.3em}#wpwrap .a0-wrap .container-fluid{padding-top:50px;max-width:750px}#wpwrap .a0-wrap .modal-dialog{margin:100px auto}#wpwrap .a0-wrap .modal-body{padding:30px;font-size:16px}#wpwrap .a0-wrap .modal-header h4{text-align:center;font-weight:bold}#wpwrap .a0-wrap .modal-header .close{margin-top:2px}#wpwrap .a0-wrap .modal-footer{padding:25px}#wpwrap .a0-wrap .bg-danger{padding:17px;font-size:15px;margin:30px 0}#wpwrap .a0-wrap .updated.settings-error{margin:5px 0;}#wpwrap .a0-wrap .updated.settings-error p{font-size:14px;text-align:left;color:rgba(0,0,0,0.86)}#wpwrap .a0-step-text{margin:30px 0 0}#wpwrap .a0-settings-form[data-tab-showing="help"] #submit{display:none}#wpwrap .a0-button,#wpwrap #wpa0_choose_icon{border-radius:3px;border:none;line-height:45px;min-width:150px;text-transform:uppercase;text-decoration:none;font-size:13px;display:inline-block;text-align:center;padding:0 30px;transition:background-color .2s ease;}#wpwrap .a0-button:focus,#wpwrap #wpa0_choose_icon:focus{box-shadow:none;outline:none}#wpwrap .a0-button.link,#wpwrap #wpa0_choose_icon.link{text-transform:none;text-decoration:underline;cursor:pointer;min-width:0;padding:0 10px}#wpwrap .a0-button.primary,#wpwrap #wpa0_choose_icon.primary{color:#fff;background-color:#eb5424;}#wpwrap .a0-button.primary:hover,#wpwrap #wpa0_choose_icon.primary:hover{color:#fff}#wpwrap .a0-button.secondary,#wpwrap #wpa0_choose_icon.secondary{font-weight:bold;color:#32759a;background-color:transparent;text-decoration:underline;}#wpwrap .a0-button.secondary:hover,#wpwrap #wpa0_choose_icon.secondary:hover{color:#32759a}#wpwrap .a0-button.default,#wpwrap #wpa0_choose_icon.default{background:#fff;color:rgba(0,0,0,0.86);border-color:#d0d2d3;text-decoration:none;}#wpwrap .a0-button.default:hover,#wpwrap #wpa0_choose_icon.default:hover{background:#d0d2d3}#wpwrap #wpa0_choose_icon{height:42px;color:#fff;background-color:#eb5424}#wpwrap .a0-steps{background-color:#f2f5f8;padding-top:120px;padding-bottom:120px;height:0;}#wpwrap .a0-steps .a0-progress{border-top:4px solid #dcdfe1;margin:auto;float:none}#wpwrap .a0-steps .steps{position:relative;top:-27px;text-align:center;}#wpwrap .a0-steps .steps span{display:inline-block;width:50px;height:50px;border-radius:30px;line-height:50px;text-align:center;background-color:#dcdfe1;color:#fff;font-weight:bold;font-size:15px}#wpwrap .a0-steps .steps p{display:none;color:#575c60;font-weight:bold;padding-top:10px;font-size:15px;width:105px;margin:auto}#wpwrap .a0-steps .steps .active span{background-color:#eb5424}#wpwrap .a0-steps .steps .active p{display:block}#wpwrap .consent-disclaimer .logo{width:100px;margin:20px 0}#wpwrap .a0-message{line-height:24px;font-size:12px;border-radius:3px;position:relative;color:rgba(0,0,0,0.86);padding:15px;}#wpwrap .a0-message.a0-step-text{font-size:14px}#wpwrap .a0-message.multiline{line-height:25px;padding:10px 20px}#wpwrap .a0-message.a0-notice{background-color:#d0e8f4;color:#32759a}#wpwrap .a0-message.a0-tip{background-color:#e4e6e8;}#wpwrap .a0-message.a0-tip a{color:rgba(0,0,0,0.86)}#wpwrap .a0-message.a0-warning{background:#fff7c9;color:#786600;}#wpwrap .a0-message.a0-warning a.link{color:#786600;font-decoration:underline}#wpwrap .a0-message b{font-weight:bold;text-transform:uppercase}#wpwrap .a0-message a{text-decoration:underline}#wpwrap .a0-message img{position:absolute;left:20px;top:20px}#wpwrap .a0-message .a0-button{border:0;margin:-4px;margin-left:10px;font-size:12px;line-height:12px;padding:10px 15px}#wpwrap .modal-content .a0-message{margin:20px 0}#wpwrap .modal-content .link{line-height:25px;margin-bottom:20px;cursor:pointer}#wpwrap .a0-profiles{margin-top:30px;margin-bottom:30px;}@media (min-width:768px){#wpwrap .a0-profiles .col:nth-of-type(1){padding-left:0;padding-right:10px}#wpwrap .a0-profiles .col:nth-of-type(2){padding-left:10px;padding-right:0}}#wpwrap .a0-profiles .profile{background-color:#f2f5f8;border-radius:3px;padding:25px;text-align:center;margin-bottom:20px;}#wpwrap .a0-profiles .profile h2{font-size:22px}#wpwrap .a0-profiles .profile p{font-size:14px;margin:20px 10px;min-height:6em}#wpwrap .a0-profiles .profile img{width:100px;height:100px;border-radius:50px;margin-bottom:20px}#wpwrap .modal-footer{text-align:center}#wpwrap .enterprise-connections{margin-top:30px;padding:0;}#wpwrap .enterprise-connections .connection{background-color:#f5f7f9;text-align:center;border-radius:3px;padding:20px;margin-bottom:30px;}#wpwrap .enterprise-connections .connection .title-wrapper{min-height:50px}#wpwrap .enterprise-connections .connection h4{line-height:24px;font-size:17px}#wpwrap .enterprise-connections .connection .logo{width:100px;height:100px;border-radius:50px;background-size:55% !important;margin:0 auto 20px}#wpwrap .enterprise-connections .connection a{color:rgba(0,0,0,0.86);cursor:pointer}#wpwrap .connections-wrapper{margin-top:30px;padding:0 15px;}@media (min-width:768px){#wpwrap .connections-wrapper{height:600px;overflow-y:scroll}#wpwrap .connections-wrapper::-webkit-scrollbar{width:14px}#wpwrap .connections-wrapper::-webkit-scrollbar-track{background:#f3f3f3;border-radius:8px;border:3px solid #fff}#wpwrap .connections-wrapper::-webkit-scrollbar-thumb{border:3px solid #fff;border-radius:8px;background:#d9d9de}}#wpwrap .connections{border-top:1px #d0d2d3 solid;border-left:1px #d0d2d3 solid;}#wpwrap .connections .connection{float:left;border-top:none;background-color:#f7f7f7;border-right:1px #d0d2d3 solid;border-bottom:1px #d0d2d3 solid;}#wpwrap .connections .connection .a0-switch{float:right;position:relative;top:35px;right:15px}#wpwrap .connections .connection .logo{width:100px;height:70px;margin:15px;padding-right:15px;padding-left:15px;}#wpwrap .connections .connection .logo .logo-child{width:100px;height:70px;background-repeat:no-repeat;background-position:center center;background-size:80%}#wpwrap .connections .connection .logo[data-logo="SAP"] .logo-child{background-size:80%}#wpwrap .connections .connection .logo[data-logo="Twitter"] .logo-child{background-size:60%}#wpwrap .connections .connection .logo[data-logo="Box"] .logo-child{background-size:70%;transform:translateX(-10%)}#wpwrap .connections .connection .logo[data-logo="vk"] .logo-child{background-size:55%}#wpwrap .a0-switch{display:inline-block;}#wpwrap .a0-switch input{display:none}#wpwrap .a0-switch label{position:relative;display:block;width:50px;height:30px;border-radius:15px;background-color:#a9a9a9}#wpwrap .a0-switch input:checked + label{background-color:#45db5e}#wpwrap .a0-switch label::before{position:absolute;content:" ";width:26px;height:26px;border-radius:13px;top:2px;left:2px;background-color:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,0.25),0 4px 11px 0 rgba(0,0,0,0.08),-1px 3px 3px 0 rgba(0,0,0,0.14);transition:left 300ms cubic-bezier(.42,.8,.58,1.2)}#wpwrap .a0-switch input:checked + label::before{left:22px}#wpwrap .a0-db-connection{padding-right:90px;position:relative;}#wpwrap .a0-db-connection .a0-step-text{margin:30px 0}#wpwrap .a0-db-connection .a0-switch{position:absolute;right:20px;top:60px}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);transform:rotate(360deg)}}#wpwrap .a0-spinner-css{display:inline-block;font-size:10px;position:relative;text-indent:-9999em;border-top:2px solid rgba(0,0,0,0.3);border-right:2px solid rgba(0,0,0,0.3);border-bottom:2px solid rgba(0,0,0,0.3);border-left:2px solid rgba(0,0,0,0.9);-webkit-animation:loaderAnim .8s infinite linear;animation:loaderAnim .8s infinite linear;-webkit-border-radius:50%;border-radius:50%;background-clip:padding-box;width:40px;height:40px}#wpwrap .lock{padding-top:30px;position:relative;}#wpwrap .lock .loading{position:absolute;top:30px;bottom:0;background:rgba(255,255,255,0.5);z-index:9999;margin:auto;width:300px;display:none;}#wpwrap .lock .loading .vcenter-wrapper{display:table;height:100%;margin:auto}#wpwrap .lock .loading .centrix{display:table-cell;vertical-align:middle}#wpwrap .lock.loading .loading{display:block}#wpwrap .lock.loading #a0-lock{overflow:hidden}#wpwrap .lock #a0-lock{margin:auto;width:300px}#wpwrap .a0-admin-creation{margin-top:20px;}#wpwrap .a0-admin-creation input[type=text],#wpwrap .a0-admin-creation input[type=password]{width:100%;border:1px solid rgba(91,102,111,0.54);height:50px;line-height:1em;padding:10px;}#wpwrap .a0-admin-creation input[type=text]#admin-email,#wpwrap .a0-admin-creation input[type=password]#admin-email{border-radius:3px 3px 0 0;background-color:#e5e5e5}#wpwrap .a0-admin-creation input[type=text]#admin-password,#wpwrap .a0-admin-creation input[type=password]#admin-password{border-top:none;border-radius:0 0 3px 3px}#wpwrap .a0-final-step{text-align:center;}#wpwrap .a0-final-step h1{margin-bottom:0;margin-top:30px}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .a0-final-step .checkmark{width:90px;height:90px;border-radius:50%;display:block;stroke-width:2;stroke:#fff;stroke-miterlimit:10;margin:0 auto;box-shadow:inset 0 0 0 #7ac142;-webkit-animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;}#wpwrap .a0-final-step .checkmark .checkmark__check{transform-origin:50% 50%}#wpwrap .a0-final-step .checkmark .checkmark__circle{stroke-dasharray:166;stroke-dashoffset:166;stroke-width:2;stroke-miterlimit:10;stroke:#7ac142;-webkit-animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards;animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards}@-moz-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-o-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .settings h3{margin:30px 0 10px}#wpwrap .settings .a0-message.manage{margin-bottom:30px;margin-top:30px}#wpwrap .settings .nav-tabs{margin:30px 0;}#wpwrap .settings .nav-tabs a{color:#4a4a4a;box-shadow:none;font-size:17px}#wpwrap .settings .a0-step-text{margin:0 0 30px}#wpwrap .settings .top-margin{margin-top:30px}#wpwrap .settings .no-bottom-margin{margin-bottom:0}#wpwrap .settings .form-table th,#wpwrap .settings .form-table label,#wpwrap .settings .form-wrap label{color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password],#wpwrap .settings textarea{border:1px solid #ccc;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password]{line-height:1em;height:40px}#wpwrap .settings #wpa0_icon_url{width:50%;display:inline-block}#wpwrap .settings .subelement{padding:5px 0}#wpwrap .settings .link{font-weight:bold;text-decoration:underline;cursor:pointer}#wpwrap .settings .nav>li>a{padding:10px 0;margin-right:40px;font-size:15px;}@media (max-width:768px){#wpwrap .settings .nav>li>a{margin-right:10px}}#wpwrap .settings .nav>li>a:hover,#wpwrap .settings .nav>li>a:focus{text-decoration:none;background-color:#fff;border-color:transparent transparent #ddd}#wpwrap .settings .nav-tabs>li.active>a,#wpwrap .settings .nav-tabs>li.active>a:hover,#wpwrap .settings .nav-tabs>li.active>a:focus{color:#33b6e3;border-color:transparent transparent #33b6e3}#wpwrap .settings .form-wrap p,#wpwrap .settings p.description,#wpwrap .settings p.help,#wpwrap .settings span.description{font-style:normal;color:rgba(0,0,0,0.5)}#wpwrap .settings label{margin-right:10px}#wpwrap .settings .connections{margin-top:30px}#wpwrap .a0-table{margin:30px;width:initial}#wpwrap #manuallySetToken{margin-right:15px}#wpwrap .a0-feedback{background-color:#f2f5f8;padding:30px;margin-top:30px;border-radius:3px;}#wpwrap .a0-feedback h2{font-size:18px;margin-bottom:15px;}#wpwrap .a0-feedback h2.message{margin:0}#wpwrap .a0-feedback .a0-separator{margin:20px 0}#wpwrap .a0-feedback input.feedback_calification{display:none}#wpwrap .a0-feedback input:checked + .feedback-face{opacity:1}#wpwrap .a0-feedback .a0-buttons{margin:15px 0 0;}#wpwrap .a0-feedback .a0-buttons .a0-button{min-width:auto;cursor:pointer}#wpwrap .a0-feedback textarea{padding:10px;height:90px}#wpwrap .a0-feedback .feedback-face{width:40px;height:40px;display:inline-block;background-size:contain;opacity:.4;margin-right:30px;cursor:pointer;}#wpwrap .a0-feedback .feedback-face:hover{opacity:.7}#wpwrap .a0-feedback .feedback-face.calification-1{background-image:url("../img/rates/01.svg")}#wpwrap .a0-feedback .feedback-face.calification-2{background-image:url("../img/rates/02.svg")}#wpwrap .a0-feedback .feedback-face.calification-3{background-image:url("../img/rates/03.svg")}#wpwrap .a0-feedback .feedback-face.calification-4{background-image:url("../img/rates/04.svg")}#wpwrap .a0-feedback .feedback-face.calification-5{background-image:url("../img/rates/05.svg")}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}} \ No newline at end of file diff --git a/assets/css/initial-setup/main.styl b/assets/css/initial-setup/main.styl index a899a460..3e36594b 100644 --- a/assets/css/initial-setup/main.styl +++ b/assets/css/initial-setup/main.styl @@ -23,7 +23,9 @@ .a0-wrap { font-family:'avenir roman'; margin-left:-10px; - + padding-left: 2%; + padding-right: 2%; + a, .link { color:aText; } @@ -114,6 +116,12 @@ margin-left: 25px; } } + + code { + background: #f1f1f1; + color: #777; + line-height: 2em; + } textarea.code { font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; @@ -144,6 +152,12 @@ form { margin:0; + + [disabled] { + opacity: 0.5; + font-size: 0.9em; + margin-top: 0.3em; + } } .container-fluid { diff --git a/assets/css/initial-setup/partials/_colors.styl b/assets/css/initial-setup/partials/_colors.styl index e68f2218..8010e211 100644 --- a/assets/css/initial-setup/partials/_colors.styl +++ b/assets/css/initial-setup/partials/_colors.styl @@ -7,7 +7,7 @@ tipBG = #E4E6E8; aText=rgb(0,148,193); text = rgba(0,0,0,.86); -softText = rgba(0,0,0,0.36); +softText = rgba(0,0,0,0.5); formFieldsText = rgba(0,0,0,.86) buttonPrimaryText = #FFFFFF; diff --git a/circle.yml b/circle.yml index 3a4095fd..f18150ba 100644 --- a/circle.yml +++ b/circle.yml @@ -19,8 +19,9 @@ test: phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/wimg/php-compatibility override: - phpcs --standard=$HOME/wp-auth0/phpcs-compat-ruleset.xml $HOME/wp-auth0 -pn -d memory_limit=-1 + - phpcbf --standard=$HOME/wp-auth0/phpcs-ruleset.xml $HOME/wp-auth0 -p -d memory_limit=-1 - phpcs --standard=$HOME/wp-auth0/phpcs-test-ruleset.xml $HOME/wp-auth0/tests -pn -d memory_limit=-1 - - phpcbf --standard=$HOME/wp-auth0/phpcs-compat-ruleset.xml $HOME/wp-auth0 -p -d memory_limit=-1 + - phpcbf --standard=$HOME/wp-auth0/phpcs-test-ruleset.xml $HOME/wp-auth0/tests -p -d memory_limit=-1 - | rm -rf $WP_TESTS_DIR $WP_CORE_DIR bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 3.8 diff --git a/composer.json b/composer.json index b8d64f46..646894d8 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "phpcs-tests": "./vendor/bin/phpcs --standard=phpcs-test-ruleset.xml -s ./tests/", "phpcs-path": "SHELL_INTERACTIVE=1 ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s", "phpcbf": "./vendor/bin/phpcbf --standard=phpcs-ruleset.xml .", + "phpcbf-tests": "./vendor/bin/phpcbf --standard=phpcs-test-ruleset.xml -s ./tests/", "phpcbf-path": "SHELL_INTERACTIVE=1 ./vendor/bin/phpcbf --standard=phpcs-ruleset.xml", "sniffs": "./vendor/bin/phpcs --standard=phpcs-ruleset.xml -e", "test": "./vendor/bin/phpunit --coverage-text", diff --git a/lib/WP_Auth0_Configure_JWTAUTH.php b/lib/WP_Auth0_Configure_JWTAUTH.php index 304e3deb..38d901b8 100755 --- a/lib/WP_Auth0_Configure_JWTAUTH.php +++ b/lib/WP_Auth0_Configure_JWTAUTH.php @@ -27,7 +27,7 @@ public function notify_jwt() { ?>
- +
diff --git a/lib/WP_Auth0_Options_Generic.php b/lib/WP_Auth0_Options_Generic.php index e89ae691..99a97b6f 100644 --- a/lib/WP_Auth0_Options_Generic.php +++ b/lib/WP_Auth0_Options_Generic.php @@ -1,69 +1,220 @@ get_defaults( true ); + foreach ( $option_keys as $key ) { + if ( $this->has_constant_val( $key ) ) { + $this->constant_opts[ $key ] = $this->get_constant_val( $key ); + } + } + } + + /** + * Takes an option key and creates the constant name to look for. + * + * @param string $key - Option key to transform. + * + * @return string + */ + public function get_constant_name( $key ) { + $constant_prefix = apply_filters( 'wp_auth0_settings_constant_prefix', 'AUTH0_ENV_' ); + return $constant_prefix . strtoupper( $key ); + } + + /** + * Does a certain option pull from a constant? + * + * @param string $key - Option key to check. + * + * @return boolean + */ + public function has_constant_val( $key ) { + $setting_const = $this->get_constant_name( $key ); + return defined( $setting_const ); + } + + /** + * Get the value of an overriding constant if one is set, return null if not. + * + * @param string $key - Option key to look for. + * + * @return string|null + */ + public function get_constant_val( $key ) { + return $this->has_constant_val( $key ) ? constant( $this->get_constant_name( $key ) ) : null; + } + + /** + * Get all the keys for constant-overridden settings. + * + * @return array + */ + public function get_all_constant_keys() { + return array_keys( $this->constant_opts ); + } + + /** + * Get the option_name for the settings array. + * + * @return string + */ public function get_options_name() { return $this->_options_name; } + /** + * Return options from memory, database, defaults, or constants. + * + * @return array + */ public function get_options() { - if ( empty( $this->_opt ) ) { + if ( empty( $this->_opts ) ) { $options = get_option( $this->_options_name, array() ); + if ( empty( $options ) || ! is_array( $options ) ) { - if ( ! is_array( $options ) ) { + // Brand new install, no saved options so get all defaults. $options = $this->defaults(); - } + } else { - $options = array_merge( $this->defaults(), $options ); + // Make sure we have settings for everything we need. + $options = array_merge( $this->defaults(), $options ); + } - $this->_opt = $options; + // Check for constant overrides and replace. + if ( ! empty( $this->constant_opts ) ) { + $options = array_replace_recursive( $options, $this->constant_opts ); + } + $this->_opts = $options; } - return $this->_opt; + return $this->_opts; } /** - * Return a settings value + * Return a filtered settings value or default. * - * @param string $key - settings key - * @param null $default - what to return if a value is not set + * @param string $key - Settings key to get. + * @param mixed $default - Default value to return if not found. * * @return mixed + * + * @link https://auth0.com/docs/cms/wordpress/extending#wp_auth0_get_option */ public function get( $key, $default = null ) { $options = $this->get_options(); - $value = $default; - - if ( isset( $options[ $key ] ) ) { - $value = $options[ $key ]; - } - + $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; return apply_filters( 'wp_auth0_get_option', $value, $key ); } + /** + * Update a setting if not already stored in a constant. + * This method will fail silently if the option is already set in a constant. + * + * @param string $key - Option key name to update. + * @param mixed $value - Value to update with. + * @param bool $should_update - Flag to update DB options array with value stored in memory. + * + * @return bool + */ public function set( $key, $value, $should_update = true ) { - $options = $this->get_options(); + $options = $this->get_options(); + + // Cannot set a setting that is being overridden by a constant. + if ( $this->has_constant_val( $key ) ) { + return false; + } + $options[ $key ] = $value; - $this->_opt = $options; + $this->_opts = $options; - if ( $should_update ) { - update_option( $this->_options_name, $options ); + // No database update so process completed successfully. + if ( ! $should_update ) { + return true; } + + return $this->update_all(); } + /** + * Save the options array as it exists in memory. + * + * @return bool + */ public function update_all() { - update_option( $this->_options_name, $this->_opt ); + foreach ( $this->get_all_constant_keys() as $key ) { + unset( $this->_opts[ $key ] ); + } + return update_option( $this->_options_name, $this->_opts ); } + /** + * Save the options array for the first time. + */ public function save() { - $options = $this->get_options(); - update_option( $this->_options_name, $options ); + $this->get_options(); + $this->update_all(); } + + /** + * Delete the options array. + * + * @return bool + */ public function delete() { - delete_option( $this->_options_name ); + return delete_option( $this->_options_name ); + } + + /** + * Return default options as key => value or just keys. + * + * @param bool $keys_only - Only return the array keys for the default options. + * + * @return array + */ + public function get_defaults( $keys_only = false ) { + $default_opts = $this->defaults(); + return $keys_only ? array_keys( $default_opts ) : $default_opts; } + /** + * Default settings when plugin is installed or reset + * + * @return array + */ protected function defaults() { return array(); } diff --git a/lib/admin/WP_Auth0_Admin.php b/lib/admin/WP_Auth0_Admin.php index fe980ade..9ea76698 100755 --- a/lib/admin/WP_Auth0_Admin.php +++ b/lib/admin/WP_Auth0_Admin.php @@ -97,12 +97,29 @@ public function init_admin() { ); } - public function input_validator( $input ) { + /** + * Main validator for settings page inputs. + * Delegates validation to settings sections in self::init_admin(). + * + * @param array $input - Incoming array of settings fields to validate. + * + * @return mixed + */ + public function input_validator( array $input ) { + $constant_keys = $this->a0_options->get_all_constant_keys(); - $old_options = $this->a0_options->get_options(); + // Look for and set constant overrides so validation is still possible. + foreach ( $constant_keys as $key ) { + $input[ $key ] = $this->a0_options->get_constant_val( $key ); + } foreach ( $this->sections as $name => $section ) { - $input = $section->input_validator( $input, $old_options ); + $input = $section->input_validator( $input ); + } + + // Remove constant overrides so they are not saved to the database. + foreach ( $constant_keys as $key ) { + unset( $input[ $key ] ); } return $input; diff --git a/lib/admin/WP_Auth0_Admin_Advanced.php b/lib/admin/WP_Auth0_Admin_Advanced.php index 696aaf75..b6552ca3 100644 --- a/lib/admin/WP_Auth0_Admin_Advanced.php +++ b/lib/admin/WP_Auth0_Admin_Advanced.php @@ -360,6 +360,7 @@ public function render_migration_ws( $args = array() ) { $this->get_dashboard_link() ); $this->render_field_description( 'Security token:' ); + $this->render_const_notice( 'migration_token' ); printf( '', $this->_textarea_rows, diff --git a/lib/admin/WP_Auth0_Admin_Appearance.php b/lib/admin/WP_Auth0_Admin_Appearance.php index d3e2592b..6260a540 100644 --- a/lib/admin/WP_Auth0_Admin_Appearance.php +++ b/lib/admin/WP_Auth0_Admin_Appearance.php @@ -196,12 +196,19 @@ public function render_custom_js( $args = array() ) { * @see add_settings_field() */ public function render_username_style( $args = array() ) { - $opt_name = $args['opt_name']; - $id_attr = $args['label_for']; - $value = $this->options->get( $opt_name ); - $this->render_radio_button( $id_attr . '_au', $opt_name, '', 'Auto', empty( $value ) ); - $this->render_radio_button( $id_attr . '_em', $opt_name, 'email', '', 'email' === $value ); - $this->render_radio_button( $id_attr . '_un', $opt_name, 'username', '', 'username' === $value ); + $this->render_radio_buttons( + array( + array( + 'label' => 'Auto', + 'value' => '', + ), + 'email', + 'username', + ), + $args['label_for'], + $args['opt_name'], + $this->options->get( $args['opt_name'], '' ) + ); $this->render_field_description( __( 'To allow the user to use either email or username to login, leave this as "Auto." ', 'wp-auth0' ) . __( 'Only database connections that require a username will allow username logins', 'wp-auth0' ) diff --git a/lib/admin/WP_Auth0_Admin_Basic.php b/lib/admin/WP_Auth0_Admin_Basic.php index 8597b061..31412817 100755 --- a/lib/admin/WP_Auth0_Admin_Basic.php +++ b/lib/admin/WP_Auth0_Admin_Basic.php @@ -193,9 +193,13 @@ public function render_client_secret_b64_encoded( $args = array() ) { * @see add_settings_field() */ public function render_client_signing_algorithm( $args = array() ) { - $value = $this->options->get( $args['opt_name'], WP_Auth0_Api_Client::DEFAULT_CLIENT_ALG ); - $this->render_radio_button( $args['label_for'] . '_hs', $args['opt_name'], 'HS256', '', 'HS256' === $value ); - $this->render_radio_button( $args['label_for'] . '_rs', $args['opt_name'], 'RS256', '', 'RS256' === $value ); + $curr_value = $this->options->get( $args['opt_name'] ) ?: WP_Auth0_Api_Client::DEFAULT_CLIENT_ALG; + $this->render_radio_buttons( + array( 'HS256', 'RS256' ), + $args['label_for'], + $args['opt_name'], + $curr_value + ); $this->render_field_description( __( 'This value can be found the Application settings in the ' ) . $this->get_dashboard_link( 'applications' ) . diff --git a/lib/admin/WP_Auth0_Admin_Features.php b/lib/admin/WP_Auth0_Admin_Features.php index 87ef7684..232e724e 100644 --- a/lib/admin/WP_Auth0_Admin_Features.php +++ b/lib/admin/WP_Auth0_Admin_Features.php @@ -112,14 +112,21 @@ public function init() { * @see add_settings_field() */ public function render_password_policy( $args = array() ) { - $opt_name = $args['opt_name']; - $id_attr = $args['label_for']; - $curr_val = $this->options->get( $opt_name ); - - $this->render_radio_button( $id_attr . '_none', $opt_name, '', 'None', empty( $curr_val ) ); - foreach ( array( 'low', 'fair', 'good', 'excellent' ) as $val ) { - $this->render_radio_button( $id_attr . '_' . $val, $opt_name, $val, '', $val === $curr_val ); - } + $this->render_radio_buttons( + array( + array( + 'label' => 'None', + 'value' => '', + ), + 'low', + 'fair', + 'good', + 'excellent', + ), + $args['label_for'], + $args['opt_name'], + $this->options->get( $args['opt_name'], 'fair' ) + ); $this->render_field_description( __( 'Password security policy for the database connection used by this application. ', 'wp-auth0' ) . __( 'Changing the policy here will change it for all other applications using this database. ', 'wp-auth0' ) . diff --git a/lib/admin/WP_Auth0_Admin_Generic.php b/lib/admin/WP_Auth0_Admin_Generic.php index 2a0455f2..ef3f6d09 100644 --- a/lib/admin/WP_Auth0_Admin_Generic.php +++ b/lib/admin/WP_Auth0_Admin_Generic.php @@ -124,14 +124,18 @@ protected function rule_validation( $old_options, $input, $key, $rule_name, $rul */ protected function render_switch( $id, $input_name, $expand_id = '' ) { $value = $this->options->get( $input_name ); + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } printf( - '
+ '
', esc_attr( $this->_option_name ), esc_attr( $input_name ), esc_attr( $id ), ! empty( $expand_id ) ? esc_attr( $expand_id ) : '', checked( empty( $value ), false, false ), + $field_is_const ? 'disabled' : '', esc_attr( $id ) ); } @@ -147,20 +151,25 @@ protected function render_switch( $id, $input_name, $expand_id = '' ) { */ protected function render_text_field( $id, $input_name, $type = 'text', $placeholder = '', $style = '' ) { $value = $this->options->get( $input_name ); + // Secure fields are not output by default; validation keeps last value if a new one is not entered if ( 'password' === $type ) { $placeholder = ! empty( $value ) ? 'Not visible' : ''; $value = ''; } + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } printf( - '', + '', esc_attr( $type ), esc_attr( $this->_option_name ), esc_attr( $input_name ), esc_attr( $id ), esc_attr( $value ), $placeholder ? esc_attr( $placeholder ) : '', - $style ? esc_attr( $style ) : '' + $style ? esc_attr( $style ) : '', + $field_is_const ? 'disabled' : '' ); } @@ -172,36 +181,48 @@ protected function render_text_field( $id, $input_name, $type = 'text', $placeho */ protected function render_textarea_field( $id, $input_name ) { $value = $this->options->get( $input_name ); + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } printf( - '', + '', esc_attr( $this->_option_name ), esc_attr( $input_name ), esc_attr( $id ), $this->_textarea_rows, + $field_is_const ? 'disabled' : '', esc_textarea( $value ) ); } /** - * Output a radio button + * Output one or many radio buttons associated to the same option key. * - * @param string $id - input id attribute - * @param string $input_name - input name attribute - * @param string|integer|float $value - input value attribute - * @param string $label - input label text - * @param bool $selected - is it active? + * @param array $buttons - Array of buttons to output; items can be strings or arrays with "label" and "value" keys. + * @param string $id - Input ID attribute. + * @param string $input_name - Option name saved to the options array. + * @param int|float|string $curr_value - Current option value. */ - protected function render_radio_button( $id, $input_name, $value, $label = '', $selected = false ) { - printf( - '', - esc_attr( $id ), - esc_attr( $this->_option_name ), - esc_attr( $input_name ), - esc_attr( $id ), - esc_attr( $value ), - checked( $selected, true, false ), - sanitize_text_field( ! empty( $label ) ? $label : ucfirst( $value ) ) - ); + protected function render_radio_buttons( array $buttons, $id, $input_name, $curr_value ) { + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } + foreach ( $buttons as $index => $button ) { + $id_attr = $id . '_' . $index; + $label = is_array( $button ) ? $button['label'] : ucfirst( $button ); + $value = is_array( $button ) ? $button['value'] : $button; + printf( + '', + esc_attr( $id_attr ), + esc_attr( $this->_option_name ), + esc_attr( $input_name ), + esc_attr( $id_attr ), + esc_attr( $value ), + checked( $value === $curr_value, true, false ), + $field_is_const ? 'disabled' : '', + sanitize_text_field( $label ) + ); + } } /** @@ -213,6 +234,19 @@ protected function render_field_description( $text ) { printf( '
%s.
', $text ); } + /** + * Check if the setting is provided by a constant and indicate. + * + * @param string $input_name - Input name for the field, used as option key. + */ + protected function render_const_notice( $input_name ) { + printf( + '

%s %s

', + __( 'Value is set in the constant ', 'wp-auth0' ), + $this->options->get_constant_name( $input_name ) + ); + } + /** * Output translated dashboard HTML link * diff --git a/phpcs-test-ruleset.xml b/phpcs-test-ruleset.xml index 3fcb4f4b..c74ca821 100644 --- a/phpcs-test-ruleset.xml +++ b/phpcs-test-ruleset.xml @@ -2,12 +2,8 @@ A custom coding standard for WP-Auth0 tests - - /tests/* - - @@ -17,8 +13,14 @@ - - - + + + + + + + + + \ No newline at end of file diff --git a/templates/back-to-auth0.php b/templates/back-to-auth0.php index 55d147bd..a9eeacaa 100644 --- a/templates/back-to-auth0.php +++ b/templates/back-to-auth0.php @@ -13,5 +13,5 @@ }
- +
diff --git a/templates/initial-setup/partials/header.php b/templates/initial-setup/partials/header.php index 03cb5206..d67aaff5 100644 --- a/templates/initial-setup/partials/header.php +++ b/templates/initial-setup/partials/header.php @@ -1,3 +1,6 @@ +
diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a1b0e3c4..ef64e500 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,7 @@ /** * PHPUnit bootstrap file * - * @package Auth0 + * @package WP-Auth0 */ $_tests_dir = getenv( 'WP_TESTS_DIR' ); @@ -31,10 +31,10 @@ function _manually_load_plugin() { require $_tests_dir . '/includes/bootstrap.php'; spl_autoload_register( - function( $className ) { - $fileName = stream_resolve_include_path( 'traits/' . $className . '.php' ); - if ( false !== $fileName ) { - include $fileName; + function( $class_name ) { + $file_name = stream_resolve_include_path( 'traits/' . $class_name . '.php' ); + if ( false !== $file_name ) { + include $file_name; } } ); diff --git a/tests/testConstantSettings.php b/tests/testConstantSettings.php new file mode 100644 index 00000000..ca4a3714 --- /dev/null +++ b/tests/testConstantSettings.php @@ -0,0 +1,193 @@ +get_all_constant_keys(); + $this->assertCount( 3, $constant_keys ); + $this->assertContains( 'domain', $constant_keys ); + $this->assertContains( 'client_id', $constant_keys ); + $this->assertContains( 'client_secret', $constant_keys ); + } + + /** + * Test that setting a constant will store the constant key. + */ + public function testConstantPrefixFilter() { + $opts = new WP_Auth0_Options(); + $opt_name = 'domain'; + + $this->assertEquals( self::DEFAULT_CONSTANT_PREFIX . 'DOMAIN', $opts->get_constant_name( $opt_name ) ); + + add_filter( + 'wp_auth0_settings_constant_prefix', function( $prefix ) { + return '__TEST_PREFIX_' . $prefix; + }, 10, 2 + ); + + $this->assertEquals( + '__TEST_PREFIX_' . self::DEFAULT_CONSTANT_PREFIX . 'DOMAIN', + $opts->get_constant_name( $opt_name ) + ); + } + + /** + * Test that setting a constant will change it's value on output. + */ + public function testThatConstantOverridesWork() { + $opts = new WP_Auth0_Options(); + $expected_opts = []; + $option_keys = array_keys( $opts->get_options() ); + + // Connections contains a sub-array of connection settings, does not need to be overridden. + foreach ( $option_keys as $opt_name ) { + $expected_opts[ $opt_name ] = rand(); + $constant_name = $opts->get_constant_name( $opt_name ); + $this->assertNull( $opts->get_constant_val( $opt_name ) ); + define( $constant_name, $expected_opts[ $opt_name ] ); + $this->assertTrue( $opts->has_constant_val( $opt_name ) ); + } + + // Create a new instance of the class to reset constant-set options. + $opts = new WP_Auth0_Options(); + foreach ( $option_keys as $opt_name ) { + $this->assertEquals( $expected_opts[ $opt_name ], $opts->get_constant_val( $opt_name ), 'Opt name: ' . $opt_name ); + $this->assertEquals( $expected_opts[ $opt_name ], $opts->get( $opt_name ), 'Opt name: ' . $opt_name ); + } + } + + /** + * Test that options can be set in memory and in the DB. + */ + public function testSet() { + $opt_name = 'domain'; + $expected_val_1 = rand(); + $expected_val_2 = rand(); + $opts = new WP_Auth0_Options(); + + // Test that a basic set without DB update works. + $result = $opts->set( $opt_name, $expected_val_1, false ); + $this->assertTrue( $result ); + $this->assertEquals( $expected_val_1, $opts->get( $opt_name ) ); + $db_options = get_option( $opts->get_options_name() ); + $this->assertNotEquals( $expected_val_1, $db_options[ $opt_name ] ); + + // Test that a basic set with DB update works. + $result = $opts->set( $opt_name, $expected_val_2, true ); + $this->assertTrue( $result ); + $this->assertEquals( $expected_val_2, $opts->get( $opt_name ) ); + $db_options = get_option( $opts->get_options_name() ); + $this->assertEquals( $expected_val_2, $db_options[ $opt_name ] ); + } + + /** + * Test that options cannot be set when a constant is present. + */ + public function testSetWithConstant() { + $opt_name = 'domain'; + $expected_val = rand(); + $opts = new WP_Auth0_Options(); + $constant_name = $opts->get_constant_name( $opt_name ); + + // Set a constant and make sure it works. + $this->assertNull( $opts->get_constant_val( $opt_name ) ); + define( $constant_name, $expected_val ); + $this->assertEquals( $expected_val, $opts->get_constant_val( $opt_name ) ); + + // Try to set an option with the constant set. + $result = $opts->set( $opt_name, rand(), false ); + $this->assertFalse( $result ); + $this->assertNotEquals( $expected_val, $opts->get( $opt_name ) ); + } + + /** + * Test that commonly-overridden settings will show a notice. + */ + public function testConstantSettingNoticeBasic() { + $opts = new WP_Auth0_Options(); + $admin = new WP_Auth0_Admin_Basic( $opts ); + + $fields = [ + [ + 'opt_name' => 'domain', + 'label_for' => 'wpa0_domain', + 'render_function' => 'render_domain', + ], + [ + 'opt_name' => 'client_id', + 'label_for' => 'wpa0_client_id', + 'render_function' => 'render_client_id', + ], + [ + 'opt_name' => 'client_secret', + 'label_for' => 'wpa0_client_secret', + 'render_function' => 'render_client_secret', + ], + [ + 'opt_name' => 'auth0_app_token', + 'label_for' => 'wpa0_auth0_app_token', + 'render_function' => 'render_auth0_app_token', + ], + ]; + + foreach ( $fields as $field ) { + $constant_name = self::DEFAULT_CONSTANT_PREFIX . strtoupper( $field['opt_name'] ); + $override_val = self::FILTER_TEST_STRING . rand(); + define( $constant_name, $override_val ); + + ob_start(); + $admin->{$field['render_function']}( $field ); + $field_html = ob_get_clean(); + + $input = $this->getDomListFromTagName( $field_html, 'input' ); + $this->assertTrue( $input->item( 0 )->hasAttribute( 'disabled' ) ); + $this->assertContains( self::CONSTANT_NOTICE_TEXT, $field_html ); + $this->assertContains( $constant_name, $field_html ); + } + } +} diff --git a/tests/testCustomDomains.php b/tests/testCustomDomains.php index a2ee6869..f512054c 100644 --- a/tests/testCustomDomains.php +++ b/tests/testCustomDomains.php @@ -1,4 +1,11 @@ assertEquals( self::OPTIONS_NAME, $opts->get_options_name() ); // Make sure the number of options has not changed unintentionally. - $this->assertEquals( 67, count( $opts->get_options() ) ); + $this->assertEquals( self::DEFAULT_OPTIONS_COUNT, count( $opts->get_options() ) ); + $this->assertEquals( self::DEFAULT_OPTIONS_COUNT, count( $opts->get_defaults() ) ); + + $opts_generic = new WP_Auth0_Options_Generic(); + $this->assertEmpty( $opts_generic->get_defaults() ); } /** @@ -61,24 +74,78 @@ public function testThatFiltersOverrideValues() { } /** - * Test that options can be set in memory and in the DB. + * Test that options can be set in memory without a DB update + */ + public function testSetWithoutSave() { + $opt_name = 'domain'; + $expected_val = rand(); + $opts = new WP_Auth0_Options(); + + // Set the option and do not save. + $opts->set( $opt_name, $expected_val, false ); + $this->assertEquals( $expected_val, $opts->get( $opt_name ) ); + + // Get the DB-saved options and make sure it was not saved. + $db_options = get_option( $opts->get_options_name() ); + $this->assertNotEquals( $expected_val, $db_options[ $opt_name ] ); + } + + /** + * Test that options can be set and saved to the DB. + */ + public function testSetWithSave() { + $opt_name = 'domain'; + $expected_val = rand(); + $opts = new WP_Auth0_Options(); + + // Set the option and flag to save (default). + $opts->set( $opt_name, $expected_val ); + $this->assertEquals( $expected_val, $opts->get( $opt_name ) ); + + // Make sure the saved value is correct. + $db_options = get_option( $opts->get_options_name() ); + $this->assertEquals( $expected_val, $db_options[ $opt_name ] ); + } + + /** + * Test that update_all works. */ - public function testSet() { - $opt_name = 'domain'; - $expected_val_1 = rand(); - $expected_val_2 = rand(); - $opts = new WP_Auth0_Options(); - - // Test that a basic set without DB update works. - $opts->set( $opt_name, $expected_val_1, false ); - $this->assertEquals( $expected_val_1, $opts->get( $opt_name ) ); + public function testUpdateAll() { + $opt_name = 'domain'; + $expected_val = rand(); + $opts = new WP_Auth0_Options(); + + // Set the option and flag to skip saving. + $opts->set( $opt_name, $expected_val, false ); + $this->assertEquals( $expected_val, $opts->get( $opt_name ) ); + + // Get the database option to make sure it was not saved. $db_options = get_option( $opts->get_options_name() ); - $this->assertNotEquals( $expected_val_1, $db_options[ $opt_name ] ); + $this->assertNotEquals( $expected_val, $db_options[ $opt_name ] ); - // Test that a basic set with DB update works. - $opts->set( $opt_name, $expected_val_2, true ); - $this->assertEquals( $expected_val_2, $opts->get( $opt_name ) ); + // Explicitly save to the DB and make sure it's correct. + $opts->update_all(); $db_options = get_option( $opts->get_options_name() ); - $this->assertEquals( $expected_val_2, $db_options[ $opt_name ] ); + $this->assertEquals( $expected_val, $db_options[ $opt_name ] ); + } + + /** + * Test that options can be saved for the first time. + */ + public function testDeleteAndSave() { + $opts = new WP_Auth0_Options(); + + // Make sure we do not have options saved. + delete_option( $opts->get_options_name() ); + $this->assertFalse( get_option( $opts->get_options_name() ) ); + + // Save and make sure it has been saved. + $opts->save(); + $db_options = get_option( $opts->get_options_name() ); + $this->assertCount( self::DEFAULT_OPTIONS_COUNT, $db_options ); + + // Now delete again and make sure it's gone. + $this->assertTrue( $opts->delete() ); + $this->assertFalse( get_option( $opts->get_options_name() ) ); } } diff --git a/tests/traits/domDocumentHelpers.php b/tests/traits/domDocumentHelpers.php index 5e139097..dfb5d38c 100644 --- a/tests/traits/domDocumentHelpers.php +++ b/tests/traits/domDocumentHelpers.php @@ -1,4 +1,10 @@