3

I am building an intranet application using Visual Studio 2017 and used the template for creating a .NET Core Web Application with Angular. Since it is an intranet application, we want to implement windows authentication. The users are already logged in to the network and we wouldnt want them to enter their credentials again when they access the application.

How can I setup my Angular application so that it can recognise the user that is already logged in to the network and pass it appropriately. We have a Web API Authentication API that can take this user id and determine which AD Groups the user exists in, in order to determine authorisation to the application.

The question i had specifically asked is about Angular Windows Authentication. Not Web API Windows authentication. Also the very specific point I made was that I would like to understand how to pass the logged in windows AD Account into a service used for authorisation without having to ask the users to specifically enter their credentials in a login form. The below question does not address my question.

How to configure ASP.NET Core application to use windows authentication?

1
  • I have added more detail to my question. Please let me know if that does not make sense. Commented Feb 2, 2018 at 15:44

1 Answer 1

1

On client side have you tried setting withCredentials: true before sending out the request?

I'd create an angular interceptor and set the property there so on every request is always set. Something like this:

import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable()
export class CustomInterceptor implements HttpInterceptor {
    constructor() { }

    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        request = request.clone({
            withCredentials: true
        });

        return next.handle(request);
    }
}

Then on the server side check User.Identity which should get you the logged in user AD details.

I have done this and using Chrome I don't have to enter any login details. It doesn't seem to work on my Firefox as you have to login the first time.

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.