Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
chore: pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter committed Feb 28, 2024
1 parent 2824f0f commit 23f00e1
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ curl -X "POST" "https://keycloak.aam-digital.net/realms/<your_realm>/protocol/op
--data-urlencode "scopes=openid reporting_read reporting_write"
```
Check API docs for the required "scopes".
This returns a JWT access token required to provided as Bearer TokenDecorator for any request to the API endpoints. Sample token:
This returns a JWT access token required to provided as Bearer Token for any request to the API endpoints. Sample token:
```json
{
"access_token": "eyJhbGciOiJSUzI...",
Expand Down
2 changes: 1 addition & 1 deletion src/auth/core/jwt-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { Reflector } from '@nestjs/core';
import { Scopes } from './scope.decorator';
import { Scopes } from './scopes.decorator';

/**
* Represents a validated JwtTokenPayload
Expand Down
3 changes: 0 additions & 3 deletions src/auth/core/scope.decorator.ts

This file was deleted.

7 changes: 7 additions & 0 deletions src/auth/core/scopes.decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Reflector } from '@nestjs/core';

/**
* Annotate an endpoint to require a certain permission in the Auth token.
* All the values in the array are required to gain access.
*/
export const Scopes = Reflector.createDecorator<string[]>();
2 changes: 1 addition & 1 deletion src/notification/controller/webhook.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Webhook } from '../domain/webhook';
import { NotificationService } from '../core/notification.service';
import { CreateWebhookDto, WebhookDto } from './dtos';
import { JwtAuthGuard } from '../../auth/core/jwt-auth.guard';
import { Scopes } from '../../auth/core/scope.decorator';
import { Scopes } from '../../auth/core/scopes.decorator';

@Controller('/api/v1/reporting/webhook')
export class WebhookController {
Expand Down
2 changes: 1 addition & 1 deletion src/report/controller/report-calculation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
CreateReportCalculationUseCase,
} from '../core/use-cases/create-report-calculation-use-case.service';
import { JwtAuthGuard } from '../../auth/core/jwt-auth.guard';
import { Scopes } from '../../auth/core/scope.decorator';
import { Scopes } from '../../auth/core/scopes.decorator';

@Controller('/api/v1/reporting')
export class ReportCalculationController {
Expand Down
2 changes: 1 addition & 1 deletion src/report/controller/report.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ReportDto } from './dtos';
import { Reference } from '../../domain/reference';
import { Report } from '../../domain/report';
import { JwtAuthGuard } from '../../auth/core/jwt-auth.guard';
import { Scopes } from '../../auth/core/scope.decorator';
import { Scopes } from '../../auth/core/scopes.decorator';

@Controller('/api/v1/reporting')
export class ReportController {
Expand Down

0 comments on commit 23f00e1

Please sign in to comment.