Skip to content

Commit

Permalink
fix: Add data reset before each check (#326)
Browse files Browse the repository at this point in the history
* Add data reset before each check

* Review comments
  • Loading branch information
Andrew Nikitin committed Aug 9, 2023
1 parent 17d0aa8 commit 659a120
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/controllers/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export class CredentialController {
{
verifyStatus,
policies
}
},
response.locals.customerId
)
if (result.error) {
return response.status(StatusCodes.BAD_REQUEST).json({
Expand Down Expand Up @@ -394,7 +395,8 @@ export class CredentialController {
verifyStatus,
policies,
domain: verifierDid
}
},
response.locals.customerId
)
if (result.error) {
return response.status(StatusCodes.BAD_REQUEST).json({
Expand Down
17 changes: 13 additions & 4 deletions src/middleware/auth/base-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export abstract class AbstractAuthHandler implements IAuthResourceHandler

private routeToScoupe: MethodToScope[] = []
private static pathSkip = [
'/swagger',
'/user',
'/swagger',
'/static',
'/logto',
'/account/set-default-role']
'/logto',
'/account/set-default-role',
'/auth/user-info']

constructor () {
this.nextHandler = {} as IAuthResourceHandler
Expand All @@ -35,7 +35,16 @@ export abstract class AbstractAuthHandler implements IAuthResourceHandler
this.logToHelper = new LogToHelper()
}

private reset() {
this.namespace = '' as Namespaces
this.token = '' as string
this.scopes = []
this.customerId = '' as string
}

public async commonPermissionCheck(request: Request): Promise<IAuthResponse> {
// Reset all variables
this.reset()
// Firstly - try to find the rule for the request
const rule = this.findRule(request.path, request.method, this.getNamespace())

Expand Down
4 changes: 2 additions & 2 deletions src/services/identity/unauthorized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export class Unauthorized extends LocalIdentity {
return Veramo.instance.getDid(this.initAgent(), did)
}

async verifyCredential(credential: VerifiableCredential | string, verificationOptions: VerificationOptions): Promise<IVerifyResult> {
async verifyCredential(credential: VerifiableCredential | string, verificationOptions: VerificationOptions, agentId?: string): Promise<IVerifyResult> {
return await Veramo.instance.verifyCredential(this.initAgent(), credential, verificationOptions)
}

async verifyPresentation(presentation: VerifiablePresentation | string, verificationOptions: VerificationOptions): Promise<IVerifyResult> {
async verifyPresentation(presentation: VerifiablePresentation | string, verificationOptions: VerificationOptions, agentId?: string): Promise<IVerifyResult> {
return await Veramo.instance.verifyPresentation(this.initAgent(), presentation, verificationOptions)
}

Expand Down

0 comments on commit 659a120

Please sign in to comment.