Skip to content

Instantly share code, notes, and snippets.

View justingreerbbi's full-sized avatar

Justin Greer justingreerbbi

View GitHub Profile
@justingreerbbi
justingreerbbi / gist:a99ef8760bb914b420c7f5d68ec7f392
Created June 21, 2016 18:29
Fix for user claims in auth code id_token issue
<?php
namespace OAuth2\OpenID\Controller;
use OAuth2\Controller\AuthorizeController as BaseAuthorizeController;
use OAuth2\RequestInterface;
use OAuth2\ResponseInterface;
/**
* @see OAuth2\Controller\AuthorizeControllerInterface
@justingreerbbi
justingreerbbi / gist:72e67558e6f34450f2af81e878907876
Created June 20, 2016 15:59
Allow only one access token per user using filter
function test_wo_restrict_single_access_token( $restriction ){
return true;
}
add_filter('wo_restrict_single_access_token', 'test_wo_restrict_single_access_token');
@justingreerbbi
justingreerbbi / gist:658295550b60cde3e3f25ee6348eba30
Created June 20, 2016 15:08
Override default auth code lifetime
function test_wo_auth_code_lifetime( $auth_code_lifetime ){
return 60; // seconds
}
add_filter( 'wo_auth_code_lifetime', 'test_wo_auth_code_lifetime' );
@justingreerbbi
justingreerbbi / gist:51eae4f71d621f231f67a36f9582a9bf
Created June 20, 2016 14:20
User action to overide auto authorization with grant type auth code for WP OAuth Server
function test_wo_authorization_code_authorize( $user_id ) {
exit( 'Run code to handle custom authorization instead of auto authorization ' . $user_id );
}
add_action( 'wo_authorization_code_authorize', 'test_wo_authorization_code_authorize' );
add_filter( 'wo_endpoints', 'wo_extend_endpoints' );
function wo_extend_endpoints ( $endpoints ){
$endpoints = array(
'is_logged_in' => array(
'func' => '_wo_is_logged_in_wo7391',
'public' => false
)
);
return $endpoints;
@justingreerbbi
justingreerbbi / me-method.html
Created May 31, 2016 03:55
Simple Form for "ME" method
<p>Me Method</p>
<form action="https://wp-oauth.com/oauth/me" method="GET">
<input type="text" name="access_token" value="" />
<button type="submit">Call Me Method</button>
</form>
@justingreerbbi
justingreerbbi / client.js
Created May 12, 2016 00:07
Titanium mobile/Appcelirator OAuth 2 basic client
/**
* OAuth 2.0 CommonJS Client for Titanium Mobile
*
* @author Justin Greer <[email protected]>
* @copyright 2015 Justin Greer
* @version 1.0.0
*/
var Client = function() {
this._serverUrl = 'serverurl.com'; //without trailing slash
this._clientId = 'client_id'; // client id form WP OAuth Server
@justingreerbbi
justingreerbbi / nodebb-config-example
Created May 3, 2016 12:47
nodeBB Config Example
var constants = Object.freeze({
type:'oauth2',
name:'wpoauthserver', // Something unique to your OAuth provider in lowercase, like “github”, or “nodebb”
oauth: {
requestTokenURL: '',
accessTokenURL: '',
userAuthorizationURL: '',
consumerKey:'',
consumerSecret: ''
},
<form action="<?php echo $server_url; ?>/oauth/token" method="POST">
<input type="text" name="refresh_token" value="" />
<input type="hidden" name="grant_type" value="refresh_token" />
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>" />
<input type="hidden" name="client_secret" value="<?php echo $client_secret; ?>" />
<button type="submit">Request New</button>
</form>
<?php
/**
* Simple Example of a client calling WordPress OAuth Server
* Replace the variabls below with your own.
*
* @author Justin Greer <[email protected]>
*/
$server_url = 'https://wordpress.dev';
$client_id = '6lkmsGocFcvxVG4S5s3QCHGi5Pvutl8AHtXaalmP';
$client_secret = 'yRntyrmDTquw7bOd0kHuFQ5mj2wtnSjVKGpi8MW2';