Skip to content

Commit

Permalink
Merge pull request #65 from Mihai-B/master
Browse files Browse the repository at this point in the history
switch back the bearer interceptor to be enabled by default
  • Loading branch information
mauriciovigolo authored May 23, 2018
2 parents dd5a485 + 0da1fa7 commit fa7422f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ There is also the possibility to exclude a list of URLs that should not have the
onLoad: 'login-required',
checkLoginIframe: false
},
enableBearerInterceptor: true,
bearerExcludedUrls: [
'/assets',
'/clients/public'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class KeycloakBearerInterceptor implements HttpInterceptor {
*/
public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// If keycloak service is not initialized yet, or the interceptor should not be execute
if (!this.keycloak || !this.keycloak.disableBearerInterceptor) {
if (!this.keycloak || !this.keycloak.enableBearerInterceptor) {
return next.handle(req);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export interface KeycloakOptions {
/**
* By default all requests made by Angular HttpClient will be intercepted in order to
* add the bearer in the Authorization Http Header. However, if this is a not desired
* feature, the disabledBearerInterceptor must be true.
* feature, the enableBearerInterceptor must be false.
*
* Briefly, if disabledBearerInterceptor === true, the bearer will not be added
* Briefly, if enableBearerInterceptor === false, the bearer will not be added
* to the authorization header.
*
* The default value is false.
* The default value is true.
*/
disableBearerInterceptor?: boolean;
enableBearerInterceptor?: boolean;
/**
* String Array to exclude the urls that should not have the Authorization Header automatically
* added. This library makes use of Angular Http Interceptor, to automatically add the Bearer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class KeycloakService {
/**
* Flag to indicate if the bearer will not be added to the authorization header.
*/
private _disableBearerInterceptor: boolean;
private _enableBearerInterceptor: boolean;
/**
* The bearer prefix that will be appended to the Authorization Header.
*/
Expand Down Expand Up @@ -145,8 +145,8 @@ export class KeycloakService {
* recommended over query.
* - flow: Set the OpenID Connect flow. Valid values are standard, implicit or hybrid.
*
* disableBearerInterceptor:
* Flag to indicate if the bearer will not be added to the authorization header.
* enableBearerInterceptor:
* Flag to indicate if the bearer will added to the authorization header.
*
* bearerExcludedUrls:
* String Array to exclude the urls that should not have the Authorization Header automatically
Expand All @@ -164,7 +164,7 @@ export class KeycloakService {
init(options: KeycloakOptions = {}): Promise<boolean> {
return new Promise((resolve, reject) => {
this._bearerExcludedUrls = options.bearerExcludedUrls || [];
this._disableBearerInterceptor = options.disableBearerInterceptor || false;
this._enableBearerInterceptor = options.enableBearerInterceptor || true;
this._authorizationHeaderName = options.authorizationHeaderName || 'Authorization';
this._bearerPrefix = this.sanitizeBearerPrefix(options.bearerPrefix);
this._instance = Keycloak(options.config);
Expand Down Expand Up @@ -491,13 +491,13 @@ export class KeycloakService {
}

/**
* Flag to indicate if the bearer will not be added to the authorization header.
* Flag to indicate if the bearer will be added to the authorization header.
*
* @returns
* Returns if the bearer interceptor was set to be disabled.
*/
get disableBearerInterceptor(): boolean {
return this._disableBearerInterceptor;
get enableBearerInterceptor(): boolean {
return this._enableBearerInterceptor;
}

/**
Expand Down

0 comments on commit fa7422f

Please sign in to comment.