def has_access_api(f):
if hasattr(f, '<STR_LIT>'):<EOL><INDENT>permission_str = f._permission_name<EOL><DEDENT>else:<EOL><INDENT>permission_str = f.__name__<EOL><DEDENT>def wraps(self, *args, **kwargs):<EOL><INDENT>permission_str = PERMISSION_PREFIX + f._permission_name<EOL>if self.appbuilder.sm.has_access(<EOL>permission_str,<EOL>self.__class__.__name__<EOL>):<EOL><INDENT>return f(self, *args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>log.warning(<EOL>LOGMSG_ERR_SEC_ACCESS_DENIED.format(<EOL>permission_str,<EOL>self.__class__.__name__<EOL>)<EOL>)<EOL>response = make_response(<EOL>jsonify(<EOL>{<EOL>'<STR_LIT:message>': str(FLAMSG_ERR_SEC_ACCESS_DENIED),<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>),<EOL><NUM_LIT><EOL>)<EOL>response.headers['<STR_LIT:Content-Type>'] = "<STR_LIT:application/json>"<EOL>return response<EOL><DEDENT><DEDENT>f._permission_name = permission_str<EOL>return functools.update_wrapper(wraps, f)<EOL>
Use this decorator to enable granular security permissions to your API methods.
Permissions will be associated to a role, and roles are associated to users.

By default the permission's name is the methods name.

this will return a message and HTTP 401 is case of unauthorized access.