mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 01:58:07 +00:00
Fix FLEXIAPI-430 Handle empty string in JWT_SIP_IDENTIFIER and fallback to sip_identity
This commit is contained in:
parent
06dc357524
commit
f883c3cee7
2 changed files with 18 additions and 2 deletions
|
|
@ -76,9 +76,11 @@ class AuthenticateJWT
|
|||
}
|
||||
|
||||
$account = null;
|
||||
$identifierKey = config('services.jwt.sip_identifier');
|
||||
if ($identifierKey == '') $identifierKey = 'sip_identity';
|
||||
|
||||
if ($token->claims()->has(config('services.jwt.sip_identifier'))) {
|
||||
list($username, $domain) = parseSIP($token->claims()->get(config('services.jwt.sip_identifier')));
|
||||
if ($token->claims()->has($identifierKey)) {
|
||||
list($username, $domain) = parseSIP($token->claims()->get($identifierKey));
|
||||
|
||||
$account = Account::withoutGlobalScopes()
|
||||
->where('username', $username)
|
||||
|
|
|
|||
|
|
@ -93,6 +93,20 @@ class AccountJWTAuthenticationTest extends TestCase
|
|||
|
||||
$this->checkToken($token);
|
||||
|
||||
// Handle JWT_SIP_IDENTIFIER=
|
||||
config()->set('services.jwt.sip_identifier', '');
|
||||
|
||||
$token = (new JwtFacade(null, $clock))->issue(
|
||||
new Sha256(),
|
||||
InMemory::plainText($this->serverPrivateKeyPem),
|
||||
static fn (
|
||||
Builder $builder,
|
||||
DateTimeImmutable $issuedAt
|
||||
): Builder => $builder->withClaim('sip_identity', 'sip:' . $password->account->username . '@' . $password->account->domain)
|
||||
);
|
||||
|
||||
$this->checkToken($token);
|
||||
|
||||
// Custom SIP identifier
|
||||
$otherIdentifier = 'sip_other_identifier';
|
||||
config()->set('services.jwt.sip_identifier', $otherIdentifier);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue