Skip to content

Commit

Permalink
Get rid of dependency on Katana's AuthenticationTicket
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo Valipour committed Oct 22, 2015
1 parent cee7647 commit cbd0a61
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ public AuthenticationSessionStoreWrapper(IAuthenticationSessionStoreProvider pro

public Task<string> StoreAsync(AuthenticationTicket ticket)
{
return this.provider.StoreAsync(ticket);
return this.provider.StoreAsync(new AuthenticationTicketModel(ticket));
}

public Task RenewAsync(string key, AuthenticationTicket ticket)
{
return this.provider.RenewAsync(key, ticket);
return this.provider.RenewAsync(key, new AuthenticationTicketModel(ticket));
}

public Task<AuthenticationTicket> RetrieveAsync(string key)
public async Task<AuthenticationTicket> RetrieveAsync(string key)
{
return this.provider.RetrieveAsync(key);
var ticket = await this.provider.RetrieveAsync(key);
return ticket == null ? null : ticket.ToAuthenticationTicket();
}

public Task RemoveAsync(string key)
Expand Down
42 changes: 42 additions & 0 deletions source/Core/Configuration/AuthenticationTicketModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace IdentityServer3.Core.Configuration
{
using System.Collections.Generic;
using System.Security.Claims;

using Microsoft.Owin.Security;

/// <summary>
/// A model class represending an authentication ticket
/// </summary>
public class AuthenticationTicketModel
{
/// <summary>
/// Instantiates an instance of authentication ticket
/// </summary>
public AuthenticationTicketModel(ClaimsIdentity identity, IDictionary<string, string> properties)
{
this.Identity = identity;
this.Properties = properties;
}

internal AuthenticationTicketModel(AuthenticationTicket ticket)
: this(ticket.Identity, ticket.Properties.Dictionary)
{
}

/// <summary>
/// The claims identity of the authentication ticket
/// </summary>
public ClaimsIdentity Identity { get; private set; }

/// <summary>
/// Authentication ticket properties
/// </summary>
public IDictionary<string, string> Properties { get; private set; }

internal AuthenticationTicket ToAuthenticationTicket()
{
return new AuthenticationTicket(this.Identity, new AuthenticationProperties(this.Properties));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ namespace IdentityServer3.Core.Configuration
{
using System.Threading.Tasks;

using Microsoft.Owin.Security;

/// <summary>
/// Providers the authentication session stores functions
/// </summary>
Expand All @@ -22,20 +20,20 @@ public interface IAuthenticationSessionStoreProvider
/// <param name="key">Session key</param>
/// <param name="identity">Authentication ticket</param>
/// <returns>Async task</returns>
Task RenewAsync(string key, AuthenticationTicket identity);
Task RenewAsync(string key, AuthenticationTicketModel identity);

/// <summary>
/// Provides the retrieve functionality of session store
/// </summary>
/// <param name="key">Session key</param>
/// <returns>Async task with authentication ticket result</returns>
Task<AuthenticationTicket> RetrieveAsync(string key);
Task<AuthenticationTicketModel> RetrieveAsync(string key);

/// <summary>
/// Provides the store functionality of session store
/// </summary>
/// <param name="ticket">Authentication ticket</param>
/// <returns>Async task with session key</returns>
Task<string> StoreAsync(AuthenticationTicket ticket);
Task<string> StoreAsync(AuthenticationTicketModel ticket);
}
}
1 change: 1 addition & 0 deletions source/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<Compile Include="Configuration\AppBuilderExtensions\ConfigureRequestIdExtension.cs" />
<Compile Include="Configuration\AppBuilderExtensions\ConfigureHttpLoggingExtension.cs" />
<Compile Include="Configuration\AuthenticationSessionStoreWrapper.cs" />
<Compile Include="Configuration\AuthenticationTicketModel.cs" />
<Compile Include="Configuration\CookieSecureMode.cs" />
<Compile Include="Configuration\EventsOptions.cs" />
<Compile Include="Configuration\InputLengthRestrictions.cs" />
Expand Down

0 comments on commit cbd0a61

Please sign in to comment.