Skip to content

Commit

Permalink
rename cookie authentication method
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-nitehawk committed Feb 28, 2024
1 parent df15140 commit eb87e88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 69 deletions.
24 changes: 5 additions & 19 deletions Src/Security/AuthExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ public static class AuthExtensions
return services;
}

/// <summary>
/// configure and enable jwt bearer authentication
/// </summary>
/// <param name="tokenSigningKey">the secret key to use for verifying the jwt tokens</param>
/// <param name="tokenSigningStyle">specify the token signing style</param>
/// <param name="tokenValidation">configuration action to specify additional token validation parameters</param>
/// <param name="bearerEvents">configuration action to specify custom jwt bearer events</param>
[Obsolete("Use AddAuthenticationJwtBearer() method.")]
public static IServiceCollection AddJWTBearerAuth(this IServiceCollection services,
string tokenSigningKey,
Expand All @@ -110,21 +103,10 @@ public static class AuthExtensions
});
}

/// <summary>
/// configure and enable jwt bearer authentication
/// </summary>
/// <param name="tokenSigningKey">the secret key to use for verifying the jwt tokens</param>
/// <param name="jwtOptions">configuration action to specify options for the authentication scheme</param>
[Obsolete("Use AddAuthenticationJwtBearer() method.")]
public static IServiceCollection AddJWTBearerAuth(this IServiceCollection services, string tokenSigningKey, Action<JwtBearerOptions> jwtOptions)
=> AddJWTBearerAuth(services, tokenSigningKey, TokenSigningStyle.Asymmetric, jwtOptions);

