owin

GetExternalLoginInfoAsync always return null when i trying login using Facebook or Google

筅森魡賤 提交于 2019-12-05 04:56:28
I have a problem with OWIN Authentication. I always receive null value from GetExternalLoginInfoAsync() when I trying log in using Facebook or Google. BUT there is some mystical case.. When I open Fiddler. I get correct data using this method. I can't get the reason var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); Thanks in advance!! I have solved my problem by adding this code context.RequestContext.HttpContext.Response.SuppressFormsAuthenticationRedirect = true; in the class: private class ChallengeResult : HttpUnauthorizedResult { public ChallengeResult(string

Web Api 2 HttpContext or HttpActionContext

ぃ、小莉子 提交于 2019-12-05 04:38:26
What is the difference between the following two ways of accessing the principle via an AuthorizeAttribute implementation? Using HttpContext : protected override bool IsAuthorized(HttpActionContext actionContext) { return HttpContext.Current.User.IsInRole("DemoRole"); } Using HttpActionContext : protected override bool IsAuthorized(HttpActionContext actionContext) { return actionContext.RequestContext.Principal.IsInRole("DemoRole"); } 来源: https://stackoverflow.com/questions/28235979/web-api-2-httpcontext-or-httpactioncontext

Owin self-host - Failed to listen on prefix 'http://localhost:12345/' because it conflicts with an existing registration on the machine

佐手、 提交于 2019-12-05 04:12:36
I'm trying to self-host a simple WebAPI: public class AccountViewApplication { protected IDisposable WebApplication; public void Start() { WebApplication = WebApp.Start<WebPipeline>("http://myhost.mymachine.me:12345"); new AccountViewApplication().Start(); } public void Stop() { WebApplication.Dispose(); } } The first time I run this, it starts to listen just fine, but the next time that I try - I get this: Failed to listen on prefix ' http://myhost.mymachine.me:12345/ ' because it conflicts with an existing registration on the machine What can I do to make it listen every time, and not

ASP.NET MVC tries to load older version of Owin assembly

偶尔善良 提交于 2019-12-05 03:32:23
As a bit of context, I'm developing an ASP.NET MVC 5 application that uses OAuth-based authentication via Microsoft's OWIN implementation, for Facebook and Google only at this stage. Currently (as of v3.0.0, git-commit 4932c2f), the FacebookAuthenticationOptions and GoogleOAuth2AuthenticationOptions don't provide any property to force Facebook nor Google respectively to reauthenticate users (via appending the appropriate query string parameters) when signing in. Initially, I set out to override the following classes: FacebookAuthenticationOptions GoogleOAuth2AuthenticationOptions

Signalr assembly loading issue OWIN

荒凉一梦 提交于 2019-12-05 03:22:16
I'm getting this error when attempting to load classes in the Microsoft.AspNet.SignalR.Owin assembly. The exception is thrown after execution leaves the Configuration method in startup.cs . I've registered a Global Exception Handler to try and catch the exception but it is not being caught. public async override Task HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken) { var exception = context.Exception; const string genericErrorMessage = "An unexpected error occured"; var response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, new { Message

Add claims with Owin Middleware

旧巷老猫 提交于 2019-12-05 03:19:07
Is it possible with an Owin Middleware implementation to add claims prior to the execution of a Web API controller? Created an OwinMiddleware implementation and added an identity: var id = new ClaimsIdentity(); id.AddClaim(new Claim("Whatever", "is possible")); context.Authentication.User.AddIdentity(id); await Next.Invoke(context); However, even this Invoke method call the identities are not updated (just the internal claims array). And the controller when executed of course never gets the new dummy claim. Ideas? You may find useful inheriting from Authorizate Attribute and extending it to

Logging out from facebook when using MVC 5 OWIN

自闭症网瘾萝莉.ら 提交于 2019-12-05 03:16:02
问题 I have an MVC 5 web app that has facebook authentication set up and working nicely. User clicks "Facebook" on the login page, signs in to Facebook and that authenticates with our web site. If the user logs out, the call to AuthenticationManager.SignOut() logs out of the web site correctly, but if the user then goes back to the login page and clicks "Facebook" again they are immediately signed in without having to sign in to facebook. So my question is, how do I configure MVC 5 OWIN facebook

How to get user's information on WebAPI controller after authenticated with IdentityServer?

依然范特西╮ 提交于 2019-12-05 03:08:46
问题 I cannot get user's information on WebAPI controller after my client app authenticates with IdentityServer3 successfully. Below are the steps: "Login With Profile and Access Token" successfully from JavaScript Implicit Client app I see user's data on "ID Token Contents" panel I do "Call service" to my WebAPI service, I see many claims in ClaimsPrincipal but cannot get values such as email, roles displayed on client side. Below are code & responses. Could anyone provide me some helps how to

Creating Owin Auth Provider that Exchanges a Custom Token for a .Net Auth Cookie

笑着哭i 提交于 2019-12-05 02:34:34
问题 I am trying to create an SSO like solution between 2 .Net applications .Net app 1 has a custom token generator and endpoints to validate tokens that returns user information. .Net application 2 is protected using Owin and was a typical standalone app and a user would directly login using a password and username. I created (based on Passion for Coding Blog and Github) a custom Owin provider that would look for a token either in a Authorization header or as a query parameter from a link that a

How to revoke the RefreshToken and invalidate the AccessToken at the same time in Oauth2

你离开我真会死。 提交于 2019-12-05 02:12:48
问题 I'm developing the authentication flow of a single page application (AngularJS + .Net MVC Json Rest API) using Owin Oauth2 (Authorization and Resource servers are the same). I've chosen the Bearer Token route over the traditional cookie+session because I would like to stay stateless and also because the same Api will be used by a mobile app where token has less problem than the cookie. This is the simplified flow: User submits Username/Password to the server (POST over Https to the