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: 3 additions & 7 deletions src/IdentityServer/Services/Default/DefaultUserSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class DefaultUserSession : IUserSession
/// The name of the check session cookie.
/// </value>
protected string CheckSessionCookieName => Options.Authentication.CheckSessionCookieName;

/// <summary>
/// Gets the domain of the check session cookie.
/// </summary>
Expand Down Expand Up @@ -310,12 +310,8 @@ public virtual async Task AddClientIdAsync(string clientId)
await AuthenticateAsync();
if (Properties != null)
{
var clientIds = Properties.GetClientList();
if (!clientIds.Contains(clientId))
{
Properties.AddClientId(clientId);
await UpdateSessionCookie();
}
Properties.AddClientId(clientId);
await UpdateSessionCookie();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,19 @@ public async Task adding_clients_should_be_able_to_read_clients()
var clients = await _subject.GetClientListAsync();
clients.Should().Contain(new string[] { "client2", "client1" });
}

[Fact]
public async Task adding_existing_client_should_not_add_new_client()
{
_mockAuthenticationHandler.Result = AuthenticateResult.Success(new AuthenticationTicket(_user, _props, "scheme"));

const string clientId = "client";
await _subject.AddClientIdAsync(clientId);
await _subject.AddClientIdAsync(clientId);

var clients = await _subject.GetClientListAsync();

_props.Items.Count.Should().Be(1);
clients.Should().BeEquivalentTo([clientId]);
}
}