Commit 9099548f authored by Sourabh_roy's avatar Sourabh_roy
Browse files

osdu eds first code push

parent 2501f058
Pipeline #53559 passed with stages
in 20 seconds
......@@ -40,6 +40,10 @@ export class AuthService {
public logout_uri="";
public tennant_id="";
httpOptions_token={};
public eds_acl={};
public eds_legal={};
public eds_payload={};
public eds_workflow_host="";
constructor(private router: Router, private http: HttpClient,public cmnSrv:CommonService) {
console.log("inside auth",router.url);
this.userSubject = new BehaviorSubject<User>(null);
......@@ -76,7 +80,10 @@ export class AuthService {
}),
};
this.eds_acl=AppConfig.settings.eds.acl;
this.eds_legal=AppConfig.settings.eds.legal;
this.eds_payload=AppConfig.settings.eds.Payload;
this.eds_workflow_host=AppConfig.settings.common.eds_workflow_host;
this.check_code();
}
......
......@@ -25,6 +25,7 @@ export class RestAPILayerService {
search_host=AppConfig.settings.common.search_host;
storage_host=AppConfig.settings.common.storage_host;
workflow_host=AppConfig.settings.common.workflow_host;
eds_workflow_host=this.auth.eds_workflow_host;
access_token=this.auth.getTokenSession();
authorization = this.auth.authorization;
data_partition=this.auth.data_partition;
......@@ -419,4 +420,41 @@ getConnectionSourceDataJob(data){
catchError(this.auth.errorHandler<any>('addProduct',errorData))
);
}
postConnectionSourceRegistry(data){
this.param = 'workflow/Osdu_ingest/workflowRun'
let errorData={
'api':this.param,
}
return this.http.post<any>(this.workflow_endpoint_url +this.eds_workflow_host+ this.param,data, this.httpOptions).pipe(
map(this.extractData),
catchError(this.auth.errorHandler<any>('addProduct',errorData))
);
}
getSchemeType(data){
this.param = 'query'
let errorData={
'api':this.param,
}
return this.http.post<any>(this.search_endpoint_url +this.search_host+ this.param,data, this.httpOptions).pipe(
map(this.extractData),
catchError(this.auth.errorHandler<any>('addProduct',errorData))
);
}
getFlowType(data){
this.param = 'query'
let errorData={
'api':this.param,
}
return this.http.post<any>(this.search_endpoint_url +this.search_host+ this.param,data, this.httpOptions).pipe(
map(this.extractData),
catchError(this.auth.errorHandler<any>('addProduct',errorData))
);
}
}
......@@ -80,9 +80,17 @@ headersList=[];
}
}, (err) => {
this.spinner.hide();
this.isAuthorized=false;
this.errorMessage=err;
this.spinner.hide();
if(err.error != undefined){
this.errorMessage=err.error;
}
else{
this.errorMessage=err;
}
console.log(err);
});
......
......@@ -79,15 +79,19 @@ export class ManageGroupsComponent implements OnInit {
getEntitlements(){
this.spinner.show();
this.restService.getEntitlementGroups().subscribe((result) => {
// console.log(result)
this.spinner.hide();
this.error_Message_Div='';
this.UserList=result.groups;
this.fullUserList=result.groups;
this.cmnSrvc.EandOgroupEmailList=result.groups.map(x=>x.email);
if(result.groups.length>0){
this.cmnSrvc.EandOgroupEmailList=result.groups.map(x=>x.email);
this.headers=Object.keys(result.groups[0]);
this.istoggle=false;
this.sort('email');
this.spinner.hide();
}
}, (err) => {
this.spinner.hide();
......
table{
margin: 0 auto;
}
select.form-control {
width: 235px;
}
input, input[type="text"], input[type="password"], input[type="email"], input[type="number"], textarea, select {
margin: 4px 0 5px 0;
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
<div class="modal-header" style=" padding: 4px 20px;" id="videoTitle">
<h4 class="modal-title" id="videoTitle1" style="width: 100%;">
Authorization Profile
Security Scheme
<button style="float: right;"
type="button"
(click)="closePopup()"
......@@ -17,12 +17,12 @@
<div class="modal-body" style=" height: auto;">
<form #myForm id="myForm">
<table>
<tr>
<td>
<label> Authorization Profile Name:&nbsp; </label>
<tr >
<td style=" width: 44.5%;">
<label> Security Scheme Name:&nbsp; </label>
</td>
<td>
<input type="text" placeholder="Authorization Profile Name" [(ngModel)]="ngAuthProfileName" name="txtAccLabel">
<input type="text" placeholder="Security Scheme Name" [(ngModel)]="ngAuthProfileName" name="ngAuthProfileName">
</td>
</tr>
<tr>
......@@ -30,9 +30,9 @@
<label>OAuth Grant Type: </label>
</td>
<td>
<select class="form-control" [(ngModel)]="ngAuthType" (change)="onAuthTypeChange($event.target.value)" name="ngParameters">
<option value="0" disabled="disabled" selected="selected">OAuth Grant Type</option>
<option value="{{type}}" *ngFor="let type of grantTypes">{{type}}</option>
<select class="form-control" [(ngModel)]="ngAuthType" (change)="onAuthTypeChange($event.target.value)" name="ngAuthType">
<option value="0" disabled="disabled" selected="selected">Scheme Type</option>
<option value="{{type.id}}" *ngFor="let type of schemetype_list">{{type.data.Name}}</option>
</select>
</td>
</tr>
......@@ -64,64 +64,93 @@
</table>
<table *ngIf="isAuthTypeSelected && isAuthType">
<tr>
<td style=" width: 45%;">
<td style=" width: 44.5%;">
<label>Flow: </label>
</td>
<td>
<input type="text" placeholder="Flow" [(ngModel)]="ngFlow" name="ngFlow">
<select class="form-control" [(ngModel)]="ngFlow" (change)="onFlowChange($event.target.value)" name="ngFlow">
<option value="0" disabled="disabled" selected="selected">Flow Type &nbsp;&nbsp;&nbsp;&nbsp;</option>
<option value="{{type.id}}" *ngFor="let type of flowtype_list">{{type.data.Name}}</option>
</select>
</td>
</tr>
<tr>
<tr *ngIf="isFlowTypeSelected && isFlowAuthCode && !isFlowPassword">
<td >
<label>Callback Url: </label>
</td>
<td>
<input type="text" placeholder="Callback Url" [(ngModel)]="ngCallbackUrl" name="txtAccName">
<input type="text" placeholder="Callback Url" [(ngModel)]="ngCallbackUrl" name="ngCallbackUrl">
</td>
</tr>
<tr>
<tr *ngIf="isFlowTypeSelected && isFlowAuthCode && !isFlowPassword">
<td>
<label>Authorization URL: </label>
</td>
<td>
<input type="text" placeholder="Authorization URL" [(ngModel)]="ngAuthEndpoints" name="txtSecretManKey">
<input type="text" placeholder="Authorization URL" [(ngModel)]="ngAuthEndpoints" name="ngAuthEndpoints">
</td>
</tr>
<tr>
<tr *ngIf="isFlowTypeSelected">
<td>
<label>Token URL: </label>
</td>
<td>
<input type="text" placeholder="Token URL" [(ngModel)]="ngTokenEndpoints" name="txtSecretManKey">
<input type="text" placeholder="Token URL" [(ngModel)]="ngTokenEndpoints" name="ngTokenEndpoints">
</td>
</tr>
<tr>
<tr *ngIf="isFlowTypeSelected">
<td>
<label>Client Id: </label>
</td>
<td>
<input type="text" placeholder="Client Id" [(ngModel)]="ngClientId" name="txtSecretManKey">
<input type="text" placeholder="Client Id" [(ngModel)]="ngClientId" name="ngClientId">
</td>
</tr>
<tr>
<tr *ngIf="isFlowTypeSelected">
<td>
<label>Client Secret: </label>
</td>
<td>
<input type="text" placeholder="Token Endpoint" [(ngModel)]="ngClientSecret" name="txtSecretManKey">
<input type="text" placeholder="Client Secret" [(ngModel)]="ngClientSecret" name="ngClientSecret">
</td>
</tr>
<tr>
</tr >
<tr *ngIf="isFlowTypeSelected">
<td>
<label>Scopes: </label>
</td>
<td>
<select class="form-control" [(ngModel)]="ngScope" name="ngParameters">
<option value="0" selected="selected">Scopes</option>
<option value="{{type}}" *ngFor="let type of grantTypes">{{type}}</option>
</select>
<input type="text" placeholder="Scopes" [(ngModel)]="ngScope" name="ngScope">
</td>
</tr>
<tr *ngIf="isFlowTypeSelected && isFlowPassword">
<td>
<label>Username: </label>
</td>
<td>
<input type="text" placeholder="Username" [(ngModel)]="ngUsername" name="ngUsername">
</td>
</tr>
<tr *ngIf="isFlowTypeSelected && isFlowPassword">
<td>
<label>Password: </label>
</td>
<td>
<input type="password" placeholder="Password" [(ngModel)]="ngPassword" name="ngPassword">
</td>
</tr>
<tr *ngIf="isFlowTypeSelected && !isFlowAuthCode && !isFlowPassword">
<td>
<label>Audience: </label>
</td>
<td>
<input type="text" placeholder="Audience" [(ngModel)]="ngAudience" name="ngAudience">
</td>
</tr>
</table>
<table>
</table>
<table *ngIf="isAuthTypeSelected && isBearerToken">
<tr>
......@@ -171,6 +200,7 @@
</tr>
</table>
</form>
<br/>
<div style="text-align: center;">
<p *ngIf="isSuccess" style="color:green"> {{successMessge}}</p>
<p *ngIf="isError" style="color:red"> {{errorMessge}}</p>
......
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { NgxSpinnerService } from 'ngx-spinner';
import { AuthService } from 'src/app/common/Authentication/auth.service';
import { CommonService } from 'src/app/common/common.service';
import { RestAPILayerService } from 'src/app/common/rest-apilayer.service';
import {grantTypes,scope} from '../../../config';
import {grantTypes,scope,OAuth_flow} from '../../../config';
import { KeyValue } from '@angular/common';
@Component({
selector: 'app-add-service-acc',
......@@ -12,13 +14,17 @@ import {grantTypes,scope} from '../../../config';
})
export class AddServiceAccComponent implements OnInit {
originalOrder = (a: KeyValue<number,string>, b: KeyValue<number,string>): number => {
return 0;
}
@Output() passEntry: EventEmitter<any> = new EventEmitter();
ServiceDetails;
isSuccess:boolean=false;
isError:boolean=false;
successMessge='';
errorMessge='';
txtAccLabel='';
ngAuthProfileName='';
// txtAccAuthType='';
txtAccName='';
txtSecretManKey='';
......@@ -26,39 +32,101 @@ export class AddServiceAccComponent implements OnInit {
Type;
btnLabel='';
grantTypes=grantTypes;
schemetype_list=[];
flowtype_list=[];
scope=scope;
OAuth_flow=OAuth_flow;
ngAuthProfileName;
// ngAuthProfileName;
ngAuthType='0';
ngCallbackUrl;
ngAuthEndpoints;
ngTokenEndpoints;
ngClientId;
ngClientSecret;
ngScope='0';
ngFlow;
ngScope='';
ngFlow='0';
ngSecretRepoUrl;
ngAccToken;
ngAPIKey;
ngAudience;
ngUsername;
ngPassword;
isAuthType:boolean;
isBearerToken:boolean;
isAPIKey:boolean;
isAuthTypeSelected:boolean=false;
isFlowTypeSelected:boolean=false;
isFlowAuthCode:boolean;
isFlowPassword:boolean;
kind_value_schema: any;
kind_value_flow:any;
constructor(public activeModal: NgbActiveModal,public cmnSrvc: CommonService, private spinner: NgxSpinnerService,public restService:RestAPILayerService,) { }
constructor(public activeModal: NgbActiveModal,private auth:AuthService, public cmnSrvc: CommonService, private spinner: NgxSpinnerService,public restService:RestAPILayerService,) { }
ngOnInit(): void {
this.kind_value_schema= this.auth.data_partition+":wks:reference-data--SecuritySchemeType:*";
this.kind_value_flow=this.auth.data_partition+":wks:reference-data--OAuth2FlowType:*"
if(this.Type=='add'){
this.btnLabel="Add"
}
else{
this.btnLabel="Save";
this.txtAccLabel=this.ServiceDetails.ServiceAccountName;
this.ngAuthProfileName=this.ServiceDetails.Name;
this.txtAccName=this.ServiceDetails.AccountName;
this.txtSecretManKey=this.ServiceDetails.SecretManagerKey;
this.txtAuthEndpoint=this.ServiceDetails.TokenURL;
this.ngSecretRepoUrl=this.ServiceDetails.SecretRepoUrl;
}
this.getAuthType();
}
getAuthType(){
this.spinner.show();
const data={
"kind": this.kind_value_schema
}
this.restService.getSchemeType(data).subscribe((result) => {
this.getFlowType();
this.spinner.hide();
this.schemetype_list=result["results"];
if(this.Type != 'add'){
this.ngAuthType=this.ServiceDetails.Type.slice(0,-1);
this.onAuthTypeChange(this.ServiceDetails.Type.slice(0,-1))
}
}, (err) => {
this.spinner.hide();
console.log(err);
});
}
getFlowType(){
this.spinner.show();
const data={
"kind": this.kind_value_flow
}
this.restService.getFlowType(data).subscribe((result) => {
this.spinner.hide();
// console.log(result)
this.flowtype_list=result["results"];
if(this.Type != 'add'){
this.ngFlow=this.ServiceDetails.Flow.slice(0,-1);
this.onFlowChange(this.ngFlow);
}
}, (err) => {
this.spinner.hide();
console.log(err);
});
}
closePopup(){
......@@ -68,33 +136,66 @@ export class AddServiceAccComponent implements OnInit {
onAuthTypeChange(val){
this.isAuthTypeSelected=true;
if(val != 0){
if(val=="OAuth2"){
if(val.includes("OAuth2")){
this.isAuthType=true;
this.isBearerToken=false;
this.isAPIKey=false;
}
else if(val=="Bearer Token"){
else if(val.includes("Bearer")){
this.isAuthType=false;
this.isBearerToken=true;
this.isAPIKey=false;
}
else if(val=="API Key"){
this.isAuthType=false;
this.isBearerToken=false;
this.isAPIKey=true;
}
// else if(val=="API Key"){
// this.isAuthType=false;
// this.isBearerToken=false;
// this.isAPIKey=true;
// }
}
}
requestSubmit(){
let count=0;
for (let element in this) {
if (element.includes('txt')) {
if (this[element].toString() === "") {
count += 1;
}
onFlowChange(val){
this.isFlowTypeSelected=true;
if(val.includes("AuthorizationCode")){
this.isFlowAuthCode=true;
this.isFlowPassword=false;
if(this.Type !='add'){
// this.ngCallbackUrl=this.ServiceDetails
}
}
else if(val.includes("PasswordCredentials")){
this.isFlowPassword=true;
if(this.Type !='add'){
}
}
else{
this.isFlowAuthCode=false;
this.isFlowPassword=false;
}
if(this.Type !='add'){
this.ngClientId=this.ServiceDetails["ClientID"];
this.ngClientSecret=this.ServiceDetails["ClientSecretKey"];
this.ngScope=this.ServiceDetails["ScopesKey"];
this.ngAuthEndpoints=this.ServiceDetails["AuthorizationUrl"];
this.ngCallbackUrl=this.ServiceDetails["CallbackUrl"];
this.ngTokenEndpoints=this.ServiceDetails["TokenUrl"];
this.ngUsername=this.ServiceDetails["UsernameKey"];
this.ngPassword=this.ServiceDetails["PasswordKey"];
}
}
requestSubmit(){
let count=0;
// for (let element in this) {
// if (element.includes('txt')) {
// if (this[element].toString() === "") {
// count += 1;
// }
// }
// }
if(count>0){
this.isError=true;
......@@ -103,29 +204,93 @@ export class AddServiceAccComponent implements OnInit {
}
else{
this.isError=false;
this.isSuccess=true;
if(this.Type=='add'){
this.successMessge="Service Account has been created successfully.";
const data={
"ServiceAccountName":this.txtAccLabel,
// "AuthType":this.txtAuthEndpoint,
"AccName":this.txtAccName,
"SecManKey":this.txtSecretManKey,
"SerEndpoint":this.txtAuthEndpoint
this.isSuccess=true;let dataparams={};
if(this.ngAuthType.includes("OAuth2")){
if(this.ngFlow.includes("AuthorizationCode")){
dataparams={
"Name":this.ngAuthProfileName,
"Type":this.ngAuthType+':',
"Flow":this.ngFlow+':',
"ScopesKey":this.ngAuthProfileName+'_Scopes',
"ClientID":this.ngClientId,
"ClientSecretKey":this.ngAuthProfileName+'_ClientSecret',
"SecretRepoUrl":this.ngSecretRepoUrl,
"CallbackUrl":this.ngCallbackUrl,
"AuthorizationUrl":this.ngAuthEndpoints,
"TokenUrl":this.ngTokenEndpoints
}
}
else if(this.ngFlow.includes("PasswordCredentials")){
dataparams={
"Name":this.ngAuthProfileName,
"Type":this.ngAuthType+':',
"Flow":this.ngFlow+':',
"ScopesKey":this.ngAuthProfileName+'_Scopes',
"ClientID":this.ngClientId,
"ClientSecretKey":this.ngAuthProfileName+'_ClientSecret',
"UsernameKey":this.ngAuthProfileName+'_Username',
"PasswordKey":this.ngAuthProfileName+'_Password',
"SecretRepoUrl":this.ngSecretRepoUrl,
"TokenUrl":this.ngTokenEndpoints
}
}
else{
dataparams={
"Name":this.ngAuthProfileName,
"Type":this.ngAuthType+':',
"Flow":this.ngFlow+':',
"ScopesKey":this.ngAuthProfileName+'_Scopes',
"ClientID":this.ngClientId,
"ClientSecretKey":this.ngAuthProfileName+'_ClientSecret',
"SecretRepoUrl":this.ngSecretRepoUrl,
"TokenUrl":this.ngTokenEndpoints,
"Audience":this.ngAudience
}
}
}
else if(this.ngAuthType.includes("Bearer")){
<