@@ -88,13 +88,19 @@ static public function hooks( CAS $obj ) {
88
88
* @param Admin $admin
89
89
*/
90
90
public function __construct ( Admin $ admin ) {
91
-
92
91
$ options = $ admin ->getOptions ();
93
- if ( empty ( $ options ['server_hostname ' ] ) ) {
92
+
93
+ $ port = (int ) $ options ['server_port ' ];
94
+
95
+ if ( empty ( $ options ['server_hostname ' ] ) || $ port !== 443 ) {
94
96
if ( 'pb_cas_admin ' !== @$ _REQUEST ['page ' ] ) { // @codingStandardsIgnoreLine
97
+ $ message = $ port === 443
98
+ ? __ ( 'CAS is not configured. ' , 'pressbooks-cas-sso ' )
99
+ : __ ( 'CAS is not configured. Make sure the service runs on secure protocols. ' , 'pressbooks-cas-sso ' );
100
+
95
101
add_action (
96
- 'network_admin_notices ' , function () {
97
- echo '<div id="message" role="alert" class="error fade"><p> ' . __ ( ' CAS is not configured. ' , ' pressbooks-cas-sso ' ) . '</p></div> ' ;
102
+ 'network_admin_notices ' , function () use ( $ message ) {
103
+ echo '<div id="message" role="alert" class="error fade"><p> ' . $ message . '</p></div> ' ;
98
104
}
99
105
);
100
106
}
@@ -112,12 +118,17 @@ public function __construct( Admin $admin ) {
112
118
default :
113
119
$ server_version = defined ( 'CAS_VERSION_2_0 ' ) ? CAS_VERSION_2_0 : '2.0 ' ;
114
120
}
121
+
122
+ $ host = $ options ['server_hostname ' ];
123
+ $ path = untrailingslashit ( $ options ['server_path ' ] );
124
+
115
125
if ( ! phpCAS::isInitialized () ) {
116
126
phpCAS::client (
117
127
$ server_version ,
118
- $ options ['server_hostname ' ],
119
- intval ( $ options ['server_port ' ] ),
120
- untrailingslashit ( $ options ['server_path ' ] )
128
+ $ host ,
129
+ $ port ,
130
+ $ path ,
131
+ "https:// {$ host }: $ {port}{$ path }"
121
132
);
122
133
}
123
134
0 commit comments