add oidc form login

This commit is contained in:
_Bastler 2022-12-27 20:41:59 +01:00
parent 92a74e72f9
commit 31af132d13
5 changed files with 288 additions and 342 deletions

534
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "we-bstly-angular",
"version": "2.1.0",
"version": "2.1.1",
"scripts": {
"ng": "ng",
"start": "ng serve",
@ -13,35 +13,35 @@
"dependencies": {
"@angular-material-components/datetime-picker": "^9.0.0",
"@angular-material-components/moment-adapter": "^9.0.0",
"@angular/animations": "^15.0.3",
"@angular/cdk": "^15.0.2",
"@angular/common": "^15.0.3",
"@angular/compiler": "^15.0.3",
"@angular/core": "^15.0.3",
"@angular/forms": "^15.0.3",
"@angular/material": "^15.0.2",
"@angular/material-moment-adapter": "^15.0.2",
"@angular/platform-browser": "^15.0.3",
"@angular/platform-browser-dynamic": "^15.0.3",
"@angular/router": "^15.0.3",
"@angular/animations": "^15.0.4",
"@angular/cdk": "^15.0.3",
"@angular/common": "^15.0.4",
"@angular/compiler": "^15.0.4",
"@angular/core": "^15.0.4",
"@angular/forms": "^15.0.4",
"@angular/material": "^15.0.3",
"@angular/material-moment-adapter": "^15.0.3",
"@angular/platform-browser": "^15.0.4",
"@angular/platform-browser-dynamic": "^15.0.4",
"@angular/router": "^15.0.4",
"moment": "^2.29.4",
"ng-qrcode": "^8.0.1",
"ngx-mat-timepicker": "^15.1.2",
"openpgp": "^5.5.0",
"qr-scanner": "^1.4.2",
"rxjs": "~7.6.0",
"rxjs": "~7.8.0",
"tslib": "^2.4.1",
"unique-names-generator": "^4.7.1",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.0.3",
"@angular/cli": "^15.0.3",
"@angular/compiler-cli": "^15.0.3",
"@angular/localize": "^15.0.3",
"@angular-devkit/build-angular": "^15.0.4",
"@angular/cli": "^15.0.4",
"@angular/compiler-cli": "^15.0.4",
"@angular/localize": "^15.0.4",
"@types/jasmine": "^4.3.1",
"@types/jasminewd2": "^2.0.10",
"@types/node": "^18.11.12",
"@types/node": "^18.11.16",
"@types/openpgp": "^4.4.18",
"jasmine-core": "~4.5.0",
"jasmine-spec-reporter": "~7.0.0",

View File

@ -1,31 +1,38 @@
<form [formGroup]="form" action="{{apiUrl}}/oidc/authorize" method="POST">
<form [formGroup]="form" action="{{apiUrl}}/oidc/authorize" method="POST" #odicLoginForm>
<mat-card>
<mat-card-content>
<h2>{{'security.oidc.login' | i18n}}</h2>
<h2>{{'security.oidc' | i18n}}</h2>
<mat-error *ngIf="loginInvalid">
{{'security.oidc.login.invalid' | i18n}}
</mat-error>
<input id="code" name="code" type="hidden" formControlName="code" required>
<input id="state" name="state" type="hidden" formControlName="state" required>
<input id="client_id" name="client_id" type="hidden" formControlName="client_id" required>
<input id="responseType" name="responseType" type="hidden" formControlName="responseType" required>
<input id="redirectUri" name="redirectUri" type="hidden" formControlName="redirectUri" required>
<input id="response_type" name="response_type" type="hidden" formControlName="response_type" required>
<input id="redirect_uri" name="redirect_uri" type="hidden" formControlName="redirect_uri" required>
<input id="scope" name="scope" type="hidden" formControlName="scope" required>
<input id="nonce" name="nonce" type="hidden" formControlName="nonce">
<input id="prompt" name="prompt" type="hidden" formControlName="prompt">
<input id="login_hint" name="login_hint" type="hidden" formControlName="login_hint">
<mat-list>
<mat-list-item (click)="setAlias('')">{{'username'}}</mat-list-item>
<ng-container *ngIf="authorize">
<h3>{{'security.oidc.authorize' | i18n}}</h3>
<p>{{'security.oidc.authorize.hint' | i18n}}</p>
</ng-container>
<ng-container *ngIf="alias">
<h3>{{'security.oidc.alias' | i18n}}</h3>
<mat-nav-list>
<mat-list-item (click)="setAlias('')"
[ngClass]="{'active' : !selectedAlias || selectedAlias == ''}">{{auth.name}}</mat-list-item>
<mat-list-item *ngFor="let userAlias of aliases" (click)="setAlias(userAlias.alias)"
[activated]="userAlias.alias == selectedAlias">{{userAlias.alias}}</mat-list-item>
</mat-list>
[ngClass]="{'active' : selectedAlias == userAlias.alias}">{{userAlias.alias}}</mat-list-item>
</mat-nav-list>
</ng-container>
</mat-card-content>
<mat-card-actions>
<a type="submit" mat-raised-button color="primary" [disabled]="form.invalid">{{'security.oidc.login' |
i18n}}</a>
<button type="submit" mat-raised-button color="primary" [disabled]="form.invalid"
(click)="odicLoginForm.submit()">{{'security.oidc.login' |
i18n}}</button>
</mat-card-actions>
</mat-card>
</form>

View File

@ -1,3 +1,9 @@
mat-form-field {
display: block;
}
mat-list-item {
&.active {
background-color: #cccccc;
}
}

View File

@ -23,8 +23,15 @@ export class FormLoginOidcComponent implements OnInit {
alias: boolean = false;
aliases: any[] = [];
selectedAlias: any;
auth;
constructor(private formBuilder: FormBuilder, private authService: AuthService, private userAliasService: UserAliasService, private router: Router, private route: ActivatedRoute, private location: Location) { }
constructor(private formBuilder: FormBuilder, private authService: AuthService, private userAliasService: UserAliasService, private router: Router, private route: ActivatedRoute, private location: Location) {
this.authService.auth.subscribe({
next: (data) => {
this.auth = data;
}
})
}
ngOnInit() {
@ -32,8 +39,8 @@ export class FormLoginOidcComponent implements OnInit {
code: ['', Validators.required],
state: ['', Validators.required],
client_id: ['', Validators.required],
responseType: ['', Validators.required],
redirectUri: ['', Validators.required],
response_type: ['', Validators.required],
redirect_uri: ['', Validators.required],
scope: ['', Validators.required],
nonce: [''],
prompt: [''],
@ -52,11 +59,11 @@ export class FormLoginOidcComponent implements OnInit {
if (params['client_id']) {
this.form.get('client_id').setValue(params['client_id']);
}
if (params['responseType']) {
this.form.get('responseType').setValue(params['responseType']);
if (params['response_type']) {
this.form.get('response_type').setValue(params['response_type']);
}
if (params['redirectUri']) {
this.form.get('redirectUri').setValue(params['redirectUri']);
if (params['redirect_uri']) {
this.form.get('redirect_uri').setValue(params['redirect_uri']);
}
if (params['scope']) {
this.form.get('scope').setValue(params['scope']);