alfresco-ng2-components/lib/core/auth/src/authentication-interceptor
Darya Blavanovich 3819aecb70
[MNT-24354] update license header to 2024 (#9633)
* MNT-24354 update license header [ci:force]

* MNT-24354 fix lint [ci:force]

* MNT-24354 [ci:force]

* MNT-24354 update license header in process-services [ci:force]

---------

Co-authored-by: DaryaBalvanovich <darya.balvanovich1@hyland.com>
2024-05-08 08:34:51 +02:00
..

AuthenticationInterceptor

This interceptor is responsible for providing authentication to angular HttpClient requests when a context SHOULD_ADD_AUTH_TOKEN is set to true. By default, the interceptor won't do anything to the intercepted request.

Usage

import { SHOULD_ADD_AUTH_TOKEN } from '@alfresco/adf-core/auth';
import { HttpClient, HttpContext } from '@angular/common/http';

getSth() {
    return this.httpClient.get('http://example.com', { context: new HttpContext().set(SHOULD_ADD_AUTH_TOKEN, true)});
}

// or

getSth() {
    const someRequest = this.httpClient.get('GET', 'http://example.com');
    someRequest.context.set(SHOULD_ADD_AUTH_TOKEN, true);

    return someRequest;
}