Skip to content
Merged
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
10 changes: 10 additions & 0 deletions app/Models/OAuth2/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
#[ORM\Cache('NONSTRICT_READ_WRITE')] // Class Client
class Client extends BaseEntity implements IClient
{
private static array $allowed_otp_client_types = [
IClient::ApplicationType_JS_Client,
IClient::ApplicationType_Native,
IClient::ApplicationType_Web_App
];

/**
* @var string
*/
Expand Down Expand Up @@ -1667,6 +1673,10 @@ public function isPasswordlessEnabled(): bool

public function enablePasswordless(): void
{
$app_type = $this->getApplicationType();
if (!in_array($this->getApplicationType(), self::$allowed_otp_client_types)) {
throw new ValidationException("This application type ($app_type) does not allow passwordless.");
}
$this->otp_enabled = true;
$this->otp_length = intval(Config::get("otp.length"));
$this->otp_lifetime = intval(Config::get("otp.lifetime"));
Expand Down
9 changes: 6 additions & 3 deletions resources/js/oauth2/profile/edit_client/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ const normalizeEntity = (entity, entitySection) => {
normEntity.pkce_enabled = entity.pkce_enabled ? 1 : 0;
normEntity = normalizePKCEDependencies(normEntity);
}
normEntity.otp_enabled = entity.otp_enabled ? 1 : 0;
normEntity.otp_length = entity.otp_length;
normEntity.otp_lifetime = entity.otp_lifetime;
normEntity.otp_enabled = 0;
if (entity.otp_enabled) {
normEntity.otp_enabled = 1;
normEntity.otp_length = entity.otp_length;
normEntity.otp_lifetime = entity.otp_lifetime;
}

if ([appTypes.JSClient, appTypes.Native, appTypes.WebApp].includes(entity.application_type))
normEntity.max_allowed_user_sessions = entity.max_allowed_user_sessions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ const SecuritySettingsPanel = (
onChange={handleUsePKCEChange}
/>
}
<CheckboxFormControl
id="otp_enabled"
title="Use Passwordless?"
tooltip="Use Passwordless Authentication"
value={formik.values.otp_enabled}
onChange={formik.handleChange}
/>
{
[appTypes.JSClient, appTypes.Native, appTypes.WebApp].includes(application_type) &&
<CheckboxFormControl
id="otp_enabled"
title="Use Passwordless?"
tooltip="Use Passwordless Authentication"
value={formik.values.otp_enabled}
onChange={formik.handleChange}
/>
}
{
formik.values.otp_enabled &&
<>
Expand Down
Loading