Skip to content

Commit

Permalink
Refactor namespaced() method to web.auth.Flow base class
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jul 17, 2024
1 parent 495f73a commit 5c88986
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
13 changes: 13 additions & 0 deletions src/main/php/web/auth/Flow.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ abstract class Flow {
const FRAGMENT= '_';

private $url= null;
protected $namespace;

/**
* Sets session namespace for this flow. Used to prevent conflicts
* in session state with multiple OAuth flows in place.
*
* @param string $namespace
* @return self
*/
public function namespaced($namespace) {
$this->namespace= $namespace;
return $this;
}

/**
* Targets a given URL
Expand Down
14 changes: 1 addition & 13 deletions src/main/php/web/auth/cas/CasFlow.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class CasFlow extends Flow {
private $sso;
private $namespace= 'cas::flow';

/**
* Creates a new instance with a given SSO base url
Expand All @@ -18,18 +17,7 @@ class CasFlow extends Flow {
*/
public function __construct($sso) {
$this->sso= rtrim($sso, '/');
}

/**
* Sets session namespace for this flow. Used to prevent conflicts
* in session state with multiple OAuth flows in place.
*
* @param string $namespace
* @return self
*/
public function namespaced($namespace) {
$this->namespace= $namespace;
return $this;
$this->namespace= 'cas::flow';
}

/**
Expand Down
14 changes: 1 addition & 13 deletions src/main/php/web/auth/oauth/OAuthFlow.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use web\auth\{Flow, UserInfo, AuthenticationError};

abstract class OAuthFlow extends Flow {
protected $callback, $namespace;
protected $callback;

/** @return ?util.URI */
public function callback() { return $this->callback; }
Expand All @@ -15,18 +15,6 @@ public function calling($callback): self {
return $this;
}

/**
* Sets session namespace for this flow. Used to prevent conflicts
* in session state with multiple OAuth flows in place.
*
* @param string $namespace
* @return self
*/
public function namespaced($namespace) {
$this->namespace= $namespace;
return $this;
}

/**
* Returns user info which fetched from the given endpoint using the
* authorized OAuth client
Expand Down

0 comments on commit 5c88986

Please sign in to comment.