backend/app/routing/routers/api/v1/sharing.routes.js

60 lines
2.1 KiB
JavaScript
Raw Normal View History

/*
* API v1 Routes
* -------------------------------------------------------------
* Description here
*/
const index = {
prefix: '/api/v1/share',
get: {
'/page/:PageId/info': [
'middleware::auth:UserOnly',
['middleware::api:RequiredFields', { form: 'sharing.page' }],
['middleware::api:PageRoute', {level: 'manage'}],
'controller::api:v1:Sharing.page_info',
],
'/page/:PageId/link/:level': [
'middleware::auth:UserOnly',
['middleware::api:RequiredFields', { form: 'sharing.page_link'}],
['middleware::api:PageRoute', {level: 'manage'}],
'controller::api:v1:Sharing.get_link',
],
},
post: {
// Share a page with the specified user.
'/page/:PageId/share': [
'middleware::auth:UserOnly',
['middleware::api:RequiredFields', { form: 'sharing.page_level' }],
['middleware::api:PageRoute', {level: 'manage'}],
['middleware::api:UserRoute', { allow_public_user: true }],
'controller::api:v1:Sharing.share_page',
],
// Unshare a page with the specified user.
'/page/:PageId/revoke': [
'middleware::auth:UserOnly',
['middleware::api:RequiredFields', { form: 'sharing.page_user' }],
['middleware::api:PageRoute', {level: 'manage'}],
['middleware::api:UserRoute', { allow_public_user: true }],
'controller::api:v1:Sharing.revoke_page',
],
// Check the public user's access to a given resource
'/check': [
['middleware::api:RequiredFields', { form: 'sharing.permission_check'}],
['middleware::auth:ApiRoute', { allow_public: true }],
'controller::api:v1:Sharing.permission_check',
],
// Check the public user's access to a given page
'/check-page/:PageId/:level': [
['middleware::auth:ApiRoute', { allow_public: true }],
'controller::api:v1:Sharing.permission_check_page',
],
},
}
module.exports = exports = index