Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mundanity committed Oct 12, 2016
0 parents commit e49e5ba
Show file tree
Hide file tree
Showing 18 changed files with 1,688 additions and 0 deletions.
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "mundanity/oauth2server",
"description": "A lightweight OAuth2 server for Drupal",
"homepage": "https://github.com/mundanity/oauth2server",
"authors": [
{
"name": "Owen Loy",
"email": "[email protected]",
"homepage": "http://www.mundanity.com"
}
],
"license": "MIT",
"require": {
"php": "~5.5",
"mundanity/drupal-logger": "~1.0.0",
"league/oauth2-server": "~4.1.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mundanity/drupal-logger.git"
}
],
"autoload": {
"psr-4": {"Drupal\\oauth2server\\": "src/"}
}
}
25 changes: 25 additions & 0 deletions oauth2server.admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* Administrative configuration form.
*
*/
function oauth2server_admin_form($form, &$form_state) {

$form['oauth2server_access_token_ttl'] = [
'#type' => 'textfield',
'#size' => 10,
'#title' => t('Access token TTL'),
'#description' => t('The time (in seconds) a provisioned access token will be valid for (default 3600s).'),
'#default_value' => variable_get('oauth2server_access_token_ttl', 3600),
];
$form['oauth2server_is_authorization_server'] = [
'#type' => 'checkbox',
'#title' => t('Enable authorization server.'),
'#description' => t('If enabled, this Drupal site will act as an authorization server, and provide an "access_token" endpoint.'),
'#default_value' => variable_get('oauth2server_is_authorization_server', TRUE),
];

return system_settings_form($form);

}
31 changes: 31 additions & 0 deletions oauth2server.drush.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* Implements hook_drush_command().
*
*/
function oauth2server_drush_command() {

$items['oauth2server-expire-tokens'] = [
'description' => dt('Expires access tokens, refresh tokens, and authorization codes.'),
'aliases' => ['oauth2server-expire'],
];

return $items;

}


/**
* Expires access tokens, refresh tokens, and authorization codes.
*
*/
function drush_oauth2server_expire_tokens() {

$count = oauth2server_expire_tokens();

drush_log(dt('Expired !count access tokens', ['!count' => $count->access_tokens]), 'ok');
drush_log(dt('Expired !count refresh tokens', ['!count' => $count->refresh_tokens]), 'ok');
drush_log(dt('Expired !count authorization codes', ['!count' => $count->auth_codes]), 'ok');

}
7 changes: 7 additions & 0 deletions oauth2server.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "OAuth2 Server"
description = "Theoretically lightweight OAuth2 server"
core = 7.x
php = 5.5

dependencies[] = restapi
dependencies[] = xautoload
Loading

0 comments on commit e49e5ba

Please sign in to comment.