-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[RFC] new api.groups decorator for function #944
Comments
I think this is a good idea - security by obscurity (hiding the buttons) doesn't work. Question is where to put this. I made an OCA Python module that has an |
I still think it's a good idea to have an OCA API library. @lasley you only need to create the repo following the method put in the OCA instance task ("Create a project") and make the PR. About this feature, 👍 for adding it, but not with the decorators |
Hi ! Thanks for your answer. A OCA API library LGTM. Great idea !
You're right, it could be simplified indeed.
Not sure it will cover all the needs, but we'll talk about it in a specific PR against the new repo.
@lasley , please ping me when the repo is created, I'll began a POC then and try to finish the work in the next Open (/ Closed) Days. |
Good point - at the time I didn't have permissions to do this. I'm not finding this process in the OCA instance though- I'll dig a bit more & report back with the new repo. |
Hmmm ok yeah so I can't find a process for repo creation, so I was just going to go ahead and create the repo - but it seems I don't have permissions. @pedrobaeza would you mind creating a blank OCA/python-oca repo so that I can submit a PR to it? |
👍 For having a decorator that does this. I had the idea to create a But having the decorator a part of a pip library might be as well. I only wonder about the name @api.groups. Would that not be confusing as this is then not coming from the odoo api python module? |
Hi @NL66278, well, about the name space, I think that collision will not be possible, because the name will be @oca.groups and not @api.groups. (or something similar) |
@legalsylvain I was reacting to the first example use. Having |
@legalsylvain It's a good idea! I'd rather keep' oca' as a namespace package available to all oca packages. We could name this new package 'oca-decorator'. This package would provide 'oca.decorator' (or oca.xyz) from oca.decorator import groups
@groups(..)
def function_name(): About lmi |
@lasley this is the task where the process for a new repository/PSC is specified: https://odoo-community.org/web#id=264&view_type=form&model=project.task&action=468&active_id=2 |
Try again now that I have changed your role. |
@lmignon - I asked for suggestions and this was the best one. The python package is similarly named. What's you idea? I'm all ears. |
@lasley My main concern is to avoid the creation of a monolytic python package. If the primary goal it to provide new specialized decorators why not oca-decorator. The name should depend of the functional scope covered by the package or whatever you want. At least the name must be meaningfull. IMO 'python-oca' is too wide. |
I'm good with Anyways it's easy enough to make that change, and I think it would be better to discuss it in the context of code. Seeing as I made the repo, will submit the PR and include your suggestion - then we can discuss in context instead of this hijacked PR. |
@lasley the |
Got it, so we would basically just want to rename our |
yep 😏 that's the idea. |
Too bad |
OCA/oca-decorators#1 submitted |
I have a question about the structure of this code. (maybe my question is irrelevant, sorry) Basically, I see two ways to write this code. A) via a classical odoo module (in an existing or new repository). so, to use it, we have to write some
B) via a python lib. It seems that you all are talking about the solution "B", and of course, it is the cleaner solution. There are only one other exemple in the OCA for the time being. The openupgradelib. the code was initially in the OpenUpgrade project, and was moved into an external python-lib. For me it is not a blocking point for the openupgradelib, because making an upgrade is a technical thing. What do you think ? |
Do we know how Odoo.sh handles pip dependencies? IMO this is on them to fix the |
not to say Odoo.sh (or Odoo.hs for french people) is the next Runbot. Bet taken. |
😆 Yeah we know where my bet lies on that one |
Indeed, but it is quite different. Of course, if you want a system that handle barcode generation, you should install barcode lib. the same for asterisk, etc... Here, it's different. I just updated OCA code source analysis. today there are 4182 modules. (a module present in two milestone is counted twice). In the other hand, In all that 4182 modules, there are only 274 python dependencies. So 94% of the OCA modules are not depending on external python libs and can be installed very easily. details : If tomorrow, there is a good extra oca python lib with usefull decorators (like the one we try to describe in this thread that try to fix a security issue), most of the OCA modules will depends on this lib, step by step. The objective of the OCA is to promote OCA members work. So if such decision (to create a lib to install) is reducing the possibility of people to use OCA modules, I think that we should not go in this direction for the time being. We could create first a little oca-decorator repository, with classical modules. And if in 1 / 2 years, it is mature, and if deployment and hosting system are more mature too (*), it will be very easy to put all the code in a external lib. openupgrade code has been during years in openupgrade repository and has been set in a external lib recently by @StefanRijnhart. I think that this changes was not a big deal. (*) : hosting and deployment system have changed a lot during the last years. (geting code by bzr, getting code by github, using buildout technology, and more recently pypi deployment) I'd like to hear what @OCA/board are thinking about that point. it is not only a technical decision, it is also a strategic decision |
Now that https://github.com/OCA/oca-decorators is available, this RFC can move there. |
@legalsylvain - I originally submitted a module for Usage of the api was damned near impossible when you start accounting for an import path that is 60-70 chars, and a try/except that has to be put around each of the imports. This will make adoption of the module basically zero - the import is harder than the record loop. Interestingly enough our try/except strategy fails miserably with decorators, but that's a completely different topic. Again, I wish Odoo would fix their @dreispt - is there a good way to move this pre-existing discussion to another repo? There's a lot of points exposed here that I'm not sure would be fluidly carried over. |
I don't understand what is the try / except need in that solution. To use a oca@foreach decorator define in a oca_api lib or module. : Lib solution impacts
manifest file :
Python file :
Module solution impacts
manifest file :
Python file :
Or did I missed something ? If yes please correct me. Kind regards. |
The try/except is what we have to do when importing anything that is not core Odoo, so your examples would be the following instead:
But yeah with your module naming, it isn't nearly as bad as mine was. I think a lot of this has to do with the fact that the module is not installing into a DB, and is not encapsulated to the environment as most modules would be. This means it is providing functionality to environments that have not explicitly installed the module, and could be considered an issue (security or otherwise). @lmignon just exposed similar argument to above in OCA/webhook#3 (comment). I think these are parallel conversations - basically boiling into how we provide feature-sets like this. I personally feel that @lmignon is right here & we should be providing this as a lib. IIRC his advice was the main reason why I moved the |
Hi @lasley. Ow thanks ! I thought that making dependencies to a module was enough to assume that the module is present, but rgreping all OCA code, i saw a lot of samples of what you talk. (a lot for report_xls, and connector). I don't have the skills to understand security issues hre, due to a module. For me, if the module is not installed, the code of the module of oca_api should not be called. but maybe I'm wrong. Regards. |
Take a look at odoo/odoo#14850 for more info
Therein lies the problem. This is not the case - Odoo imports all modules within the This is core in Odoo, and realistically there is no circumvention. This is also why I do not co-host my customers in the same way that Odoo SA does. I'm curious if they've managed to solve this with Odoo.sh, but my guess is that they have a ticking timebomb on their hands in their SaaS |
Thanks for all this clarifications. It's a pity that odoo/odoo#14850 is not accepted. |
I close this issue. (moved into OCA/oca-decorators#7) |
Syncing from upstream OCA/server-tools (15.0)
Hi all,
I think about a new decorator like
to decorate function that are call by function in a xml file like
<button name='function_name' />
.The decorator will check if current user is a member of one of the defined groups, if not an access error is raised. Then, in the render view, the button is hidden if the user is not a member of the defined groups automatically
That new decorator could fix security breaches that allow user to call a function of a hidden button, by xml RPC.
In a second time we could imagine other decorators @api.add_groups or @api.remove_groups to add or remove access to a function, in a custom module that inherit a model.
Thanks for your comment.
The text was updated successfully, but these errors were encountered: