Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The falcon-policy
package provides a middleware component
that enables simple policy controls such as role-based access on routes
via configuration.
The configuration approach to policy rules enables dynamic authorization use-cases where the policy needs to be adjusted on-demand without a new service deployment.
.. code:: bash
$ pip install falcon-policy
The RoleBasedPolicy
middleware class examines each incoming request
and verifies the roles
list from the request context; which should be
populated by an authentication middleware. If the request context isn't
populated with a roles
list, then the middleware will fall back on
the X-Roles
header for the appropriate role given the request being made.
Usage of the X-Roles
header, is primarily used when handling
authentication outside of the middleware stack or for development with
authentication disabled.
Implementation Note:
If the request context type isn't a dictionary, the middleware will assume
that req.context
is an Object with a roles
attribute.
Getting Started:
RoleBasedPolicy
using the configurationfalcon.API()
initializer:.. code:: python
from falcon_policy import RoleBasedPolicy
policy_config = {
'roles': [
'admin',
'creator',
'observer',
],
'groups': {
'create': ['admin', 'creator'],
'update': ['admin', 'creator'],
'read': ['admin', 'creator', 'observer'],
'delete': ['admin'],
},
'routes': {
'/quote': {
'GET': ['read'],
'POST': ['create'],
'PUT': ['update'],
'DELETE': ['delete'],
},
'/quote/{id}': {
'GET': ['read'],
'POST': ['create'],
'PUT': ['update'],
'DELETE': ['delete'],
},
'/status': {
'GET': ['@any-role'],
'HEAD': ['@passthrough'],
},
},
}
app = falcon.API(
middleware=[
RoleBasedPolicy(policy_config)
]
)
If validation fails an instance of falcon.HTTPForbidden
is raised.
The policy configuration is separated into three sections:
Specialty Roles:
``falcon-policy`` offers two specialty roles types that should be used with
care:
* ``@any-role``: Allows any defined role
* ``@passthrough``: Allows all users (authenticated and unauthenticated)
Falcon is a bare-metal Python web framework <http://falconframework.org/index.html>
__ for building lean and
mean cloud APIs and app backends. It encourages the REST architectural style,
and tries to do as little as possible while remaining highly effective <http://falconframework.org/index.html#Benefits>
__.
.. |Build Status| image:: https://travis-ci.org/falconry/falcon-policy.svg :target: https://travis-ci.org/falconry/falcon-policy .. |codecov.io| image:: https://codecov.io/gh/falconry/falcon-policy/branch/master/graph/badge.svg :target: https://codecov.io/gh/falconry/falcon-policy
FAQs
Policy middleware for Falcon APIs
We found that falcon-policy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.