Add Entra group restriction, button-only mode and detailed README

Groups: a Graph-backed picker on the Security tab (search by name or
paste object IDs) stores allowed group IDs. During sign-in membership is
read from the ID token's groups claim when present, otherwise verified
through Microsoft Graph checkMemberGroups (transitive). Verification
failures refuse the sign-in.

Button-only mode: hides the password form and the lost-password link
and rejects password sign-ins on wp-login.php via the authenticate
filter. A generated, rate-limited fallback key re-enables the form for
30 minutes per browser; M365_LOGIN_DISABLE_BUTTON_ONLY switches the
mode off from wp-config.php.

Also: new German-language README with sequence diagram, settings
reference, troubleshooting and hook examples; readme.txt external
services section now covers Microsoft Graph; translations updated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJxAHYdMfKPoN4koRc4Ci2
This commit is contained in:
friloo 2026-09-22 14:30:53 +00:00
parent 1517e7e3bc
commit 1202283eda
No known key found for this signature in database
20 changed files with 2241 additions and 517 deletions

View file

@ -28,6 +28,7 @@ class M365_Login_Button {
$this->settings = $settings;
add_action( 'login_enqueue_scripts', array( $this, 'enqueue' ) );
add_filter( 'login_body_class', array( $this, 'body_class' ) );
add_filter( 'login_message', array( $this, 'render_above' ), 20 );
add_action( 'login_footer', array( $this, 'render_below' ) );
add_shortcode( 'm365_login_button', array( $this, 'shortcode' ) );
@ -57,6 +58,28 @@ class M365_Login_Button {
return (bool) apply_filters( 'm365_login_show_button', true );
}
/**
* Whether the password form is hidden for this request.
*
* @return bool
*/
private function form_hidden() {
return $this->should_render() && $this->settings->button_only() && ! M365_Login::instance()->auth->fallback_active();
}
/**
* Adds a body class while the password form is hidden.
*
* @param string[] $classes Body classes.
* @return string[]
*/
public function body_class( $classes ) {
if ( $this->form_hidden() ) {
$classes[] = 'm365-button-only';
}
return $classes;
}
/**
* Enqueues login styles and the small positioning script.
*/
@ -140,7 +163,7 @@ class M365_Login_Button {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- passed through to the flow, validated there.
$redirect_to = isset( $_REQUEST['redirect_to'] ) ? esc_url_raw( wp_unslash( $_REQUEST['redirect_to'] ) ) : '';
$divider = (string) $this->settings->get( 'divider_text' );
$divider = $this->form_hidden() ? '' : (string) $this->settings->get( 'divider_text' );
$divider = '' === trim( $divider ) ? '' : '<div class="m365-login__divider" aria-hidden="true"><span>' . esc_html( $divider ) . '</span></div>';
$html = '<div class="m365-login m365-login--' . esc_attr( $position ) . '" id="m365-login-block">';