Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
terencefan committed Oct 16, 2024
1 parent 72dd4da commit cebd25b
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions src/Microsoft.Azure.SignalR.Common/Auth/AccessKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,41 @@
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Azure.SignalR
namespace Microsoft.Azure.SignalR;

internal class AccessKey
{
internal class AccessKey
public string Id => Key?.Item1;

public string Value => Key?.Item2;

public Uri Endpoint { get; }

protected Tuple<string, string> Key { get; set; }

public AccessKey(string uri, string key) : this(new Uri(uri))
{
Key = new Tuple<string, string>(key.GetHashCode().ToString(), key);
}

public AccessKey(Uri uri, string key) : this(uri)
{
Key = new Tuple<string, string>(key.GetHashCode().ToString(), key);
}

protected AccessKey(Uri uri)
{
Endpoint = uri;
}

public virtual Task<string> GenerateAccessTokenAsync(
string audience,
IEnumerable<Claim> claims,
TimeSpan lifetime,
AccessTokenAlgorithm algorithm,
CancellationToken ctoken = default)
{
public string Id => Key?.Item1;

public string Value => Key?.Item2;

public Uri Endpoint { get; }

protected Tuple<string, string> Key { get; set; }

public AccessKey(string uri, string key) : this(new Uri(uri))
{
Key = new Tuple<string, string>(key.GetHashCode().ToString(), key);
}

public AccessKey(Uri uri, string key) : this(uri)
{
Key = new Tuple<string, string>(key.GetHashCode().ToString(), key);
}

protected AccessKey(Uri uri)
{
Endpoint = uri;
}

public virtual Task<string> GenerateAccessTokenAsync(
string audience,
IEnumerable<Claim> claims,
TimeSpan lifetime,
AccessTokenAlgorithm algorithm,
CancellationToken ctoken = default)
{
var token = AuthUtility.GenerateAccessToken(this, audience, claims, lifetime, algorithm);
return Task.FromResult(token);
}
var token = AuthUtility.GenerateAccessToken(this, audience, claims, lifetime, algorithm);
return Task.FromResult(token);
}
}

0 comments on commit cebd25b

Please sign in to comment.