Files
alfresco-ng2-components/docs/core/services/authentication.service.md
Denys Vuika 0b90affea4 ACS-8770 Update the Auth Service api docs and deprecations (#9947)
* update api docs and clean dead code

* update api docs and clean dead code

rebasing onto develop branch

* [ACS-8770] fix unit test after auth refactor

* [ACS-8770] fix sonarcube issues

* [ACS-8770] update auth service doc file

* [ACS-8770] clean up demo-shell artifacts

---------

Co-authored-by: Anton Ramanovich <Anton.Ramanovich@hyland.com>
2025-07-21 15:16:59 +02:00

4.8 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Authentication Service v2.0.0 Active 2025-06-12

Authentication Service

Provides authentication to ACS and APS.

Class members

Methods

  • addTokenToHeader(requestUrl: string, headersArg?: HttpHeaders): Observable<HttpHeaders>
    Adds the auth token to an HTTP header using the 'bearer' scheme.
    • requestUrl: string - The URL of the request for which to set authentication headers.
    • headersArg: HttpHeaders - (Optional) Header that will receive the token
    • Returns Observable<HttpHeaders> - The new header with the token added
  • getToken(): string
    Gets the auth token.
    • Returns string - Auth token string
  • getUsername(): string
    Gets the username of the authenticated user.
    • Returns string - Username of the authenticated user
  • getAuthHeaders(requestUrl: string, headers: HttpHeaders): HttpHeaders
    Gets and sets the necessary authentication headers for a given request URL.
    • requestUrl: string - The URL of the request for which to obtain authentication headers.
    • headers: HttpHeaders - The existing HTTP headers to which authentication details might be added.
    • Returns HttpHeaders - The HTTP headers object, potentially updated with authentication tokens.
  • isALLProvider(): boolean
    Does the provider support both ECM and BPM?
    • Returns boolean - True if both are supported, false otherwise
  • isBPMProvider(): boolean
    Does the provider support BPM?
    • Returns boolean - True if supported, false otherwise
  • isECMProvider(): boolean
    Does the provider support ECM?
    • Returns boolean - True if supported, false otherwise
  • isKerberosEnabled(): boolean
    Does kerberos enabled?
    • Returns boolean - True if enabled, false otherwise
  • isLoggedIn(): boolean
    Checks if the user logged in.
    • Returns boolean - True if logged in, false otherwise
  • isOauth(): boolean
    Does the provider support OAuth?
    • Returns boolean - True if supported, false otherwise
  • login(username: string, password: string, rememberMe?: boolean): Observable<{ type: string; ticket: any }>
    Logs the user in.
    • username: string - Username for the login
    • password: string - Password for the login
    • rememberMe: boolean - (Optional) Stores the user's login details if true
    • Returns Observable<{ type: string; ticket: any }> - An Observable that emits an object containing the authentication type (type) and the authentication ticket (ticket) upon successful login.
  • logout(): Observable<any>
    Logs the user out.
    • Returns Observable<any> - Response event called when logout is complete
  • reset(): void
    Resets the authentication state of the service.
  • on(event: string, listener: Function): void
    Adds an event listener for the specified event.
  • off(event: string, listener?: Function): void
    Removes an event listener for the specified event.
  • once(event: string, listener: Function): void
    Adds a one-time event listener for the specified event.
  • emit(event: string, ...args: any[]): void
    Emits an event with optional arguments.
  • onLogin: Subject<any>
    Emitted when the user logs in successfully.
  • onLogout: Subject<any>
    Emitted when the user logs out.
  • onTokenReceived: Subject<any>
    Emitted when an authentication token is received.
  • onError: Observable<any>
    An Observable that emits an error object when an authentication-related error occurs.

Details

Usage example

import { AuthenticationService } from '@alfresco/adf-core';

@Component({...})
export class AppComponent {
    constructor(authService: AuthenticationService) {
        this.AuthenticationService.login('admin', 'admin').subscribe(
            token => {
                console.log(token);
            },
            error => {
                console.log(error);
            }
        );
    }
}

See also