SSO auth bug fix

SSO auth bug fix
pull/260/head
Shahana Farooqui 4 years ago
parent 3397521a83
commit 8f2db2ff32

2
.gitignore vendored

@ -46,3 +46,5 @@ RTL-Config.json
RTL-Config-1.json
RTL-Multi-Node-Conf.json
RTL.conf
RTL-1.conf
RTL-Multi-Node-Conf-1.json

@ -12,5 +12,5 @@
<link rel="stylesheet" href="styles.90ee7bcb73e8367b2a29.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.bd15680a9b84bab2ef08.js" defer></script><script src="polyfills-es5.37b2eeccc22c1df73ce7.js" nomodule defer></script><script src="polyfills.f1c3d2a0bcdfc4e93ca8.js" defer></script><script src="main.9b4e9790c9a8eba28ff9.js" defer></script></body>
<script src="runtime.bd15680a9b84bab2ef08.js" defer></script><script src="polyfills-es5.37b2eeccc22c1df73ce7.js" nomodule defer></script><script src="polyfills.f1c3d2a0bcdfc4e93ca8.js" defer></script><script src="main.b6178808094e07f60dfd.js" defer></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -334,7 +334,7 @@ connect.setSelectedNode = (config) => {
}
}
connect.modifyJsonForNewUX = (confFileFullPath) => {
connect.modifyJsonMultiNodeConfig = (confFileFullPath) => {
RTLConfFile = common.rtl_conf_file_path + '/RTL-Multi-Node-Conf.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
if (!config.SSO) { config.SSO = {}; }
@ -402,7 +402,7 @@ connect.modifyJsonForNewUX = (confFileFullPath) => {
fs.writeFileSync(confFileFullPath, JSON.stringify(newConfig, null, 2), 'utf-8');
}
connect.upgradeIniToJson = (confFileFullPath) => {
connect.modifyIniSingleNodeConfig = (confFileFullPath) => {
RTLConfFile = common.rtl_conf_file_path + '/RTL.conf';
var config = ini.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
if (!config.SSO) { config.SSO = {}; }
@ -473,12 +473,18 @@ connect.upgradeConfig = (confFileFullPath) => {
const singleNodeExists = fs.existsSync(singleNodeConfFile);
const multiNodeExists = fs.existsSync(multiNodeConfFile);
if ((singleNodeExists && multiNodeExists) || (!singleNodeExists && multiNodeExists)) {
connect.modifyJsonForNewUX(confFileFullPath);
console.log('Start...config migration for file ' + multiNodeConfFile);
connect.modifyJsonMultiNodeConfig(confFileFullPath);
console.log('End...config migration.');
} else if (singleNodeExists && !multiNodeExists) {
connect.upgradeIniToJson(confFileFullPath);
console.log('Start...config migration for file ' + singleNodeConfFile);
connect.modifyIniSingleNodeConfig(confFileFullPath);
console.log('End...config migration.');
} else if (!singleNodeExists && !multiNodeExists) {
if (!fs.existsSync(confFileFullPath)) {
console.log('Start...config creation at: ' + confFileFullPath);
fs.writeFileSync(confFileFullPath, JSON.stringify(connect.setDefaultConfig(), null, 2), 'utf-8');
console.log('End...config creation.');
}
}
} catch(err) {

2
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.6.4-beta",
"version": "0.6.4-beta-rc2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.6.4-beta",
"version": "0.6.4-beta-rc2",
"license": "MIT",
"scripts": {
"ng": "ng",

@ -88,7 +88,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
if (action.type === RTLActions.SET_RTL_CONFIG) {
if (!this.sessionService.getItem('token')) {
if (+action.payload.sso.rtlSSO) {
this.store.dispatch(new RTLActions.Login(sha256(this.accessKey)));
this.store.dispatch(new RTLActions.Login({password: sha256(this.accessKey), initialPass: false}));
} else {
this.router.navigate([this.appConfig.sso.logoutRedirectLink]);
}

@ -1,5 +1,5 @@
<div fxLayout="column" fxFlex="100" class="overflow-x-hidden">
<form (ngSubmit)="onResetPassword()" fxLayout="column" fxLayoutAlign="start stretch" class="settings-container page-sub-title-container mt-1" #form="ngForm">
<form (ngSubmit)="onResetPassword()" fxLayout="column" fxLayoutAlign="start stretch" class="settings-container page-sub-title-container mt-1" #authForm="ngForm">
<div fxFlex="100" class="mb-1">
<fa-icon [icon]="faKey" class="page-title-img mr-1"></fa-icon>
<span class="page-title">Reset Password</span>
@ -12,11 +12,11 @@
</mat-form-field>
<mat-form-field>
<input matInput placeholder="New Password" type="password" id="newpassword" name="newpassword" [(ngModel)]="newPassword" tabindex="2" required>
<mat-error *ngIf="!newPassword">New password is required.</mat-error>
<mat-error *ngIf="matchOldAndNewPasswords()">{{errorMsg}}</mat-error>
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Confirm New Password" type="password" id="confirmpassword" name="confirmpassword" [(ngModel)]="confirmPassword" tabindex="3" required>
<mat-error *ngIf="!confirmPassword">Confirm new password is required.</mat-error>
<mat-error *ngIf="matchNewPasswords()">{{errorConfirmMsg}}</mat-error>
</mat-form-field>
</div>
</div>

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { Store } from '@ngrx/store';
import { faKey } from '@fortawesome/free-solid-svg-icons';
import * as sha256 from 'sha256';
@ -12,20 +12,63 @@ import * as RTLActions from '../../../../store/rtl.actions';
styleUrls: ['./auth-settings.component.scss']
})
export class AuthSettingsComponent implements OnInit {
@ViewChild('authForm', { static: true }) form: any;
public faKey = faKey;
public oldPassword = '';
public newPassword = '';
public confirmPassword = '';
public errorMsg = '';
public errorConfirmMsg = '';
constructor(private store: Store<fromRTLReducer.RTLState>) {}
ngOnInit() {}
onResetPassword() {
if(!this.oldPassword || !this.newPassword || !this.confirmPassword) { return true; }
if(!this.oldPassword || !this.newPassword || !this.confirmPassword || this.oldPassword === this.newPassword) { return true; }
this.store.dispatch(new RTLActions.ResetPassword({oldPassword: sha256(this.oldPassword), newPassword: sha256(this.newPassword)}));
}
matchOldAndNewPasswords(): boolean {
let invalid = false;
if(this.form.controls.newpassword) {
if (!this.newPassword) {
this.form.controls.newpassword.setErrors({invalid: true});
this.errorMsg = 'New password is required.';
invalid = true;
} else if (this.oldPassword !== '' && this.newPassword !== '' && this.oldPassword === this.newPassword) {
this.form.controls.newpassword.setErrors({invalid: true});
this.errorMsg = 'Old and New password cannot be same.';
invalid = true;
} else {
this.form.controls.newpassword.setErrors(null);
this.errorMsg = '';
invalid = false;
}
}
return invalid;
}
matchNewPasswords(): boolean {
let invalid = false;
if (this.form.controls.confirmpassword) {
if (!this.confirmPassword) {
this.form.controls.confirmpassword.setErrors({invalid: true});
this.errorConfirmMsg = 'Confirm password is required.';
invalid = true;
} else if (this.newPassword !== '' && this.confirmPassword !== '' && this.newPassword !== this.confirmPassword) {
this.form.controls.confirmpassword.setErrors({invalid: true});
this.errorConfirmMsg = 'New and confirm passwords do not match.';
invalid = true;
} else {
this.form.controls.confirmpassword.setErrors(null);
this.errorConfirmMsg = '';
invalid = false;
}
}
return invalid;
}
resetData() {
this.oldPassword = '';
this.newPassword = '';

@ -7,7 +7,7 @@
<mat-card-content fxLayout="column">
<mat-tab-group selectedIndex="{{loadTab === 'authSettings' ? 1 : 0}}">
<mat-tab id="appSettings" label="Settings"><rtl-app-settings></rtl-app-settings></mat-tab>
<mat-tab label="Password Reset"><rtl-auth-settings></rtl-auth-settings></mat-tab>
<mat-tab *ngIf="!appConfig.sso.rtlSSO" label="Password Reset"><rtl-auth-settings></rtl-auth-settings></mat-tab>
<mat-tab *ngIf="showLnConfig" [label]="lnImplementationStr">
<ng-template matTabContent>
<rtl-server-config [selectedNodeType]="'ln'"></rtl-server-config>

@ -1,12 +1,13 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { faTools } from '@fortawesome/free-solid-svg-icons';
import { ConfigSettingsNode } from '../../models/RTLconfig';
import { ConfigSettingsNode, RTLConfiguration } from '../../models/RTLconfig';
import * as fromRTLReducer from '../../../store/rtl.reducers';
import { ActivatedRoute } from '@angular/router';
import * as RTLActions from '../../../store/rtl.actions';
@Component({
selector: 'rtl-settings',
@ -18,8 +19,10 @@ export class SettingsComponent implements OnInit, OnDestroy{
public showLnConfig = false;
public showBitcoind = false;
public selNode: ConfigSettingsNode;
public appConfig: RTLConfiguration;
public lnImplementationStr = '';
public loadTab = 'appSettings';
public initializeNodeData = false;
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
constructor(private store: Store<fromRTLReducer.RTLState>, private activatedRoute: ActivatedRoute) {}
@ -29,12 +32,14 @@ export class SettingsComponent implements OnInit, OnDestroy{
.pipe(takeUntil(this.unSubs[0]))
.subscribe(data => {
this.loadTab = window.history.state.loadTab ? window.history.state.loadTab : 'appSettings';
this.initializeNodeData = window.history.state.initializeNodeData ? window.history.state.initializeNodeData : false;
});
this.store.select('root')
.pipe(takeUntil(this.unSubs[1]))
.subscribe((rtlStore) => {
this.showLnConfig = false;
this.showBitcoind = false;
this.appConfig = rtlStore.appConfig;
this.selNode = rtlStore.selNode;
this.lnImplementationStr = this.selNode.lnImplementation.toUpperCase() === 'CLT' ? 'C-Lightning Config' : 'LND Config';
if (this.selNode.authentication && this.selNode.authentication.configPath && this.selNode.authentication.configPath.trim() !== '') {
@ -47,6 +52,9 @@ export class SettingsComponent implements OnInit, OnDestroy{
}
ngOnDestroy() {
if(this.initializeNodeData) {
this.store.dispatch(new RTLActions.SetSelelectedNode({lnNode: this.selNode, isInitialSetup: true}));
}
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.complete();

@ -8,9 +8,9 @@ export const MENU_DATA: MenuRootNode = {
{id: 3, parentId: 0, name: 'Lightning', iconType: 'FA', icon: faBolt, link: '/lnd/peerschannels', userPersona: UserPersonaEnum.ALL, children: [
{id: 31, parentId: 3, name: 'Peers/Channels', iconType: 'FA', icon: faUsers, link: '/lnd/peerschannels', userPersona: UserPersonaEnum.ALL},
{id: 32, parentId: 3, name: 'Transactions', iconType: 'FA', icon: faExchangeAlt, link: '/lnd/transactions', userPersona: UserPersonaEnum.ALL},
{id: 33, parentId: 3, name: 'Backup', iconType: 'FA', icon: faDownload, link: '/lnd/backup', userPersona: UserPersonaEnum.ALL},
{id: 34, parentId: 3, name: 'Routing', iconType: 'FA', icon: faMapSigns, link: '/lnd/routing', userPersona: UserPersonaEnum.ALL},
{id: 35, parentId: 3, name: 'Graph Lookup', iconType: 'FA', icon: faSearch, link: '/lnd/lookups', userPersona: UserPersonaEnum.ALL}
{id: 33, parentId: 3, name: 'Routing', iconType: 'FA', icon: faMapSigns, link: '/lnd/routing', userPersona: UserPersonaEnum.ALL},
{id: 34, parentId: 3, name: 'Graph Lookup', iconType: 'FA', icon: faSearch, link: '/lnd/lookups', userPersona: UserPersonaEnum.ALL},
{id: 35, parentId: 3, name: 'Backup', iconType: 'FA', icon: faDownload, link: '/lnd/backup', userPersona: UserPersonaEnum.ALL}
]},
{id: 5, parentId: 0, name: 'Network', iconType: 'FA', icon: faProjectDiagram, link: '/lnd/network', userPersona: UserPersonaEnum.OPERATOR},
{id: 6, parentId: 0, name: 'Node/Network', iconType: 'FA', icon: faServer, link: '/lnd/network', userPersona: UserPersonaEnum.MERCHANT},

@ -286,10 +286,11 @@ export class RTLEffects implements OnDestroy {
this.logger.info('Successfully Authorized!');
this.SetToken(postRes.token);
rootStore.selNode.settings.currencyUnits = [...CURRENCY_UNITS, rootStore.selNode.settings.currencyUnit];
this.store.dispatch(new RTLActions.SetSelelectedNode({lnNode: rootStore.selNode, isInitialSetup: true}))
if(action.payload.initialPass) {
this.store.dispatch(new RTLActions.OpenSnackBar('Reset your password.'));
this.router.navigate(['/settings'], { state: { loadTab: 'authSettings' }});
this.router.navigate(['/settings'], { state: { loadTab: 'authSettings', initializeNodeData: true }});
} else {
this.store.dispatch(new RTLActions.SetSelelectedNode({lnNode: rootStore.selNode, isInitialSetup: true}));
}
}),
catchError((err) => {

@ -1 +1 @@
export const VERSION = '0.6.4-beta';
export const VERSION = '0.6.4-beta-rc2';
Loading…
Cancel
Save