platformatic / platformatic

Platformatic Open Source monorepo!
Apache License 2.0
1.44k stars 145 forks source link

Platformatic db auth #3068

Open keletsomolefe opened 1 week ago

keletsomolefe commented 1 week ago
/// <reference path="../global.d.ts" />
import { FastifyInstance, FastifyPluginOptions } from 'fastify';
import auth from '@platformatic/db-authorization';

export default async function (fastify: FastifyInstance, opts: FastifyPluginOptions) {
  await fastify.register(auth, {
    roleKey: "X-PLATFORMATIC-ROLE",
    anonymousRole: "anonymous",
    rules: [{
      role: 'user',
      entities: ['movie'],
      find: true,
      delete: false,
      save: false
    }]
  });
}

{"statusCode":500,"error":"Internal Server Error","message":"request.setupDBAuthorizationUser is not a function"}

mcollina commented 1 week ago

Are you already using Platformatic DB?

Could you include a repository to reproduce?

keletsomolefe commented 1 week ago

Was trying to create a reproduce only to find out that when i pass below config, where i mention auth.ts it fails, but if i remove the specific file mention it works fine

BREAKS

...
    "plugins": {
        "typescript": true,
        "paths": [
            {
                "path": "./plugins/auth.ts",
                "encapsulate": false
            }
        ]
    }
...

WORKS

...
    "plugins": {
        "typescript": true,
        "paths": [
            {
                "path": "./plugins",
                "encapsulate": false
            }
        ]
    }
...