mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 18:44:14 +00:00
Removed global config from auth.service
This commit is contained in:
@@ -32,8 +32,8 @@ module.exports = {
|
|||||||
// Authentications
|
// Authentications
|
||||||
auth: {
|
auth: {
|
||||||
target: {
|
target: {
|
||||||
host: 'https://dspace7.4science.it',
|
host: 'https://fis.tiss.tuwien.ac.at',
|
||||||
page: '/dspace-spring-rest/shib.html'
|
page: '/spring-rest/login.html'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Form settings
|
// Form settings
|
||||||
|
@@ -31,7 +31,8 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
// we're creating a refresh token request list
|
// we're creating a refresh token request list
|
||||||
protected refreshTokenRequestUrls = [];
|
protected refreshTokenRequestUrls = [];
|
||||||
|
|
||||||
constructor(private inj: Injector, private router: Router, private store: Store<AppState>) { }
|
constructor(private inj: Injector, private router: Router, private store: Store<AppState>) {
|
||||||
|
}
|
||||||
|
|
||||||
private is405AuthResponse(response: HttpResponseBase): boolean {
|
private is405AuthResponse(response: HttpResponseBase): boolean {
|
||||||
return response.status === 405;
|
return response.status === 405;
|
||||||
@@ -146,10 +147,19 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
if (this.isAuthRequest(error)) {
|
if (this.isAuthRequest(error)) {
|
||||||
console.log('catchError isAuthRequest=true');
|
console.log('catchError isAuthRequest=true');
|
||||||
// clean eventually refresh Requests list
|
// clean eventually refresh Requests list
|
||||||
|
|
||||||
this.refreshTokenRequestUrls = [];
|
this.refreshTokenRequestUrls = [];
|
||||||
// console.log('error: ', error);
|
// console.log('error: ', error);
|
||||||
const location = error.headers.get('Location');// this line added while shibboleth dev
|
let location = error.headers.get('location');// this line added while shibboleth dev
|
||||||
console.log('error.headers.get("Location"): ', location);
|
console.log('error.headers.get("location"): ', location);
|
||||||
|
|
||||||
|
console.log('www-authenticate', error.headers.get('www-authenticate'));
|
||||||
|
let strings = error.headers.get('www-authenticate').split(',');
|
||||||
|
let string = strings[1];
|
||||||
|
let s = string.replace('location=', '');
|
||||||
|
let s1 = s.replace('"', '').trim();
|
||||||
|
console.log('This should be the location: ', s1);
|
||||||
|
location = s1;
|
||||||
|
|
||||||
console.log('error headers: ', error.headers);
|
console.log('error headers: ', error.headers);
|
||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
|
@@ -23,6 +23,8 @@ import { AppState } from '../../app.reducer';
|
|||||||
import { ClientCookieService } from '../../shared/services/client-cookie.service';
|
import { ClientCookieService } from '../../shared/services/client-cookie.service';
|
||||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service';
|
import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service';
|
||||||
|
import {GlobalConfig} from '../../../config/global-config.interface';
|
||||||
|
import {GLOBAL_CONFIG} from '../../../config';
|
||||||
|
|
||||||
describe('AuthService test', () => {
|
describe('AuthService test', () => {
|
||||||
|
|
||||||
@@ -138,9 +140,9 @@ describe('AuthService test', () => {
|
|||||||
{ provide: AuthRequestService, useValue: authRequest },
|
{ provide: AuthRequestService, useValue: authRequest },
|
||||||
{ provide: REQUEST, useValue: {} },
|
{ provide: REQUEST, useValue: {} },
|
||||||
{ provide: Router, useValue: routerStub },
|
{ provide: Router, useValue: routerStub },
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbService },
|
|
||||||
CookieService,
|
CookieService,
|
||||||
AuthService
|
AuthService,
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
@@ -43,7 +43,7 @@ export class AuthService {
|
|||||||
protected _authenticated: boolean;
|
protected _authenticated: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
// @Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
||||||
@Inject(REQUEST) protected req: any,
|
@Inject(REQUEST) protected req: any,
|
||||||
@Inject(NativeWindowService) protected _window: NativeWindowRef,
|
@Inject(NativeWindowService) protected _window: NativeWindowRef,
|
||||||
protected authRequestService: AuthRequestService,
|
protected authRequestService: AuthRequestService,
|
||||||
@@ -203,18 +203,20 @@ export class AuthService {
|
|||||||
*/
|
*/
|
||||||
public retrieveAuthMethods(): Observable<string> {
|
public retrieveAuthMethods(): Observable<string> {
|
||||||
console.log('auth.service retrieveAuthMethods() was called');
|
console.log('auth.service retrieveAuthMethods() was called');
|
||||||
return this.authRequestService.getRequest('login').pipe(
|
// return this.authRequestService.getRequest('login').pipe(
|
||||||
|
return this.authRequestService.postToEndpoint('login', {}).pipe(
|
||||||
map((status: AuthStatus) => {
|
map((status: AuthStatus) => {
|
||||||
let url = '';
|
let url = '';
|
||||||
if (isNotEmpty(status.ssoLoginUrl)) {
|
if (isNotEmpty(status.ssoLoginUrl)) {
|
||||||
url = this.parseSSOLocation(status.ssoLoginUrl);
|
// url = this.parseSSOLocation(status.ssoLoginUrl);
|
||||||
|
url = 'https://fis.tiss.tuwien.ac.at/Shibboleth.sso/Login?target=https%3A%2F%2Ffis.tiss.tuwien.ac.at';
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseSSOLocation(url: string): string {
|
/* private parseSSOLocation(url: string): string {
|
||||||
console.log('auth.service parseSSOLocation was called');
|
console.log('auth.service parseSSOLocation was called');
|
||||||
const parseUrl = decodeURIComponent(url);
|
const parseUrl = decodeURIComponent(url);
|
||||||
// const urlTree: UrlTree = this.router.parseUrl(url);
|
// const urlTree: UrlTree = this.router.parseUrl(url);
|
||||||
@@ -227,7 +229,7 @@ export class AuthService {
|
|||||||
// console.log(url);
|
// console.log(url);
|
||||||
const target = `?target=${this.config.auth.target.host}${this.config.auth.target.page}`;
|
const target = `?target=${this.config.auth.target.host}${this.config.auth.target.page}`;
|
||||||
return parseUrl.replace(/\?target=http.+/g, target);
|
return parseUrl.replace(/\?target=http.+/g, target);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new user
|
* Create a new user
|
||||||
|
Reference in New Issue
Block a user