Skip to content

Commit

Permalink
Fix bearer proto security definitions
Browse files Browse the repository at this point in the history
Add correct security definition for JWT Authorization token
headers so that swagger file is generated correctly.
  • Loading branch information
sesposito committed Feb 10, 2023
1 parent 4170087 commit e664924
Show file tree
Hide file tree
Showing 19 changed files with 669 additions and 53 deletions.
25 changes: 13 additions & 12 deletions apigrpc/apigrpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions apigrpc/apigrpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
}
}
security: {
// Made up security so we can apply "Bearer <JWT_TOKEN>"
key: "BearerJwt";
key: "BearerJwt"
value: {
type: TYPE_INVALID;
type: TYPE_API_KEY
in: IN_HEADER
name: "Authorization"
}
}
security: {
Expand Down
4 changes: 3 additions & 1 deletion apigrpc/apigrpc.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5225,7 +5225,9 @@
"type": "basic"
},
"BearerJwt": {
"type": ""
"type": "apiKey",
"name": "Authorization",
"in": "header"
},
"HttpKeyAuth": {
"type": "apiKey",
Expand Down
23 changes: 12 additions & 11 deletions console/console.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions console/console.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
}
}
security: {
// Made up security so we can apply "Bearer <JWT_TOKEN>"
key: "BearerJwt";
value: {};
key: "BearerJwt"
value: {
type: TYPE_API_KEY
in: IN_HEADER
name: "Authorization"
}
}
}
// Default security definition.
Expand Down
4 changes: 3 additions & 1 deletion console/console.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4063,7 +4063,9 @@
"type": "basic"
},
"BearerJwt": {
"type": ""
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
},
"security": [
Expand Down
2 changes: 1 addition & 1 deletion console/ui/dist/prod-nt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<link rel="stylesheet" href="static/styles.14b882f135e080634619.css"></head>
<body class="h-100">
<app-root></app-root>
<script src="static/runtime.4ced225923cd14368d64.js" defer=""></script><script src="static/polyfills.cb4331e883de4daa4c94.js" defer=""></script><script src="static/main.8e218c242568953c057c.js" defer=""></script></body>
<script src="static/runtime.4ced225923cd14368d64.js" defer=""></script><script src="static/polyfills.cb4331e883de4daa4c94.js" defer=""></script><script src="static/main.6c39b14c019905e4d727.js" defer=""></script></body>
</html>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion console/ui/dist/prod/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<link rel="stylesheet" href="static/styles.14b882f135e080634619.css"></head>
<body class="h-100">
<app-root></app-root>
<script src="static/runtime.4ced225923cd14368d64.js" defer=""></script><script src="static/polyfills.cb4331e883de4daa4c94.js" defer=""></script><script src="static/main.fccf1eefb431fad17814.js" defer=""></script></body>
<script src="static/runtime.4ced225923cd14368d64.js" defer=""></script><script src="static/polyfills.cb4331e883de4daa4c94.js" defer=""></script><script src="static/main.eae8e312bbf936b64915.js" defer=""></script></body>
</html>

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions console/ui/src/app/account/purchases/purchases.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ <h6 class="mr-2 d-inline font-weight-bold">Error while processing request: {{err
<th>Store</th>
<th style="width: 180px">Purchase Time</th>
<th style="width: 180px">Create Time</th>
<th style="width: 180px">Refund Time</th>
</tr>
</thead>
<tbody>
<ng-template ngFor let-i="index" let-p [ngForOf]="purchases">
<ng-template ngFor let-i="index" let-p [ngForOf]="purchases">
<tr>
<td>
<div class="arrow" (click)="purchasesRowsOpen[i]=!purchasesRowsOpen[i];">
Expand All @@ -41,9 +42,10 @@ <h6 class="mr-2 d-inline font-weight-bold">Error while processing request: {{err
<td>{{getStoreText(p.store)}}</td>
<td>{{p.purchase_time}}</td>
<td>{{p.create_time}}</td>
<td>{{getRefundText(p.refund_time)}}</td>
</tr>
<tr *ngIf="purchasesRowsOpen[i]" class="open-row">
<td colspan="7">
<td colspan="6">
<div class="p-2">
<div><small><b>Provider Response</b></small></div>
<div>
Expand All @@ -53,7 +55,7 @@ <h6 class="mr-2 d-inline font-weight-bold">Error while processing request: {{err
</td>
</tr>
</ng-template>
<tr *ngIf="purchases.length === 0"><td colspan="5" class="text-muted">No purchases were found.</td></tr>
<tr *ngIf="purchases.length === 0"><td colspan="6" class="text-muted">No purchases were found.</td></tr>
</tbody>
</table>
</div>
7 changes: 7 additions & 0 deletions console/ui/src/app/account/purchases/purchases.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export class PurchasesComponent implements OnInit {
return this.formatStoreText(ApiStoreProvider[store]);
}

getRefundText(time: string): string {
if (time === '1970-01-01T00:00:00Z') {
return '';
}
return time;
}

formatStoreText(label: string): string {
return label.split('_').map(s => s[0] + s.slice(1).toLowerCase()).join(' ');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,41 @@ <h6 class="mr-2 d-inline font-weight-bold">Error while processing request: {{err
<th style="width: 180px">Purchase Time</th>
<th style="width: 180px">Expiry Time</th>
<th style="width: 180px">Create Time</th>
<th style="width: 180px">Refund Time</th>
</tr>
</thead>
<tbody>
<ng-template ngFor let-i="index" let-p [ngForOf]="subscriptions">
<ng-template ngFor let-i="index" let-p [ngForOf]="subscriptions">
<tr>
<td>{{p.product_id}}</td>
<td>
<div class="arrow" (click)="subscriptionsRowOpen[i]=!subscriptionsRowOpen[i];">
<div class="arrow-right" *ngIf="!subscriptionsRowOpen[i]"></div>
<div class="arrow-down" *ngIf="subscriptionsRowOpen[i]"></div>
</div>
{{p.product_id}}
</td>
<td>{{p.original_transaction_id}}</td>
<td>{{getStoreText(p.store)}}</td>
<td>{{p.purchase_time}}</td>
<td>{{p.expiry_time}}</td>
<td>{{p.create_time}}</td>
<td>{{getRefundText(p.refund_time)}}</td>
</tr>
<tr *ngIf="subscriptionsRowOpen[i]" class="open-row">
<td colspan="7">
<div class="p-2">
<div><small><b>Provider Response</b></small></div>
<div>
<pre class="pre-wrap m-0 p-0"><small>{{p.provider_response}}</small></pre>
</div>
<div class="pt-2"><small><b>Provider Notification</b></small></div>
<div>
<pre class="pre-wrap m-0 p-0"><small>{{p.provider_notification}}</small></pre>
</div>
</div>
</tr>
</ng-template>
<tr *ngIf="subscriptions.length === 0"><td colspan="6" class="text-muted">No purchases were found.</td></tr>
<tr *ngIf="subscriptions.length === 0"><td colspan="7" class="text-muted">No subscriptions were found.</td></tr>
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {Observable} from 'rxjs';
})
export class SubscriptionsComponent implements OnInit {
public subscriptions: ApiValidatedSubscription[] = [];
public subscriptionsRowOpen: boolean[] = [];
public error = '';
public nextCursor = '';
public prevCursor = '';
Expand Down Expand Up @@ -58,6 +59,7 @@ export class SubscriptionsComponent implements OnInit {
cursor,
).subscribe(res => {
this.subscriptions = res.validated_subscriptions;
this.subscriptionsRowOpen = [];
this.nextCursor = res.cursor;
this.prevCursor = res.prev_cursor;
}, error => {
Expand All @@ -69,14 +71,22 @@ export class SubscriptionsComponent implements OnInit {
return this.formatStoreText(ApiStoreProvider[store]);
}

getRefundText(time: string): string {
if (time === '1970-01-01T00:00:00Z') {
return '';
}
return time;
}

formatStoreText(label: string): string {
return label.split('_').map(s => s[0] + s.slice(1).toLowerCase()).join(' ');
}
}

@Injectable({providedIn: 'root'})
export class SubscriptionsResolver implements Resolve<ApiPurchaseList> {
constructor(private readonly consoleService: ConsoleService) {}
constructor(private readonly consoleService: ConsoleService) {
}

resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ApiSubscriptionList> {
const userId = route.parent.paramMap.get('id');
Expand Down
Loading

0 comments on commit e664924

Please sign in to comment.