allow Jwt Bear token to be passed as url parameter

This commit is contained in:
2019-03-31 00:15:05 +00:00
parent 7a305a3df9
commit 1aa4326187

View File

@ -20,6 +20,7 @@ using OAuth.AspNet.AuthServer;
using OAuth.AspNet.Tokens;
namespace Yavsc {
using System.Threading.Tasks;
using Auth;
using Extensions;
using Helpers.Google;
@ -101,6 +102,19 @@ namespace Yavsc {
options.SecurityTokenValidators.Add (new TicketDataFormatTokenValidator (
ProtectionProvider
));
options.Events = new JwtBearerEvents
{
OnReceivingToken = async context =>
{
var signalRTokenHeader = context.Request.Query["signalRTokenHeader"];
if (!string.IsNullOrEmpty(signalRTokenHeader) &&
(context.HttpContext.WebSockets.IsWebSocketRequest || context.Request.Headers["Accept"] == "text/event-stream"))
{
context.Token = context.Request.Query["signalRTokenHeader"];
}
}
};
}
);