Name | ckanext-vip-portal JSON |
Version |
0.2.5
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-10-17 14:34:40 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | AGPL |
keywords |
ckan
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
[](https://github.com/DataShades/ckanext-vip-portal/actions/workflows/test.yml)
# ckanext-vip-portal
Generic access restrictions for anonymous user.
Configure the set or endpoints/URLs that are available for the anonymous user,
and redirect to the login page if he attempts to visit non-whitelisted page.
## Requirements
Compatibility with core CKAN versions:
| CKAN version | Compatible? |
|--------------|-------------|
| 2.9 | yes |
| 2.10 | yes |
| 2.11(master) | yes |
## Installation
To install `ckanext-vip-portal`:
2. Install it using pip
```sh
pip install ckanext-vip-portal
```
3. Add `vip_portal` to the `ckan.plugins` setting in your CKAN
config file.
## Config settings
```ini
# Configure endpoint that handles unauthorized page access
# (optional, default: user.login)
ckanext.vip_portal.login_endpoint = auth_ext.login
# Allow anonymous access to all the pages. It basically disables current
# extensions
# (optional, default: false)
ckanext.vip_portal.free_anonymous_access = true
# Allow any authenticated user to visit pages normally
# (optional, default: true)
ckanext.vip_portal.free_authenticated_access = false
# Unless endpoint is blocked by one of IVipAccess implementations, it can be
# accessed by anyone. Use it in combination with IVipPortal interface if you
# want to leave the portal generally open and block only certain endpoints
# (optional, default: false)
ckanext.vip_portal.free_access_by_default = true
# Allow anonymous access to login pages
# (optional, default: true)
ckanext.vip_portal.allow_login = false
# Allow anonymous access to password reset page
# (optional, default: true)
ckanext.vip_portal.allow_password_reset = false
# Allow anonymous access to registration pages
# (optional, default: true)
ckanext.vip_portal.allow_registration = false
# Allow anonymous access to API endpoints
# (optional, default: true)
ckanext.vip_portal.allow_api = false
# Additional endpoints that are accessible by anonymous user
# (optional, default: )
ckanext.vip_portal.extra_allowed_endpoints = home.index home.about dataset.search
# Additional paths(URLs) that are accessible by anonymous user
# (optional, default: )
ckanext.vip_portal.extra_allowed_paths = / /about /dataset
# Allow anonymous user to access any path that starts with the following
# prefixes
# (optional, default: )
ckanext.vip_portal.extra_allowed_prefixes = /dataset /organization /group /static
# Allow anonymous user to access any path that ends with the following
# suffixes
# (optional, default: )
ckanext.vip_portal.extra_allowed_suffixes = .svg .html .css
# Allows to customize the route that the user will get redirected to
# after a successful login. Empty value allow user to be redirected to the page
# requested before displaying login page
# (optional, default: )
ckan.auth.route_after_login = dataset.search
```
## Advanced
For more specific scenarios, implement
`ckanext.vip_portal.interfaces.IVipPortal`
```python
class IVipPortal(Interface):
def check_vip_access_for_endpoint(
self,
endpoint: Union[tuple[str, str], tuple[None, None]],
user: Optional[str],
) -> Access:
"""Check if user allowed to visit the endpoint.
Return `ckanext.vip_portal.interfaces.Access` enum member from this
method:
* Access.allowed: user is allowed to see the endpoint
* Access.forbidden: user is not allowed to see the endpoint
* Access.unknown: use default logic that depends on settings
Use `forbidden` only when you explicitly want to disallow access to the
ednpoint. Otherwise use `unknown`: it will check configuration of the
extension and other plugins first and only then allow/disallow visiting
the page.
"""
return Access.unknown
def check_vip_access_for_path(
self, path: str, user: Optional[str]
) -> Access:
"""Check if user allowed to visit the endpoint.
See IVipPortal.check_vip_access_for_endpoint
"""
return Access.unknown
def make_vip_rejection_response(
self, user: Optional[str]
) -> Optional[Response]:
"""Create a response for forbiddent page.
By default, authenticated user sees 403 page and anonymous user is
redirected to login page.
"""
return None
def alter_vip_rejection_response(
self, resp: Response, user: Optional[str]
) -> Response:
"""Modify rejection response before it's sent to user.
Here you can add additional headers to the rejection response. For
anything more complex consider using
IVipPortal.make_vip_rejection_response.
"""
return resp
```
## Developer installation
To install `ckanext-vip-portal` for development, activate your CKAN virtualenv and
do:
git clone https://github.com/DataShades/ckanext-vip-portal.git
cd ckanext-vip-portal
pip install -e '.[dev]'
## License
[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
Raw data
{
"_id": null,
"home_page": null,
"name": "ckanext-vip-portal",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": "DataShades <datashades@linkdigital.com.au>",
"keywords": "CKAN",
"author": null,
"author_email": "DataShades <datashades@linkdigital.com.au>, Sergey Motornyuk <sergey.motornyuk@linkdigital.com.au>",
"download_url": "https://files.pythonhosted.org/packages/d0/a6/e1f78544064cff76f4ea29dc882c29d49bc0e7759a974a0ea94509473478/ckanext_vip_portal-0.2.5.tar.gz",
"platform": null,
"description": "[](https://github.com/DataShades/ckanext-vip-portal/actions/workflows/test.yml)\n\n# ckanext-vip-portal\n\nGeneric access restrictions for anonymous user.\n\nConfigure the set or endpoints/URLs that are available for the anonymous user,\nand redirect to the login page if he attempts to visit non-whitelisted page.\n\n## Requirements\n\nCompatibility with core CKAN versions:\n\n| CKAN version | Compatible? |\n|--------------|-------------|\n| 2.9 | yes |\n| 2.10 | yes |\n| 2.11(master) | yes |\n\n\n## Installation\n\nTo install `ckanext-vip-portal`:\n\n2. Install it using pip\n ```sh\n pip install ckanext-vip-portal\n ```\n\n3. Add `vip_portal` to the `ckan.plugins` setting in your CKAN\n config file.\n\n\n## Config settings\n\n```ini\n# Configure endpoint that handles unauthorized page access\n# (optional, default: user.login)\nckanext.vip_portal.login_endpoint = auth_ext.login\n\n# Allow anonymous access to all the pages. It basically disables current\n# extensions\n# (optional, default: false)\nckanext.vip_portal.free_anonymous_access = true\n\n# Allow any authenticated user to visit pages normally\n# (optional, default: true)\nckanext.vip_portal.free_authenticated_access = false\n\n# Unless endpoint is blocked by one of IVipAccess implementations, it can be\n# accessed by anyone. Use it in combination with IVipPortal interface if you\n# want to leave the portal generally open and block only certain endpoints\n# (optional, default: false)\nckanext.vip_portal.free_access_by_default = true\n\n# Allow anonymous access to login pages\n# (optional, default: true)\nckanext.vip_portal.allow_login = false\n\n# Allow anonymous access to password reset page\n# (optional, default: true)\nckanext.vip_portal.allow_password_reset = false\n\n# Allow anonymous access to registration pages\n# (optional, default: true)\nckanext.vip_portal.allow_registration = false\n\n# Allow anonymous access to API endpoints\n# (optional, default: true)\nckanext.vip_portal.allow_api = false\n\n# Additional endpoints that are accessible by anonymous user\n# (optional, default: )\nckanext.vip_portal.extra_allowed_endpoints = home.index home.about dataset.search\n\n# Additional paths(URLs) that are accessible by anonymous user\n# (optional, default: )\nckanext.vip_portal.extra_allowed_paths = / /about /dataset\n\n# Allow anonymous user to access any path that starts with the following\n# prefixes\n# (optional, default: )\nckanext.vip_portal.extra_allowed_prefixes = /dataset /organization /group /static\n\n# Allow anonymous user to access any path that ends with the following\n# suffixes\n# (optional, default: )\nckanext.vip_portal.extra_allowed_suffixes = .svg .html .css\n\n# Allows to customize the route that the user will get redirected to\n# after a successful login. Empty value allow user to be redirected to the page\n# requested before displaying login page\n# (optional, default: )\nckan.auth.route_after_login = dataset.search\n\n```\n\n## Advanced\n\nFor more specific scenarios, implement\n`ckanext.vip_portal.interfaces.IVipPortal`\n\n```python\nclass IVipPortal(Interface):\n def check_vip_access_for_endpoint(\n self,\n endpoint: Union[tuple[str, str], tuple[None, None]],\n user: Optional[str],\n ) -> Access:\n \"\"\"Check if user allowed to visit the endpoint.\n\n Return `ckanext.vip_portal.interfaces.Access` enum member from this\n method:\n\n * Access.allowed: user is allowed to see the endpoint\n * Access.forbidden: user is not allowed to see the endpoint\n * Access.unknown: use default logic that depends on settings\n\n Use `forbidden` only when you explicitly want to disallow access to the\n ednpoint. Otherwise use `unknown`: it will check configuration of the\n extension and other plugins first and only then allow/disallow visiting\n the page.\n\n \"\"\"\n return Access.unknown\n\n def check_vip_access_for_path(\n self, path: str, user: Optional[str]\n ) -> Access:\n \"\"\"Check if user allowed to visit the endpoint.\n\n See IVipPortal.check_vip_access_for_endpoint\n \"\"\"\n return Access.unknown\n\n def make_vip_rejection_response(\n self, user: Optional[str]\n ) -> Optional[Response]:\n \"\"\"Create a response for forbiddent page.\n\n By default, authenticated user sees 403 page and anonymous user is\n redirected to login page.\n\n \"\"\"\n return None\n\n def alter_vip_rejection_response(\n self, resp: Response, user: Optional[str]\n ) -> Response:\n \"\"\"Modify rejection response before it's sent to user.\n\n Here you can add additional headers to the rejection response. For\n anything more complex consider using\n IVipPortal.make_vip_rejection_response.\n\n \"\"\"\n return resp\n```\n\n## Developer installation\n\nTo install `ckanext-vip-portal` for development, activate your CKAN virtualenv and\ndo:\n\n git clone https://github.com/DataShades/ckanext-vip-portal.git\n cd ckanext-vip-portal\n pip install -e '.[dev]'\n\n\n## License\n\n[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)\n",
"bugtrack_url": null,
"license": "AGPL",
"summary": null,
"version": "0.2.5",
"project_urls": {
"Homepage": "https://github.com/DataShades/ckanext-vip-portal"
},
"split_keywords": [
"ckan"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0601ca220dd2296e3e885acfebe1145c5ba8ed6aa6170252cf820bf49787896a",
"md5": "fb8d49b270ac8ccd8086ac9f8a49a654",
"sha256": "3f54e9583da393942d9d42694f6e8eb90f55cbce5f9050fecf225cb6db712d9c"
},
"downloads": -1,
"filename": "ckanext_vip_portal-0.2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fb8d49b270ac8ccd8086ac9f8a49a654",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 22062,
"upload_time": "2024-10-17T14:34:38",
"upload_time_iso_8601": "2024-10-17T14:34:38.466426Z",
"url": "https://files.pythonhosted.org/packages/06/01/ca220dd2296e3e885acfebe1145c5ba8ed6aa6170252cf820bf49787896a/ckanext_vip_portal-0.2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d0a6e1f78544064cff76f4ea29dc882c29d49bc0e7759a974a0ea94509473478",
"md5": "5dc078ed89dcff3f3b6e65b1d7b02b4f",
"sha256": "0aed7504e9a0774406c2e2af2adc37b6f4aa1c7018a3e479971b821fe29421c4"
},
"downloads": -1,
"filename": "ckanext_vip_portal-0.2.5.tar.gz",
"has_sig": false,
"md5_digest": "5dc078ed89dcff3f3b6e65b1d7b02b4f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21292,
"upload_time": "2024-10-17T14:34:40",
"upload_time_iso_8601": "2024-10-17T14:34:40.308091Z",
"url": "https://files.pythonhosted.org/packages/d0/a6/e1f78544064cff76f4ea29dc882c29d49bc0e7759a974a0ea94509473478/ckanext_vip_portal-0.2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-17 14:34:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DataShades",
"github_project": "ckanext-vip-portal",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "ckanext-vip-portal"
}