File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { Observable } from 'rxjs';
13
13
import { catchError } from 'rxjs/operators' ;
14
14
import { OAuthResourceServerErrorHandler } from './resource-server-error-handler' ;
15
15
import { OAuthModuleConfig } from '../oauth-module.config' ;
16
+ import { isPlatformBrowser } from '@angular/common' ;
16
17
17
18
@Injectable ( )
18
19
export class DefaultOAuthInterceptor implements HttpInterceptor {
@@ -23,8 +24,15 @@ export class DefaultOAuthInterceptor implements HttpInterceptor {
23
24
) { }
24
25
25
26
private checkUrl ( url : string ) : boolean {
26
- const found = this . moduleConfig . resourceServer . allowedUrls . find ( u => url . startsWith ( u ) ) ;
27
- return ! ! found ;
27
+ if ( this . moduleConfig . resourceServer . customUrlValidation ) {
28
+ return this . moduleConfig . resourceServer . customUrlValidation ( url ) ;
29
+ }
30
+
31
+ if ( this . moduleConfig . resourceServer . allowedUrls ) {
32
+ return ! ! this . moduleConfig . resourceServer . allowedUrls . find ( u => url . startsWith ( u ) ) ;
33
+ }
34
+
35
+ return true ;
28
36
}
29
37
30
38
public intercept (
@@ -39,7 +47,7 @@ export class DefaultOAuthInterceptor implements HttpInterceptor {
39
47
if ( ! this . moduleConfig . resourceServer ) {
40
48
return next . handle ( req ) ;
41
49
}
42
- if ( this . moduleConfig . resourceServer . allowedUrls && ! this . checkUrl ( url ) ) {
50
+ if ( ! this . checkUrl ( url ) ) {
43
51
return next . handle ( req ) ;
44
52
}
45
53
Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ export abstract class OAuthResourceServerConfig {
10
10
*/
11
11
allowedUrls ?: Array < string > ;
12
12
sendAccessToken : boolean ;
13
+ customUrlValidation ?: ( url : string ) => boolean ;
13
14
}
You can’t perform that action at this time.
0 commit comments