/// <summary>
/// configure and enable jwt bearer authentication
/// </summary>
/// <param name="tokenSigningKey">the secret key to use for verifying the jwt tokens</param>
/// <param name="tokenSigningStyle">specify the token signing style</param>
/// <param name="jwtOptions">configuration action to specify options for the authentication scheme</param>
[Obsolete("Use AddAuthenticationJwtBearer() method.")]
public static IServiceCollection AddJWTBearerAuth(this IServiceCollection services,
string tokenSigningKey,
Expand All @@ -146,7 +128,7 @@ public static IServiceCollection AddJWTBearerAuth(this IServiceCollection servic
/// </summary>
/// <param name="validFor">specify how long the created cookie is valid for with a <see cref="TimeSpan" /></param>
/// <param name="options">optional action for configuring cookie authentication options</param>
public static IServiceCollection AddCookieAuth(this IServiceCollection services, TimeSpan validFor, Action<CookieAuthenticationOptions>? options = null)
public static IServiceCollection AddAuthenticationCookie(this IServiceCollection services, TimeSpan validFor, Action<CookieAuthenticationOptions>? options = null)
{
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(
Expand All @@ -162,6 +144,10 @@ public static IServiceCollection AddCookieAuth(this IServiceCollection services,
return services;
}

[Obsolete("Use AddAuthenticationCookie() method.")]
public static IServiceCollection AddCookieAuth(this IServiceCollection services, TimeSpan validFor, Action<CookieAuthenticationOptions>? options = null)
=> AddAuthenticationCookie(services, validFor, options);

/// <summary>
/// returns true of the current user principal has a given permission code.
/// </summary>
Expand Down
50 changes: 0 additions & 50 deletions Src/Security/JWTBearer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Text;
#if NET8_0_OR_GREATER
using Microsoft.IdentityModel.JsonWebTokens;

#else
using System.IdentityModel.Tokens.Jwt;
#endif
Expand Down Expand Up @@ -86,14 +85,6 @@ static SigningCredentials GetSigningCredentials(JwtCreationOptions opts)
/// </summary>
public static class JWTBearer
{
/// <summary>
/// generate a jwt token with the supplied parameters
/// </summary>
/// <param name="signingKey">the secret key to use for signing the tokens</param>
/// <param name="expireAt">the expiry date</param>
/// <param name="permissions">one or more permissions to assign to the user principal</param>
/// <param name="roles">one or more roles to assign the user principal</param>
/// <param name="claims">one or more claims to assign to the user principal</param>
[Obsolete("Use JwtBearer.CreateToken() method.")]
public static string CreateToken(string signingKey,
DateTime? expireAt = null,
Expand All @@ -102,16 +93,6 @@ public static class JWTBearer
params (string claimType, string claimValue)[] claims)
=> CreateToken(signingKey, expireAt, permissions, roles, claims.Select(c => new Claim(c.claimType, c.claimValue)));

/// <summary>
/// generate a jwt token with the supplied parameters
/// </summary>
/// <param name="signingKey">the secret key to use for signing the tokens</param>
/// <param name="issuer">the issue</param>
/// <param name="audience">the audience</param>
/// <param name="expireAt">the expiry date</param>
/// <param name="permissions">one or more permissions to assign to the user principal</param>
/// <param name="roles">one or more roles to assign the user principal</param>
/// <param name="claims">one or more claims to assign to the user principal</param>
[Obsolete("Use JwtBearer.CreateToken() method.")]
public static string CreateToken(string signingKey,
string? issuer,
Expand All @@ -122,17 +103,6 @@ public static class JWTBearer
params (string claimType, string claimValue)[] claims)
=> CreateToken(signingKey, expireAt, permissions, roles, claims.Select(c => new Claim(c.claimType, c.claimValue)), issuer, audience);

/// <summary>
/// generate a jwt token with the supplied parameters and token signing style
/// </summary>
/// <param name="signingKey">the secret key to use for signing the tokens</param>
/// <param name="signingStyle">the signing style to use (Symmertic or Asymmetric)</param>
/// <param name="issuer">the issue</param>
/// <param name="audience">the audience</param>
/// <param name="expireAt">the expiry date</param>
/// <param name="permissions">one or more permissions to assign to the user principal</param>
/// <param name="roles">one or more roles to assign the user principal</param>
/// <param name="claims">one or more claims to assign to the user principal</param>
[Obsolete("Use JwtBearer.CreateToken() method.")]
public static string CreateToken(string signingKey,
TokenSigningStyle signingStyle,
Expand All @@ -144,15 +114,6 @@ public static class JWTBearer
params (string claimType, string claimValue)[] claims)
=> CreateToken(signingKey, expireAt, permissions, roles, claims.Select(c => new Claim(c.claimType, c.claimValue)), issuer, audience, signingStyle);

/// <summary>
/// generate a jwt token with the supplied parameters
/// </summary>
/// <param name="signingKey">the secret key to use for signing the tokens</param>
/// <param name="privileges">an action to specify the privileges of the user</param>
/// <param name="issuer">the issuer</param>
/// <param name="audience">the audience</param>
/// <param name="expireAt">the expiry date</param>
/// <param name="signingStyle">the signing style to use (Symmertic or Asymmetric)</param>
[Obsolete("Use JwtBearer.CreateToken() method.")]
public static string CreateToken(string signingKey,
Action<UserPrivileges> privileges,
Expand All @@ -167,17 +128,6 @@ public static class JWTBearer
return CreateToken(signingKey, expireAt, privs.Permissions, privs.Roles, privs.Claims, issuer, audience, signingStyle);
}

/// <summary>
/// generate a jwt token with the supplied parameters
/// </summary>
/// <param name="signingKey">the secret key to use for signing the tokens</param>
/// <param name="expireAt">the expiry date</param>
/// <param name="permissions">one or more permissions to assign to the user principal</param>
/// <param name="roles">one or more roles to assign the user principal</param>
/// <param name="claims">one or more claims to assign to the user principal</param>
/// <param name="issuer">the issuer</param>
/// <param name="audience">the audience</param>
/// <param name="signingStyle">the signing style to use (Symmetric or Asymmetric)</param>
[Obsolete("Use JwtBearer.CreateToken() method.")]
public static string CreateToken(string signingKey,
DateTime? expireAt = null,
Expand Down

0 comments on commit eb87e88

Please sign in to comment.