Open Closed

windows Authentication #6204


User avatar
0
s.alshammari.c created
  • ABP Framework version: v7
  • UI Type: Angular
  • Database System: EF Core (SQL Server)

how to implement windows Authentication in ABP suite


22 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We have a sample pull reqeust.

    https://github.com/abpframework/abp/pull/8419

  • User Avatar
    0
    s.alshammari.c created

    I added context.Services.Configure<IISServerOptions>(iis => { iis.AuthenticationDisplayName = "Windows"; iis.AutomaticAuthentication = false; });

    but still, this button is not showing

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You also need to configure the Windows authentication.

    Services.AddAuthentication

    https://learn.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth

  • User Avatar
    0
    s.alshammari.c created

    I want automatic login is that possible or do I must press windows button and then register by email ?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can override the public virtual async Task<IActionResult> OnGetAsync() of the Login page.

    This is the same as you click the Windows button.

    public override async Task<IActionResult> OnGetAsync()
    {
        var redirectUrl = Url.Page("./Login", pageHandler: "ExternalLoginCallback", values: new { ReturnUrl, ReturnUrlHash, });
        var properties = SignInManager.ConfigureExternalAuthenticationProperties("Windows", redirectUrl);
        properties.Items["scheme"] = "Windows";
    
        return await Task.FromResult(Challenge(properties, provider));
    }
    

    See the sign in code

    https://github.com/search?q=repo%3Aabpframework%2Fabp%20ProcessWindowsLoginAsync&type=code

  • User Avatar
    0
    s.alshammari.c created

    can I send you my code ? provide me your email please

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can share a simple project. liming.ma@volosoft.com

  • User Avatar
    0
    s.alshammari.c created

    its a fresh project can you just implement it and share it with me please

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    ok, What's your email?

    I will use OpenIddict as auth server.

  • User Avatar
    0
    s.alshammari.c created

    hi saudalshammari2030@gmail.com

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Sent. The key code is src\BookStore.Web\MyLoginModel.cs

  • User Avatar
    0
    s.alshammari.c created

    I didn't receive anything on my email yet (already checked spam etc..). can you make sure that its sent please? I sent you an email reply to it with the project please

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I sent it again.

  • User Avatar
    0
    s.alshammari.c created

    still I have to register by email , what I need is to integrate it with the active directory so once someone open the website it automatically log in

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can debug to check this, and make sure the email claim exists in it.

  • User Avatar
    0
    s.alshammari.c created

    no email claim exist , I only got the name. should I add this id.AddClaim(new Claim(ClaimTypes.Email,result.Principal.FindFirstValue(ClaimTypes.Email))); ?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    no email claim exist

    You can find a way to get an email from result.Principal or add a random email claim to id.

  • User Avatar
    0
    s.alshammari.c created

    inside result.Principal about 22 claims first one is "Name" and "PrimarySid" and all others are "groupsid" , there is no email claim

  • User Avatar
    0
    s.alshammari.c created

    hi

    no email claim exist

    You can find a way to get an email from result.Principal or add a random email claim to id.

    I did this and here is what I got

    is there a way to bypass register page ? I want everything to run in background and user automatically log in.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Try to use the AbpClaimTypes.Email as the claim type.

  • User Avatar
    0
    s.alshammari.c created

    thank you , now it works but user still need to press login button in order to login . is there a way to auto login on website enter

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Add redirect to your index page.

    if (!CurrentUser.IsAuthenticated)
    {
        return Redirect("/account/login); 
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38