Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Hooks when accessing services #3445

Open
mades5 opened this issue Mar 13, 2024 · 3 comments
Open

Skip Hooks when accessing services #3445

mades5 opened this issue Mar 13, 2024 · 3 comments

Comments

@mades5
Copy link

mades5 commented Mar 13, 2024

Hi,

I added my own authentication strategy to feathers and have one problem with that.
I authenticate my user in my strategy and try to get his rights from the database by accessing the service

const rights = await this.app?.service('rights').get(group);

This is working but the service always runs all the hooks from my service and there is a check if the user has the rights to access this service which he does not have at this point so I get an Unauthorized error.
Is there a way to access a service and skipping hooks? I could not find anything about this in the documentation.
Thanks

@AshotN
Copy link
Contributor

AshotN commented Mar 13, 2024

In your hook you can add a check that if there is no user to skip the auth check.

@mades5
Copy link
Author

mades5 commented Mar 14, 2024

That's not possible, the user is already there. Just the rights are missing.

@haris2k
Copy link

haris2k commented May 24, 2024

// if internal call from another service
if (context.params.provider === undefined) {
    // skip checks
}

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

No branches or pull requests

3 participants