question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get dynamic permissions for ACL from backend?

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request
  • Question

Issue description

Current behavior: How to get dynamic permissions for ACL from backend instead of static as below:

Expected behavior:

Steps to reproduce:

Related code:

NbSecurityModule.forRoot({
     accessControl: {
       guest: {
         view: ['news', 'comments'],
       },
       user: {
         parent: 'guest',
         create: 'comments',
       },
       moderator: {
         parent: 'user',
         create: 'news',
         remove: '*',
       },
     },
   }),

Other information:

npm, node, OS, Browser

<!--
Node, npm: `node --version` and `npm --version`
OS: Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
Browser: Chrome/Safari/Firefox/etc?
-->

Angular, Nebular

<!--
Check your `package-lock.json` or locate a `package.json` in the `node_modules` folder.
-->

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Suroor-Ahmmadcommented, Oct 8, 2020

If anyone looking for the solution, I have used same logic what @jesus-ibanez suggested, inside AuthGuard canActivate() method

canActivate() {
    return this.authService.isAuthenticated()
        .pipe(
            tap(async authenticated => {
                this.authService.getToken().subscribe(
                    (token: NbAuthJWTToken) => {
                        if (token.isValid()) {
                            this.permissions = token.getPayload().permissions;
                            console.log(this.permissions);
                            this.nbAclService.setAccessControl(this.permissions);
                        }
                    }
                );
                if (!authenticated) {
                    this.router.navigate(['auth/login']);
                }
            }),
        );
}
1reaction
jesus-ibanezcommented, Aug 22, 2018

by using setAccessControl after login it works, thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get dynamic permissions for ACL - Stack Overflow
I'm trying to implement dynamic permissions, that is to say, that the components to which the user has access come in the token....
Read more >
Use Access Control List (ACL) to set up permission-based ...
Learn how to use Access Control List (ACL) in your applications to set up conditional access to data based on specific user profiles....
Read more >
Zend_Acl part 3: creating and storing dynamic ACLs
In this third post of the series, I'll talk about using dynamic ACLs: How to store an ACL in a database, and construct...
Read more >
Dynamic roles [ACL] - Discussion - Phalcon Framework
If ACL is executed with every http request, I would create entity 'Role' and entity 'Permission'. Every role would have some permissions. ACL...
Read more >
How can I create and manage permissions more dynamically?
The existing ACL and role-based systems I've seen don't seem to offer any way to deal with constraints - you either have access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found