Skip to content

Add require_prompt as an option #492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion includes/openid-connect-generic-client-wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public function get_authentication_url( $atts = array() ) {
'redirect_uri' => $this->client->get_redirect_uri(),
'redirect_to' => $this->get_redirect_to(),
'acr_values' => $this->settings->acr_values,
'prompt' => $this->settings->require_prompt ? 'login' : '',
),
$atts,
'openid_connect_generic_auth_url'
Expand All @@ -230,6 +231,9 @@ public function get_authentication_url( $atts = array() ) {
if ( ! empty( $atts['acr_values'] ) ) {
$url_format .= '&acr_values=%7$s';
}
if ( ! empty( $atts['prompt'] ) ) {
$url_format .= '&prompt=%8$s';
}

$url = sprintf(
$url_format,
Expand All @@ -239,7 +243,8 @@ public function get_authentication_url( $atts = array() ) {
rawurlencode( $atts['client_id'] ),
$this->client->new_state( $atts['redirect_to'] ),
rawurlencode( $atts['redirect_uri'] ),
rawurlencode( $atts['acr_values'] )
rawurlencode( $atts['acr_values'] ),
rawurlencode( $atts['prompt'] )
);

$url = apply_filters( 'openid-connect-generic-auth-url', $url );
Expand Down
1 change: 1 addition & 0 deletions includes/openid-connect-generic-option-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @property string $email_format The key(s) in the user claim array to formulate the user's email address.
* @property string $displayname_format The key(s) in the user claim array to formulate the user's display name.
* @property bool $identify_with_username The flag which indicates how the user's identity will be determined.
* @property bool $require_prompt The flag which tells the IdP to show the login prompt every time.
* @property int $state_time_limit The valid time limit of the state, in seconds. Defaults to 180 seconds.
*
* Plugin Settings:
Expand Down
6 changes: 6 additions & 0 deletions includes/openid-connect-generic-settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ private function get_settings_fields() {
'type' => 'checkbox',
'section' => 'client_settings',
),
'require_prompt' => array(
'title' => __( 'Require Prompt', 'daggerhart-openid-connect-generic' ),
'description' => __( 'If checked, the IdP will always show the login prompt, regardless of whether the user used Remember Me.', 'daggerhart-openid-connect-generic' ),
'type' => 'checkbox',
'section' => 'client_settings',
),
'state_time_limit' => array(
'title' => __( 'State time limit', 'daggerhart-openid-connect-generic' ),
'description' => __( 'State valid time in seconds. Defaults to 180', 'daggerhart-openid-connect-generic' ),
Expand Down
1 change: 1 addition & 0 deletions openid-connect-generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public static function bootstrap() {
'email_format' => '{email}',
'displayname_format' => '',
'identify_with_username' => false,
'require_prompt' => false,

// Plugin settings.
'enforce_privacy' => defined( 'OIDC_ENFORCE_PRIVACY' ) ? intval( OIDC_ENFORCE_PRIVACY ) : 0,
Expand Down