From 5c889866b3f1805da78908dc595f8a636a02eff0 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Wed, 17 Jul 2024 19:44:05 +0200 Subject: [PATCH] Refactor namespaced() method to web.auth.Flow base class --- src/main/php/web/auth/Flow.class.php | 13 +++++++++++++ src/main/php/web/auth/cas/CasFlow.class.php | 14 +------------- src/main/php/web/auth/oauth/OAuthFlow.class.php | 14 +------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/main/php/web/auth/Flow.class.php b/src/main/php/web/auth/Flow.class.php index 9866823..4d7190e 100755 --- a/src/main/php/web/auth/Flow.class.php +++ b/src/main/php/web/auth/Flow.class.php @@ -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 diff --git a/src/main/php/web/auth/cas/CasFlow.class.php b/src/main/php/web/auth/cas/CasFlow.class.php index 305ee21..b7007c6 100755 --- a/src/main/php/web/auth/cas/CasFlow.class.php +++ b/src/main/php/web/auth/cas/CasFlow.class.php @@ -9,7 +9,6 @@ class CasFlow extends Flow { private $sso; - private $namespace= 'cas::flow'; /** * Creates a new instance with a given SSO base url @@ -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'; } /** diff --git a/src/main/php/web/auth/oauth/OAuthFlow.class.php b/src/main/php/web/auth/oauth/OAuthFlow.class.php index d01d72c..83db688 100755 --- a/src/main/php/web/auth/oauth/OAuthFlow.class.php +++ b/src/main/php/web/auth/oauth/OAuthFlow.class.php @@ -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; } @@ -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