This repository has been archived by the owner on Feb 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth2_loginprovider.drush.inc
78 lines (73 loc) · 1.94 KB
/
oauth2_loginprovider.drush.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @file
* Drush commands for managing oauth2_server clients.
*/
/**
* Implementation of hook_drush_command().
*
* @return
* An associative array describing commands.
*/
function oauth2_loginprovider_drush_command() {
return array(
'oauth2-client-ls' => array(
'description' => "List registered oauth2 clients.",
),
'oauth2-client-add' => array(
'description' => "Add a new oauth2 client.",
'arguments' => array(
'client_key' => '',
'client_secret' => '',
'redirect_uri' => '',
),
),
'oauth2-client-del' => array(
'description' => "Delete oauth2 client if exists.",
'arguments' => array(
'client_key' => 'The key of the client.',
),
),
);
}
/**
* Implementation of hook_drush_help().
*
* @param
* A string with the help section (prepend with 'drush:')
*
* @return
* A string with the help text for your command.
*/
function oauth2_loginprovider_drush_help($section) {
switch ($section) {
case 'drush:oauth2-client-ls':
return dt("List registered oauth2 clients.");
case 'drush:oauth2-client-add':
return dt("Add a new oauth2 client.");
case 'drush:oauth2-client-del':
return dt("Delete oauth2 client if exists.");
}
}
/**
* Callback function for the command 'oauth2-client-ls'.
*/
function drush_oauth2_loginprovider_oauth2_client_ls() {
$clients = oauth2_client_list();
print "client_key,redirect_uri\n";
foreach ($clients as $client) {
print "$client->client_key,$client->redirect_uri\n";
}
}
/**
* Callback function for the command 'oauth2-client-add'.
*/
function drush_oauth2_loginprovider_oauth2_client_add($client_key, $client_secret, $redirect_uri) {
oauth2_client_add($client_key, $client_secret, $redirect_uri);
}
/**
* Callback function for the command 'oauth2-client-del'.
*/
function drush_oauth2_loginprovider_oauth2_client_del($client_key) {
oauth2_client_del($client_key);
}