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

Improve usecase to validate if it contains an authorization method #86

Open
maikvortx opened this issue Aug 9, 2022 · 2 comments
Open
Labels
enhancement New feature or request hacktoberfest

Comments

@maikvortx
Copy link
Contributor

Is your feature request related to a problem? Please describe.

The authorization method is returning Not Authorized when an usecase doesn't have implementation for authorize method. Thus, when we call uc.authorize(user) , buchu returns 'Not Authorized' because usecase doesn't have implementation for it.

Describe the solution you'd like

Often, usecases have authorization but sometimes we have usecase that don't implement the authorization method. As we use defaultResolver in our applications to standardize routes, we can implement validation on buchu to validate if usecase has an authorization method.

image

Describe alternatives you've considered

While an alternative, I'm checking the ucRunner._authorize property to validate if the usecase has an authorized implementation.

image

@maikvortx maikvortx added the enhancement New feature or request label Aug 9, 2022
@maikvortx
Copy link
Contributor Author

@dalssoft what you think about it?

@dalssoft
Copy link
Member

dalssoft commented Sep 5, 2022

mixed feelings here.
(1) it would be ok to ignore authorize: async (user) => and make it optional. But keeping uc.authorize(user), which now would return the same result as authorize: async (user) => Ok() when there is no authorize: async (user) => informed.

(2) however, I'm afraid that making authorize: async (user) => optional would make security a second class citizen inside Herbs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants