Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support github custom ingester #792

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ <h2 class="margin-bottom__12px">Configure API Key</h2>
</div>
</section>

<section class="card padding-all__24px margin-top__24px" *ngIf="sourceForm.value.verifier.type === 'hmac'" formGroupName="hmac">
<h2 class="margin-bottom__12px">Configure HMAC</h2>
<section class="card padding-all__24px margin-top__24px" *ngIf="sourceForm.value.verifier.type === 'hmac' || sourceForm.value.verifier.type === 'github'" formGroupName="hmac">
<h2 class="margin-bottom__12px">{{ sourceForm.value.verifier.type === 'github' ? 'Github Credentials' : 'Configure HMAC' }}</h2>

<div class="grid grid__col-2 grid--gap__24px">
<div class="input margin-bottom__0px">
<div class="input margin-bottom__0px" *ngIf="sourceForm.value.verifier.type === 'hmac'">
<label for="encoding" class="position__relative">
Encoding
<span class="bg__grey__light rounded__4px padding-x__4px position__absolute position--right__0px font__10px font__weight-400">required</span>
Expand All @@ -98,7 +98,7 @@ <h2 class="margin-bottom__12px">Configure HMAC</h2>
</div>
</div>

<div class="input margin-bottom__0px">
<div class="input margin-bottom__0px" *ngIf="sourceForm.value.verifier.type === 'hmac'">
<label for="algorithm" class="position__relative">
Hash Algorithm
<span class="bg__grey__light rounded__4px padding-x__4px position__absolute position--right__0px font__10px font__weight-400">required</span>
Expand All @@ -112,7 +112,7 @@ <h2 class="margin-bottom__12px">Configure HMAC</h2>
</div>
</div>

<div class="input margin-bottom__0px">
<div class="input margin-bottom__0px" *ngIf="sourceForm.value.verifier.type === 'hmac'">
<label for="header-key" class="position__relative">
Signature header key
<span class="bg__grey__light rounded__4px padding-x__4px position__absolute position--right__0px font__10px font__weight-400">required</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export class CreateSourceComponent implements OnInit {
httpTypes = [
{ value: 'hmac', viewValue: 'HMAC' },
{ value: 'basic_auth', viewValue: 'Basic Auth' },
{ value: 'api_key', viewValue: 'API Key' }
{ value: 'api_key', viewValue: 'API Key' },
{ value: 'github', viewValue: 'Github' }
];
encodings = ['base64', 'hex'];
hashAlgorithms = ['SHA256', 'SHA512', 'MD5', 'SHA1', 'SHA224', 'SHA384', 'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512', 'SHA512_256', 'SHA512_224'];
Expand All @@ -65,13 +66,16 @@ export class CreateSourceComponent implements OnInit {
}

async saveSource() {
const verifier = this.sourceForm.get('verifier.type')?.value === 'github' ? 'hmac' : this.sourceForm.get('verifier.type')?.value;
if (this.sourceForm.get('verifier.type')?.value === 'github') this.sourceForm.get('verifier.hmac')?.patchValue({ encoding: 'hex', header: 'X-Hub-Signature-256', hash: 'SHA256' });
if (!this.isSourceFormValid()) return this.sourceForm.markAllAsTouched();

const sourceData = {
...this.sourceForm.value,
provider: this.sourceForm.get('verifier.type')?.value === 'github' ? 'github' : '',
verifier: {
type: this.sourceForm.get('verifier.type')?.value,
[this.sourceForm.get('verifier.type')?.value]: { ...this.sourceForm.get('verifier.' + this.sourceForm.get('verifier.type')?.value)?.value }
type: verifier,
[verifier]: { ...this.sourceForm.get('verifier.' + verifier)?.value }
}
};

Expand All @@ -96,7 +100,7 @@ export class CreateSourceComponent implements OnInit {
return true;
}

if (this.sourceForm.get('verifier')?.value.type === 'hmac' && this.sourceForm.get('verifier.hmac')?.valid) {
if ((this.sourceForm.get('verifier')?.value.type === 'hmac' || this.sourceForm.get('verifier')?.value.type === 'github') && this.sourceForm.get('verifier.hmac')?.valid) {
return true;
}

Expand Down