UNPKG

keycloak-angular

Version:

Easy Keycloak integration for Angular applications.

54 lines (53 loc) 2.17 kB
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; import { Observable } from 'rxjs'; import { KeycloakService } from '../services/keycloak.service'; import * as i0 from "@angular/core"; /** * This interceptor includes the bearer by default in all HttpClient requests. * * If you need to exclude some URLs from adding the bearer, please, take a look * at the {@link KeycloakOptions} bearerExcludedUrls property. * * @deprecated KeycloakBearerInterceptor is deprecated and will be removed in future versions. * Use the new functional interceptor such as `includeBearerTokenInterceptor`. * More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md */ export declare class KeycloakBearerInterceptor implements HttpInterceptor { private keycloak; constructor(keycloak: KeycloakService); /** * Calls to update the keycloak token if the request should update the token. * * @param req http request from @angular http module. * @returns * A promise boolean for the token update or noop result. */ private conditionallyUpdateToken; /** * @deprecated * Checks if the url is excluded from having the Bearer Authorization * header added. * * @param req http request from @angular http module. * @param excludedUrlRegex contains the url pattern and the http methods, * excluded from adding the bearer at the Http Request. */ private isUrlExcluded; /** * Intercept implementation that checks if the request url matches the excludedUrls. * If not, adds the Authorization header to the request if the user is logged in. * * @param req * @param next */ intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>; /** * Adds the token of the current user to the Authorization header * * @param req * @param next */ private handleRequestWithTokenHeader; static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakBearerInterceptor, never>; static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakBearerInterceptor>; }