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

Refactor authorizator component #436

Open
darioAnongba opened this issue Dec 15, 2021 · 0 comments
Open

Refactor authorizator component #436

darioAnongba opened this issue Dec 15, 2021 · 0 comments

Comments

@darioAnongba
Copy link
Contributor

darioAnongba commented Dec 15, 2021

Currently the Authorizator component is stateful and is created from user information. This is not needed as the authorizator functions are pure (given an input their return always the same output and do not depend on state).

The best implementation would be one of the 2:

Singleton:

  • Instantiate a singleton authorizator that is passed around. This component accepts a logger or any other component needed to perform its actions. This authorizator singleton then has a function CheckPermission taking userInfo and operation as params. Do the same for CheckAccess.

Functions of the UserInfo struct:

  • Add functions to the userInfo struct directly such as HasAccess (checks tenant vs list of allowed_tenants) or HasPermission (checks list of permission vs an operation).

Option 2 seems more intuitive and removes the need for one more struct in the codebase but the logging will need to happen on every use case using it.
Option 1 encapsulates the logging.

@darioAnongba darioAnongba changed the title Remove authorizator Refactor authorizator component Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant