-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added authorization provider functionality
- Loading branch information
Showing
56 changed files
with
1,111 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
// root: true, | ||
extends: ['altair'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
"prettier-config-altair" | ||
{ | ||
"semi": true, | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"overrides": [ | ||
{ | ||
"files": "tsconfig.json", | ||
"options": { | ||
"trailingComma": "none" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../altair/components/authorization/authorization-apikey/authorization-apikey.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<form nz-form nzLayout="vertical" [formGroup]="apiKeyForm"> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="key">Key</nz-form-label> | ||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="The input is not a valid key!"> | ||
<input nz-input formControlName="key" id="key" class="app-input" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="value">Value</nz-form-label> | ||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="The input is not a valid value!"> | ||
<input nz-input formControlName="value" id="value" class="app-input" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
</form> |
23 changes: 23 additions & 0 deletions
23
...tair/components/authorization/authorization-apikey/authorization-apikey.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AuthorizationApikeyComponent } from './authorization-apikey.component'; | ||
|
||
describe('AuthorizationApikeyComponent', () => { | ||
let component: AuthorizationApikeyComponent; | ||
let fixture: ComponentFixture<AuthorizationApikeyComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AuthorizationApikeyComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AuthorizationApikeyComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
...es/altair/components/authorization/authorization-apikey/authorization-apikey.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component, Input, OnInit, Output } from '@angular/core'; | ||
import { NonNullableFormBuilder } from '@angular/forms'; | ||
import { SharedModule } from 'app/modules/altair/modules/shared/shared.module'; | ||
|
||
@Component({ | ||
selector: 'app-authorization-apikey', | ||
standalone: true, | ||
imports: [SharedModule], | ||
templateUrl: './authorization-apikey.component.html', | ||
styles: ``, | ||
}) | ||
export class AuthorizationApikeyComponent implements OnInit { | ||
apiKeyForm = this.formBuilder.group({ | ||
key: '', | ||
value: '', | ||
}); | ||
@Input() authData?: unknown; | ||
@Output() authDataChange = this.apiKeyForm.valueChanges; | ||
|
||
constructor(private readonly formBuilder: NonNullableFormBuilder) {} | ||
|
||
ngOnInit(): void { | ||
if (this.authData) { | ||
this.apiKeyForm.patchValue(this.authData); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...es/altair/components/authorization/authorization-basic/authorization-basic.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<form nz-form nzLayout="vertical" [formGroup]="basicForm"> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="username">Username</nz-form-label> | ||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="The input is not a valid username!"> | ||
<input nz-input formControlName="username" id="username" class="app-input" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="password">Password</nz-form-label> | ||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="The input is not a valid password!"> | ||
<input nz-input formControlName="password" id="password" class="app-input" type="password" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
</form> |
23 changes: 23 additions & 0 deletions
23
...altair/components/authorization/authorization-basic/authorization-basic.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AuthorizationBasicComponent } from './authorization-basic.component'; | ||
|
||
describe('AuthorizationBasicComponent', () => { | ||
let component: AuthorizationBasicComponent; | ||
let fixture: ComponentFixture<AuthorizationBasicComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AuthorizationBasicComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AuthorizationBasicComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
...ules/altair/components/authorization/authorization-basic/authorization-basic.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component, Input, OnInit, Output } from '@angular/core'; | ||
import { NonNullableFormBuilder } from '@angular/forms'; | ||
import { SharedModule } from 'app/modules/altair/modules/shared/shared.module'; | ||
|
||
@Component({ | ||
selector: 'app-authorization-basic', | ||
standalone: true, | ||
imports: [SharedModule], | ||
templateUrl: './authorization-basic.component.html', | ||
styles: ``, | ||
}) | ||
export class AuthorizationBasicComponent implements OnInit { | ||
basicForm = this.formBuilder.group({ | ||
username: '', | ||
password: '', | ||
}); | ||
@Input() authData?: unknown; | ||
@Output() authDataChange = this.basicForm.valueChanges; | ||
|
||
constructor(private readonly formBuilder: NonNullableFormBuilder) {} | ||
|
||
ngOnInit(): void { | ||
if (this.authData) { | ||
this.basicForm.patchValue(this.authData); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../altair/components/authorization/authorization-bearer/authorization-bearer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<form nz-form nzLayout="vertical" [formGroup]="bearerForm"> | ||
<nz-form-item> | ||
<nz-form-label nzRequired nzFor="token">Bearer token</nz-form-label> | ||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="The input is not a valid bearer token!"> | ||
<input nz-input formControlName="token" id="token" class="app-input" /> | ||
</nz-form-control> | ||
</nz-form-item> | ||
</form> |
23 changes: 23 additions & 0 deletions
23
...tair/components/authorization/authorization-bearer/authorization-bearer.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AuthorizationBearerComponent } from './authorization-bearer.component'; | ||
|
||
describe('AuthorizationBearerComponent', () => { | ||
let component: AuthorizationBearerComponent; | ||
let fixture: ComponentFixture<AuthorizationBearerComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AuthorizationBearerComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AuthorizationBearerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
...es/altair/components/authorization/authorization-bearer/authorization-bearer.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component, Input, OnInit, Output } from '@angular/core'; | ||
import { NonNullableFormBuilder } from '@angular/forms'; | ||
import { SharedModule } from 'app/modules/altair/modules/shared/shared.module'; | ||
|
||
@Component({ | ||
selector: 'app-authorization-bearer', | ||
standalone: true, | ||
imports: [SharedModule], | ||
templateUrl: './authorization-bearer.component.html', | ||
styles: ``, | ||
}) | ||
export class AuthorizationBearerComponent implements OnInit { | ||
bearerForm = this.formBuilder.group({ | ||
token: '', | ||
}); | ||
@Input() authData?: unknown; | ||
@Output() authDataChange = this.bearerForm.valueChanges; | ||
|
||
constructor(private readonly formBuilder: NonNullableFormBuilder) {} | ||
|
||
ngOnInit(): void { | ||
if (this.authData) { | ||
this.bearerForm.patchValue(this.authData); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../altair/components/authorization/authorization-editor/authorization-editor.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<form nz-form nzLayout="vertical" [formGroup]="typeForm"> | ||
<nz-form-item> | ||
<nz-form-label>{{ 'AUTHORIZATION_TYPE_TEXT' | translate }}</nz-form-label> | ||
<nz-form-control [nzSm]="6" nzErrorTip="The input is not a valid type!"> | ||
<nz-select formControlName="type"> | ||
@for (item of AUTH_TYPES; track $index) { | ||
<nz-option [nzValue]="item" [nzLabel]="AUTH_MAPPING[item].copy | translate"></nz-option> | ||
} | ||
</nz-select> | ||
</nz-form-control> | ||
</nz-form-item> | ||
</form> | ||
@switch (typeForm.controls.type.value) { | ||
@case ('api-key') { | ||
<app-authorization-apikey | ||
[authData]="authorizationState?.data" | ||
(authDataChange)="authDataChange.emit($event)" | ||
/> | ||
} | ||
@case ('basic') { | ||
<app-authorization-basic | ||
[authData]="authorizationState?.data" | ||
(authDataChange)="authDataChange.emit($event)" | ||
/> | ||
} | ||
@case ('bearer') { | ||
<app-authorization-bearer | ||
[authData]="authorizationState?.data" | ||
(authDataChange)="authDataChange.emit($event)" | ||
/> | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...tair/components/authorization/authorization-editor/authorization-editor.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AuthorizationEditorComponent } from './authorization-editor.component'; | ||
|
||
describe('AuthorizationEditorComponent', () => { | ||
let component: AuthorizationEditorComponent; | ||
let fixture: ComponentFixture<AuthorizationEditorComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AuthorizationEditorComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AuthorizationEditorComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
...es/altair/components/authorization/authorization-editor/authorization-editor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { NonNullableFormBuilder } from '@angular/forms'; | ||
import { | ||
AUTHORIZATION_TYPES, | ||
AUTHORIZATION_TYPE_LIST, | ||
AuthorizationState, | ||
AuthorizationTypes, | ||
DEFAULT_AUTHORIZATION_TYPE, | ||
} from 'altair-graphql-core/build/types/state/authorization.interface'; | ||
import { distinctUntilChanged, map } from 'rxjs/operators'; | ||
import { AUTHORIZATION_MAPPING } from '../authorizations'; | ||
|
||
@Component({ | ||
selector: 'app-authorization-editor', | ||
templateUrl: './authorization-editor.component.html', | ||
styles: ``, | ||
}) | ||
export class AuthorizationEditorComponent implements OnInit { | ||
typeForm = this.formBuilder.group<{ | ||
type: AuthorizationTypes; | ||
}>({ | ||
type: DEFAULT_AUTHORIZATION_TYPE, | ||
}); | ||
|
||
@Input() authorizationState?: AuthorizationState; | ||
@Output() authTypeChange = this.typeForm.valueChanges.pipe( | ||
map(({ type }) => type ?? DEFAULT_AUTHORIZATION_TYPE), | ||
distinctUntilChanged() | ||
); | ||
@Output() authDataChange = new EventEmitter(); | ||
AUTH_MAPPING = AUTHORIZATION_MAPPING; | ||
AUTH_TYPES = AUTHORIZATION_TYPE_LIST; | ||
|
||
constructor(private readonly formBuilder: NonNullableFormBuilder) {} | ||
|
||
ngOnInit(): void { | ||
if (this.authorizationState) { | ||
this.typeForm.patchValue({ | ||
type: this.authorizationState.type, | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.