Skip to content

Commit eb64d48

Browse files
Merge pull request #102 from pressbooks/dependabot/composer/apereo/phpcas-1.6.0
Bump apereo/phpcas from 1.5.0 to 1.6.0
2 parents 3b5c3b4 + f401670 commit eb64d48

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/class-cas.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,19 @@ static public function hooks( CAS $obj ) {
8888
* @param Admin $admin
8989
*/
9090
public function __construct( Admin $admin ) {
91-
9291
$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 ) {
9496
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+
95101
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>';
98104
}
99105
);
100106
}
@@ -112,12 +118,17 @@ public function __construct( Admin $admin ) {
112118
default:
113119
$server_version = defined( 'CAS_VERSION_2_0' ) ? CAS_VERSION_2_0 : '2.0';
114120
}
121+
122+
$host = $options['server_hostname'];
123+
$path = untrailingslashit( $options['server_path'] );
124+
115125
if ( ! phpCAS::isInitialized() ) {
116126
phpCAS::client(
117127
$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}"
121132
);
122133
}
123134

0 commit comments

Comments
 (0)