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

BasicValidator implements AuthValidator - aqueduct document error #932

Open
robotoss opened this issue Jan 11, 2021 · 0 comments
Open

BasicValidator implements AuthValidator - aqueduct document error #932

robotoss opened this issue Jan 11, 2021 · 0 comments

Comments

@robotoss
Copy link

I tried to write my own authorization:

class BasicValidator implements AuthValidator {
  @override
  List<APISecurityRequirement> documentRequirementsForAuthorizer(
      APIDocumentContext context, Authorizer authorizer,
      {List<AuthScope> scopes}) {
    return [
      APISecurityRequirement({"securitySchemes": []})
    ];
  }

  @override
  FutureOr<Authorization> validate<T>(
      AuthorizationParser<T> parser, T authorizationData,
      {List<AuthScope> requiredScope}) {
    final userId = SecurityHelper().userIdByToken(authorizationData.toString());
    if (userId != null) {
      return Authorization(
        userId.toString(),
        null,
        this,
      );
    }
    return null;
  }

The code works when the server starts up.
But when I try to use the command - aqueduct document. I get an error

PS C:\aqueductProjects\aqueduct_pd> aqueduct document
-- Aqueduct CLI Version: 4.0.0-b1
-- Aqueduct project version: 4.0.0-b1
*** Uncaught error
Bad state: NoSuchMethodError: The getter 'type' was called on null.
Receiver: null
Tried calling: type
**** Stacktrace


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant