internal static HttpServer Create(Func<IResponseMessage, string> normalizationCallback = null, Func<IRequestMessage, string, bool> verificationCallback = null) { var configuration = new HttpConfiguration(); configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); var options = new Options() { ClockSkewSeconds = 60, LocalTimeOffsetMillis = 0, CredentialsCallback = (id) => Credentials.FirstOrDefault(c => c.Id == id), NormalizationCallback = normalizationCallback, VerificationCallback = verificationCallback, ResponsePayloadHashabilityCallback = (req) => true }; var hawkHandler = new HawkAuthenticationHandler(options); configuration.MessageHandlers.Add(hawkHandler); return new HttpServer(configuration); }
internal static HttpServer Create(Func<HttpResponseMessage, string> normalizationCallback = null, Func<HttpRequestMessage, string, bool> verificationCallback = null) { var configuration = new HttpConfiguration(); configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); Func<string, Credential> credentialsCallback = (id) => Credentials.FirstOrDefault(c => c.Id == id); var hawkHandler = new HawkAuthenticationHandler(credentialsCallback, normalizationCallback, verificationCallback); configuration.MessageHandlers.Add(hawkHandler); return new HttpServer(configuration); }