I use services with drupal 7, here the services resources function :
function custom_api_services_resources()
{
return [
'res' => [
'create' => [
'callback' => 'custom_api_create_user',
'access arguments' => array('administer access control'),
'access arguments append' => FALSE,
'args' => [
[
'name' => 'data',
'type' => 'struct',
'description' => 'data',
'optional' => FALSE,
'source' => 'data'
]
],
]
]
];
}
Here the node access function (empty) :
function custom_api_node_access($op, $data) {
}
For Authentication I use HTTP basic authentication and/or Session authentication
I don't know what I have to do to limit access only for admin. I've tried a lot but never work with authentication.
I feel like it's very easy to use it, but I don't understand it.
I've already posted a message about this issue but differently. Can someone delete the first one, please ? How do I use the access arguments?
Edit
custom_api.module file :
'create' => [
'callback' => 'custom_api_create_users',
'access callback' => 'custom_api_access_callback',
'access arguments' => array('administer create field_projects'),
'access arguments append' => TRUE,
'access callback file' => array(
'type' => 'inc',
'module' => 'support',
'name' => 'custom_api.resource',
),
'args' => [
[
'name' => 'data',
'type' => 'struct',
'description' => 'data',
'optional' => FALSE,
'source' => 'data'
]
]
custom_api.resource.inc :
function custom_api_access_callback($permission) {
return user_access($permission);
}
Permission from Database, role_permission table :
Permission : access comments Module : comment
Permission : access content Module : node
Permission : access news feeds Module : aggregator
Permission : access site map Module : site_map
Permission : create field_credits Module : field_permissions
Permission : create field_credit_level_1 Module : field_permissions
Permission : create field_credit_level_2 Module : field_permissions
Permission : create field_credit_level_3 Module : field_permissions
Permission : create field_level Module : field_permissions
Permission : create field_number_of_credit_remove Module : field_permissions
Permission : create field_projects Module : field_permissions
Permission : create field_remove_credit Module : field_permissions
Permission : search content Module : search
Permission : subscribe to newsletters Module : simplenews
Permission : use advanced search Module : search
Permission : use custom search Module : custom_search
Permission : use custom search blocks Module : custom_search_blocks
Permission : use text format guestbook_txt Module : filter
Permission : access comments Module : comment
Permission : access content Module : node
Permission : access news feeds Module : aggregator
Permission : access site map Module : site_map
Permission : administer custom search Module : custom_search
Permission : administer custom search blocks Module : custom_search_blocks
Permission : administer search Module : search
I have link to add data (client and node : project and client) in drupal website. Only administrators can add data.
hook_node_access
for creating a user?