Commit 255d612f authored by Chris Hines's avatar Chris Hines
Browse files

fix up a redirect

parent c5e4d9e9
Pipeline #7544 passed with stages
in 3 minutes and 3 seconds
...@@ -49,7 +49,7 @@ export class AuthorisationService { ...@@ -49,7 +49,7 @@ export class AuthorisationService {
this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>([]); this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]); this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
this.backendURI = null; this.backendURI = null;
this.agentContents = new BehaviorSubject([]); this.agentContents = new BehaviorSubject(null);
this.keys = []; this.keys = [];
this.getSshAuthzServers(); this.getSshAuthzServers();
this.keys = []; this.keys = [];
...@@ -89,6 +89,9 @@ export class AuthorisationService { ...@@ -89,6 +89,9 @@ export class AuthorisationService {
let loggedin = [] let loggedin = []
let loggedout = [] let loggedout = []
var found: boolean; var found: boolean;
if (agentContents == null) {
return
}
for (let s of authzServers) { for (let s of authzServers) {
found=false; found=false;
for (let cert of agentContents) { for (let cert of agentContents) {
...@@ -133,9 +136,7 @@ export class AuthorisationService { ...@@ -133,9 +136,7 @@ export class AuthorisationService {
} }
storeToken(frag: string) { storeToken(frag: string) {
console.log('storing the token fragment');
if (frag === undefined || frag == null) { if (frag === undefined || frag == null) {
console.log('framgned not defined, not storing');
return; return;
} }
let tokenmatch = null; let tokenmatch = null;
...@@ -154,12 +155,6 @@ export class AuthorisationService { ...@@ -154,12 +155,6 @@ export class AuthorisationService {
//Verify that the state matched the nonce we used when initiating login //Verify that the state matched the nonce we used when initiating login
let tuple = JSON.parse(sessionStorage.getItem('authservice')); let tuple = JSON.parse(sessionStorage.getItem('authservice'));
if (tuple == null) {
console.log('token found, but no authService defined');
let data = sessionStorage.getItem('authservice');
console.log(data);
return
}
if (tuple[1] != state) { if (tuple[1] != state) {
return return
} }
...@@ -173,27 +168,21 @@ export class AuthorisationService { ...@@ -173,27 +168,21 @@ export class AuthorisationService {
public getCert() { public getCert() {
var token: AuthToken; var token: AuthToken;
token = this.token.value; token = this.token.value;
console.log('entered getCert');
if (token === null || token === undefined || token.token === undefined || token.token === '' || token.token === null) { if (token === null || token === undefined || token.token === undefined || token.token === '' || token.token === null) {
console.log('getCert token not defined, setting callback');
console.log(this.token.value);
this.token.pipe(skip(1),take(1)).subscribe(() => this.getCert()); this.token.pipe(skip(1),take(1)).subscribe(() => this.getCert());
return return
} }
if (this.backendSelectionService.apiserver.value === null || this.backendSelectionService.apiserver.value === undefined) { if (this.backendSelectionService.apiserver.value === null || this.backendSelectionService.apiserver.value === undefined) {
console.log('getCert api server not defined, setting callback');
this.backendSelectionService.apiserver.pipe(skip(1),take(1)).subscribe(() => this.getCert()); this.backendSelectionService.apiserver.pipe(skip(1),take(1)).subscribe(() => this.getCert());
return return
} }
console.log('generating ssh key');
let starttime = new Date(); let starttime = new Date();
let newkeypair = keypair(); let newkeypair = keypair();
let publicKey = forge.pki.publicKeyFromPem(newkeypair.public); let publicKey = forge.pki.publicKeyFromPem(newkeypair.public);
let sshpub = forge.ssh.publicKeyToOpenSSH(publicKey, 'sv2@monash.edu'); let sshpub = forge.ssh.publicKeyToOpenSSH(publicKey, 'sv2@monash.edu');
let endtime = new Date(); let endtime = new Date();
console.log('created a private key, getting it signed');
let headers = new HttpHeaders(); let headers = new HttpHeaders();
let options = { headers: headers, withCredentials: true}; let options = { headers: headers, withCredentials: true};
...@@ -237,8 +226,6 @@ public getKeys(id?: Identity) { ...@@ -237,8 +226,6 @@ public getKeys(id?: Identity) {
} }
let path=sessionStorage.getItem('path'); let path=sessionStorage.getItem('path');
this.updateAgentContents(); this.updateAgentContents();
console.log('navigating to ');
console.log(path);
// only navigate once the agent contents has been refreshed // only navigate once the agent contents has been refreshed
this.loggedInAuthZ.pipe(take(1)).subscribe( () => {this.readyToNavigate.next([true,path])}); this.loggedInAuthZ.pipe(take(1)).subscribe( () => {this.readyToNavigate.next([true,path])});
} }
...@@ -255,9 +242,6 @@ public getKeys(id?: Identity) { ...@@ -255,9 +242,6 @@ public getKeys(id?: Identity) {
if (this.backendURI == null) { if (this.backendURI == null) {
return return
} }
console.log('attempting to update agent contents');
console.log(this.backendSelectionService.apiserver)
console.log(this.backendURI);
if (this.statusMsg !== undefined) { if (this.statusMsg !== undefined) {
this.statusMsg.next("Updating the list of available accounts"); this.statusMsg.next("Updating the list of available accounts");
}; };
...@@ -312,8 +296,6 @@ public getKeys(id?: Identity) { ...@@ -312,8 +296,6 @@ public getKeys(id?: Identity) {
let nonce=Math.random().toString(36).substring(2, 15) let nonce=Math.random().toString(36).substring(2, 15)
sessionStorage.setItem('authservice', JSON.stringify([authservice,nonce])); sessionStorage.setItem('authservice', JSON.stringify([authservice,nonce]));
console.log('stored the authservice in sessionStorage');
console.log(sessionStorage.getItem('authservice'));
sessionStorage.setItem('path', '/launch'); sessionStorage.setItem('path', '/launch');
if (authservice.scope == null) { if (authservice.scope == null) {
window.location.assign(authservice.authorise+"?response_type=token&redirect_uri="+redirect_uri+"&state="+nonce+"&client_id="+authservice.client_id); window.location.assign(authservice.authorise+"?response_type=token&redirect_uri="+redirect_uri+"&state="+nonce+"&client_id="+authservice.client_id);
...@@ -351,7 +333,6 @@ public getKeys(id?: Identity) { ...@@ -351,7 +333,6 @@ public getKeys(id?: Identity) {
} }
private signingError(error: any,sshauthzservice: SshAuthzServer) { private signingError(error: any,sshauthzservice: SshAuthzServer) {
this.statusMsg.next('You don\'t appear to have an account on '+sshauthzservice.name); this.statusMsg.next('You don\'t appear to have an account on '+sshauthzservice.name);
console.log(error);
if (!(sshauthzservice.logout === null)) { if (!(sshauthzservice.logout === null)) {
window.open(sshauthzservice.logout); window.open(sshauthzservice.logout);
} }
......
...@@ -24,16 +24,12 @@ export class BackendSelectionService { ...@@ -24,16 +24,12 @@ export class BackendSelectionService {
private initApiServer() { private initApiServer() {
try { try {
this.apiserver.next(<APIServer>JSON.parse(localStorage.getItem('apiserver'))); this.apiserver.next(<APIServer>JSON.parse(localStorage.getItem('apiserver')));
console.log('selected api server');
console.log(this.apiserver.value);
} catch { } catch {
this.apiserver.next(null); this.apiserver.next(null);
} }
if (this.apiserver.value === null) { if (this.apiserver.value === null) {
console.log('no saved api server, waitin for a list to choose the first one')
//this.apiservers.pipe(filter((v) => v !== []),take(1)).subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)}) //this.apiservers.pipe(filter((v) => v !== []),take(1)).subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)})
this.apiservers.subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)}) this.apiservers.subscribe((v) => this.defaultApiServer(v))
this.apiservers.subscribe((l) => {console.log('api servers changed'); console.log(l);});
} }
} }
...@@ -61,7 +57,6 @@ export class BackendSelectionService { ...@@ -61,7 +57,6 @@ export class BackendSelectionService {
}*/ }*/
getAPIServers() { getAPIServers() {
console.log('retrieving api servers');
let headers = new HttpHeaders(); let headers = new HttpHeaders();
let options = { headers: headers, withCredentials: false}; let options = { headers: headers, withCredentials: false};
this.http.get<APIServer[]>('./assets/config/apiservers.json',options) this.http.get<APIServer[]>('./assets/config/apiservers.json',options)
...@@ -69,7 +64,6 @@ export class BackendSelectionService { ...@@ -69,7 +64,6 @@ export class BackendSelectionService {
} }
private updateAPIServers(resp) { private updateAPIServers(resp) {
console.log('got some api servers merging them');
var s: APIServer; var s: APIServer;
var list: APIServer[] = [] var list: APIServer[] = []
var current: APIServer; var current: APIServer;
...@@ -105,7 +99,6 @@ export class BackendSelectionService { ...@@ -105,7 +99,6 @@ export class BackendSelectionService {
list.push(current); list.push(current);
} }
this.apiservers.next(list); this.apiservers.next(list);
console.log('apiserver merge complete');
} }
} }
...@@ -24,8 +24,8 @@ export class ComputesitesService { ...@@ -24,8 +24,8 @@ export class ComputesitesService {
constructor(private http: HttpClient, private authorisationService: AuthorisationService) { constructor(private http: HttpClient, private authorisationService: AuthorisationService) {
this.computesites = new BehaviorSubject<Computesite[]>([]); this.computesites = new BehaviorSubject<Computesite[]>([]);
this.identities = new BehaviorSubject<Identity[]>([]); this.identities = new BehaviorSubject<Identity[]>([]);
this.appidentities = new BehaviorSubject<Identity[]>([]); this.appidentities = new BehaviorSubject<Identity[]>(null);
this.ftidentities = new BehaviorSubject<Identity[]>([]); this.ftidentities = new BehaviorSubject<Identity[]>(null);
this.computesites.subscribe(computesites => this.getStrudelApps(computesites)) this.computesites.subscribe(computesites => this.getStrudelApps(computesites))
this.computesites.subscribe((cs) => this.authorisationService.updateAgentContents()); this.computesites.subscribe((cs) => this.authorisationService.updateAgentContents());
...@@ -155,6 +155,10 @@ export class ComputesitesService { ...@@ -155,6 +155,10 @@ export class ComputesitesService {
var identities: Identity[] = []; var identities: Identity[] = [];
var appidentities: Identity[] = []; var appidentities: Identity[] = [];
var ftidentities: Identity[] = []; var ftidentities: Identity[] = [];
// If the agent contents is set to null we are probably still updating it
if (resp == null) {
return
}
for (cs of this.computesites.value) { for (cs of this.computesites.value) {
for (let i in certs) { for (let i in certs) {
let principal = this.siteMatch(certs[i],cs); let principal = this.siteMatch(certs[i],cs);
......
...@@ -129,12 +129,18 @@ export class LauncherComponent implements OnInit { ...@@ -129,12 +129,18 @@ export class LauncherComponent implements OnInit {
} }
navLogin(o) { navLogin(o) {
if (o == null) {
return
}
if (o.length == 0) { if (o.length == 0) {
this.router.navigate(['/login']); this.router.navigate(['/login']);
} }
} }
getHealth(o) { getHealth(o) {
if (o == null) {
return
}
for (let id of o) { for (let id of o) {
this.tesService.getHealthAlerts(id); this.tesService.getHealthAlerts(id);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment