Giter Club home page Giter Club logo

nest-authz's Issues

Support for NestJS 10

Hi, NestJS was updated some days ago to v10, is posible update this package to @nestjs/common@"^10.0.0 ?

AuthZModule.register无法注入相关service依赖

自定义了一个policy adapter,它依赖一个service服务,但目前这个动态模块无法注入依赖,因此就硬编码了一个,所以能否改进一下authzmodule?

@Module({
  providers: [],
  exports: [],
})
export class CasbinModule {
  static register(options: AuthZModuleOptions): DynamicModule {
    const moduleOptionsProvider = {
      provide: AUTHZ_MODULE_OPTIONS,
      useValue: options || {},
    };

    const enforcerProvider = {
      provide: AUTHZ_ENFORCER,
      useFactory: async (service: CustomService) => {
        const policy = new CustomAdapter(service);
        return casbin.newEnforcer('model.conf', policy);
      },
      inject: [CustomService],
    };
    return {
      module: CasbinModule,
      imports: [CustomModule],
      providers: [
        moduleOptionsProvider,
        enforcerProvider,
        AuthZGuard,
        AuthZRBACService,
        AuthZManagementService,
      ],
      exports: [
        moduleOptionsProvider,
        enforcerProvider,
        AuthZGuard,
        AuthZRBACService,
        AuthZManagementService,
      ],
    };
  }
}

无法手动刷新权限列表

使用以下代码增加用户或角色后无法自动更新或手动更新权限列表,
await this.authZRBACService.addRoleForUser('menu_list', 'menu');
现只能通过修改authz-management.service.ts 文件中增加一个更新方法来临时解决,
loadPolicy(): Promise<void> { return this.enforcer.loadPolicy(); }
在项目中调用
await this.authZManagementService.loadPolicy();

不过不知道是否有更好的方式,如有请回复我下,十分感谢。

Upgrade dependencies

Hey folks, this package does not work with nestjs v9 due to out-of-date dependencies.

This PR #154 contains a fix for it, but it might require another upgrade

AuthActionVerb中的read能否精分一下

能否将AuthActionVerb中的READ精分为查询列表和查询详情。如BROWSE/READ、 LIST/GET或者QUERY/GET 等类似的,否则要单独写一个列表资源字符串

What is the `name` field in configuration used for?

In the documentation there is the following code:

import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [
    AuthZModule.register({
      model: 'model.conf',
      policy: TypeORMAdapter.newAdapter({
        name: 'casbin',
        type: 'mysql',
        host: 'localhost',
        port: 3306,
        username: 'root',
        password: 'password',
        database: 'nestdb'
      }),
      usernameFromContext: (ctx) => {
        const request = ctx.switchToHttp().getRequest();
        return request.user && request.user.username;
      }
    }),
  ],
})

What does the name field do in TypeORMAdapter?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.