ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
OAuthServer Class Reference
+ Inheritance diagram for OAuthServer:
+ Collaboration diagram for OAuthServer:

Public Member Functions

 __construct ($data_store)
 
 add_signature_method ($signature_method)
 
 fetch_request_token (&$request)
 process a request_token request returns the request token on success More...
 
 fetch_access_token (&$request)
 process an access_token request returns the access token on success More...
 
 verify_request (&$request)
 verify an api call, checks all the parameters More...
 

Protected Attributes

 $timestamp_threshold = 300
 
 $version = '1.0'
 
 $signature_methods = array()
 
 $data_store
 

Private Member Functions

 get_version (&$request)
 version 1 More...
 
 get_signature_method ($request)
 figure out the signature with some defaults More...
 
 get_consumer ($request)
 try to find the consumer for the provided request's consumer key More...
 
 get_token ($request, $consumer, $token_type="access")
 try to find the token for the provided request's token key More...
 
 check_signature ($request, $consumer, $token)
 all-in-one function to check the signature on a request should guess the signature method appropriately More...
 
 check_timestamp ($timestamp)
 check that the timestamp is new enough More...
 
 check_nonce ($consumer, $token, $nonce, $timestamp)
 check that the nonce is not repeated More...
 

Detailed Description

Definition at line 552 of file OAuth.php.

Constructor & Destructor Documentation

◆ __construct()

OAuthServer::__construct (   $data_store)

Definition at line 560 of file OAuth.php.

561 {
562 $this->data_store = $data_store;
563 }

References $data_store.

Member Function Documentation

◆ add_signature_method()

OAuthServer::add_signature_method (   $signature_method)

Definition at line 565 of file OAuth.php.

566 {
567 $this->signature_methods[$signature_method->get_name()] =
568 $signature_method;
569 }

◆ check_nonce()

OAuthServer::check_nonce (   $consumer,
  $token,
  $nonce,
  $timestamp 
)
private

check that the nonce is not repeated

Definition at line 772 of file OAuth.php.

773 {
774 if (!$nonce) {
775 throw new OAuthException(
776 'Missing nonce parameter. The parameter is required'
777 );
778 }
779
780 // verify that the nonce is uniqueish
781 $found = $this->data_store->lookup_nonce(
782 $consumer,
783 $token,
784 $nonce,
786 );
787 if ($found) {
788 throw new OAuthException("Nonce already used: $nonce");
789 }
790 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81

References $timestamp, and PHPMailer\PHPMailer\$token.

Referenced by check_signature().

+ Here is the caller graph for this function:

◆ check_signature()

OAuthServer::check_signature (   $request,
  $consumer,
  $token 
)
private

all-in-one function to check the signature on a request should guess the signature method appropriately

Definition at line 721 of file OAuth.php.

722 {
723 // this should probably be in a different method
724 $timestamp = $request instanceof OAuthRequest
725 ? $request->get_parameter('oauth_timestamp')
726 : null;
727 $nonce = $request instanceof OAuthRequest
728 ? $request->get_parameter('oauth_nonce')
729 : null;
730
732 $this->check_nonce($consumer, $token, $nonce, $timestamp);
733
734 $signature_method = $this->get_signature_method($request);
735
736 $signature = $request->get_parameter('oauth_signature');
737 $valid_sig = $signature_method->check_signature(
738 $request,
739 $consumer,
740 $token,
741 $signature
742 );
743
744 if (!$valid_sig) {
745 throw new OAuthException("Invalid signature");
746 }
747 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
check_nonce($consumer, $token, $nonce, $timestamp)
check that the nonce is not repeated
Definition: OAuth.php:772
check_timestamp($timestamp)
check that the timestamp is new enough
Definition: OAuth.php:752
get_signature_method($request)
figure out the signature with some defaults
Definition: OAuth.php:650

References $request, $timestamp, PHPMailer\PHPMailer\$token, check_nonce(), check_timestamp(), and get_signature_method().

Referenced by fetch_access_token(), fetch_request_token(), and verify_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_timestamp()

OAuthServer::check_timestamp (   $timestamp)
private

check that the timestamp is new enough

Definition at line 752 of file OAuth.php.

753 {
754 if (!$timestamp) {
755 throw new OAuthException(
756 'Missing timestamp parameter. The parameter is required'
757 );
758 }
759
760 // verify that timestamp is recentish
761 $now = time();
762 if (abs($now - $timestamp) > $this->timestamp_threshold) {
763 throw new OAuthException(
764 "Expired timestamp, yours $timestamp, ours $now"
765 );
766 }
767 }

References $timestamp.

Referenced by check_signature().

+ Here is the caller graph for this function:

◆ fetch_access_token()

OAuthServer::fetch_access_token ( $request)

process an access_token request returns the access token on success

Definition at line 599 of file OAuth.php.

600 {
601 $this->get_version($request);
602
603 $consumer = $this->get_consumer($request);
604
605 // requires authorized request token
606 $token = $this->get_token($request, $consumer, "request");
607
608 $this->check_signature($request, $consumer, $token);
609
610 // Rev A change
611 $verifier = $request->get_parameter('oauth_verifier');
612 $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
613
614 return $new_token;
615 }
get_token($request, $consumer, $token_type="access")
try to find the token for the provided request's token key
Definition: OAuth.php:697
check_signature($request, $consumer, $token)
all-in-one function to check the signature on a request should guess the signature method appropriate...
Definition: OAuth.php:721
get_version(&$request)
version 1
Definition: OAuth.php:633
get_consumer($request)
try to find the consumer for the provided request's consumer key
Definition: OAuth.php:676

References $request, PHPMailer\PHPMailer\$token, check_signature(), get_consumer(), get_token(), and get_version().

+ Here is the call graph for this function:

◆ fetch_request_token()

OAuthServer::fetch_request_token ( $request)

process a request_token request returns the request token on success

Definition at line 577 of file OAuth.php.

578 {
579 $this->get_version($request);
580
581 $consumer = $this->get_consumer($request);
582
583 // no token required for the initial token request
584 $token = NULL;
585
586 $this->check_signature($request, $consumer, $token);
587
588 // Rev A change
589 $callback = $request->get_parameter('oauth_callback');
590 $new_token = $this->data_store->new_request_token($consumer, $callback);
591
592 return $new_token;
593 }

References $request, PHPMailer\PHPMailer\$token, check_signature(), get_consumer(), and get_version().

+ Here is the call graph for this function:

◆ get_consumer()

OAuthServer::get_consumer (   $request)
private

try to find the consumer for the provided request's consumer key

Definition at line 676 of file OAuth.php.

677 {
678 $consumer_key = $request instanceof OAuthRequest
679 ? $request->get_parameter("oauth_consumer_key")
680 : NULL;
681
682 if (!$consumer_key) {
683 throw new OAuthException("Invalid consumer key");
684 }
685
686 $consumer = $this->data_store->lookup_consumer($consumer_key);
687 if (!$consumer) {
688 throw new OAuthException("Invalid consumer");
689 }
690
691 return $consumer;
692 }

References $request.

Referenced by fetch_access_token(), fetch_request_token(), and verify_request().

+ Here is the caller graph for this function:

◆ get_signature_method()

OAuthServer::get_signature_method (   $request)
private

figure out the signature with some defaults

Definition at line 650 of file OAuth.php.

651 {
652 $signature_method = $request instanceof OAuthRequest
653 ? $request->get_parameter("oauth_signature_method")
654 : NULL;
655
656 if (!$signature_method) {
657 // According to chapter 7 ("Accessing Protected Ressources") the signature-method
658 // parameter is required, and we can't just fallback to PLAINTEXT
659 throw new OAuthException('No signature method parameter. This parameter is required');
660 }
661
662 if (!in_array($signature_method,
663 array_keys($this->signature_methods))) {
664 throw new OAuthException(
665 "Signature method '$signature_method' not supported " .
666 "try one of the following: " .
667 implode(", ", array_keys($this->signature_methods))
668 );
669 }
670 return $this->signature_methods[$signature_method];
671 }

References $request.

Referenced by check_signature().

+ Here is the caller graph for this function:

◆ get_token()

OAuthServer::get_token (   $request,
  $consumer,
  $token_type = "access" 
)
private

try to find the token for the provided request's token key

Definition at line 697 of file OAuth.php.

698 {
699 $token_field = $request instanceof OAuthRequest
700 ? $request->get_parameter('oauth_token')
701 : null;
702
703 if (!empty($token_field)) {
704 $token = $this->data_store->lookup_token(
705 $consumer, $token_type, $token_field
706 );
707 if (!$token) {
708 throw new OAuthException("Invalid $token_type token: $token_field");
709 }
710 }
711 else {
712 $token = new OAuthToken('', '');
713 }
714 return $token;
715 }
OAuth PECL extension includes an OAuth Exception class, so we need to wrap the definition of this cla...
Definition: OAuth.php:43

References $request, and PHPMailer\PHPMailer\$token.

Referenced by fetch_access_token(), and verify_request().

+ Here is the caller graph for this function:

◆ get_version()

OAuthServer::get_version ( $request)
private

version 1

Definition at line 633 of file OAuth.php.

634 {
635 $version = $request->get_parameter("oauth_version");
636 if (!$version) {
637 // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
638 // Chapter 7.0 ("Accessing Protected Ressources")
639 $version = '1.0';
640 }
641 if ($version !== $this->version) {
642 throw new OAuthException("OAuth version '$version' not supported");
643 }
644 return $version;
645 }

References $request, and $version.

Referenced by fetch_access_token(), fetch_request_token(), and verify_request().

+ Here is the caller graph for this function:

◆ verify_request()

OAuthServer::verify_request ( $request)

verify an api call, checks all the parameters

Definition at line 620 of file OAuth.php.

621 {
622 $this->get_version($request);
623 $consumer = $this->get_consumer($request);
624 $token = $this->get_token($request, $consumer, "access");
625 $this->check_signature($request, $consumer, $token);
626 return array($consumer, $token);
627 }

References $request, PHPMailer\PHPMailer\$token, check_signature(), get_consumer(), get_token(), and get_version().

+ Here is the call graph for this function:

Field Documentation

◆ $data_store

OAuthServer::$data_store
protected

Definition at line 558 of file OAuth.php.

Referenced by __construct().

◆ $signature_methods

OAuthServer::$signature_methods = array()
protected

Definition at line 556 of file OAuth.php.

Referenced by sspmod_oauth_OAuthServer\get_signature_methods().

◆ $timestamp_threshold

OAuthServer::$timestamp_threshold = 300
protected

Definition at line 554 of file OAuth.php.

◆ $version

OAuthServer::$version = '1.0'
protected

Definition at line 555 of file OAuth.php.

Referenced by get_version().


The documentation for this class was generated from the following file: