|
|
@ -30,7 +30,7 @@ class Auth |
|
|
|
// Defaults |
|
|
|
// Defaults |
|
|
|
public const DEFAULT_RESPONSE = GtkResponseType::CANCEL; |
|
|
|
public const DEFAULT_RESPONSE = GtkResponseType::CANCEL; |
|
|
|
public const FORMAT_SECONDARY_TEXT = 'Select identity'; |
|
|
|
public const FORMAT_SECONDARY_TEXT = 'Select identity'; |
|
|
|
public const MESSAGE_FORMAT = 'Authorization'; |
|
|
|
public const MESSAGE_FORMAT = 'Auth'; |
|
|
|
|
|
|
|
|
|
|
|
public const MARGIN = 8; |
|
|
|
public const MARGIN = 8; |
|
|
|
public const SPACING = 1; |
|
|
|
public const SPACING = 1; |
|
|
@ -71,6 +71,13 @@ class Auth |
|
|
|
$this::SPACING |
|
|
|
$this::SPACING |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add separator |
|
|
|
|
|
|
|
$content->add( |
|
|
|
|
|
|
|
new GtkSeparator( |
|
|
|
|
|
|
|
GtkOrientation::VERTICAL |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Init new certificate option |
|
|
|
// Init new certificate option |
|
|
|
$this->_options[ |
|
|
|
$this->_options[ |
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
@ -96,7 +103,7 @@ class Auth |
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
|
]->useName(); |
|
|
|
]->useName(); |
|
|
|
|
|
|
|
|
|
|
|
// Search database for auth records |
|
|
|
// Build records from database |
|
|
|
foreach ($this->page->container->browser->database->auth->like( |
|
|
|
foreach ($this->page->container->browser->database->auth->like( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'%s%%', |
|
|
|
'%s%%', |
|
|
@ -107,28 +114,48 @@ class Auth |
|
|
|
// Get related identity records |
|
|
|
// Get related identity records |
|
|
|
if ($identity = $this->page->container->browser->database->identity->get($auth->identity)) |
|
|
|
if ($identity = $this->page->container->browser->database->identity->get($auth->identity)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_options[$identity->id] = new Auth\Option\Identity( |
|
|
|
$this->_options[ |
|
|
|
|
|
|
|
$identity->id |
|
|
|
|
|
|
|
] = new Auth\Option\Identity( |
|
|
|
$this |
|
|
|
$this |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$this->_options[$identity->id]->setGroup( |
|
|
|
$this->_options[ |
|
|
|
|
|
|
|
$identity->id |
|
|
|
|
|
|
|
]->setGroup( |
|
|
|
$this->_options[ |
|
|
|
$this->_options[ |
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$this->_options[$identity->id]->setLabel( |
|
|
|
$this->_options[ |
|
|
|
|
|
|
|
$identity->id |
|
|
|
|
|
|
|
]->setLabel( |
|
|
|
$identity->id, |
|
|
|
$identity->id, |
|
|
|
$identity->name |
|
|
|
$identity->name |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Append separator |
|
|
|
// Append logout option |
|
|
|
$content->add( |
|
|
|
$this->_options[ |
|
|
|
new GtkSeparator( |
|
|
|
Auth\Option\Identity::ID_LOG_OUT |
|
|
|
GtkOrientation::VERTICAL |
|
|
|
] = new Auth\Option\Identity( |
|
|
|
) |
|
|
|
$this |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_options[ |
|
|
|
|
|
|
|
Auth\Option\Identity::ID_LOG_OUT |
|
|
|
|
|
|
|
]->setGroup( |
|
|
|
|
|
|
|
$this->_options[ |
|
|
|
|
|
|
|
Auth\Option\Identity::ID_CRT_NEW |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_options[ |
|
|
|
|
|
|
|
Auth\Option\Identity::ID_LOG_OUT |
|
|
|
|
|
|
|
]->setLabel( |
|
|
|
|
|
|
|
Auth\Option\Identity::ID_LOG_OUT |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Build options list |
|
|
|
// Build options list |
|
|
@ -173,7 +200,7 @@ class Auth |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Append empty line separator |
|
|
|
// Add final separator |
|
|
|
$content->add( |
|
|
|
$content->add( |
|
|
|
new GtkLabel |
|
|
|
new GtkLabel |
|
|
|
); |
|
|
|
); |
|
|
@ -189,32 +216,31 @@ class Auth |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($option->gtk->get_active()) |
|
|
|
if ($option->gtk->get_active()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Logout previous identities for this request |
|
|
|
// Route ID |
|
|
|
|
|
|
|
switch ($id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case Auth\Option\Identity::ID_LOG_OUT: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Logout previous session |
|
|
|
$this->page->container->browser->database->auth->logout( |
|
|
|
$this->page->container->browser->database->auth->logout( |
|
|
|
$this->page->navbar->request->getValue() |
|
|
|
$this->page->navbar->request->getValue() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Activate existing identity |
|
|
|
break; |
|
|
|
if ($id) |
|
|
|
|
|
|
|
{ |
|
|
|
case Auth\Option\Identity::ID_CRT_NEW: |
|
|
|
// Add new auth record |
|
|
|
|
|
|
|
$this->page->container->browser->database->auth->add( |
|
|
|
// Logout previous session |
|
|
|
$id, |
|
|
|
$this->page->container->browser->database->auth->logout( |
|
|
|
$this->page->navbar->request->getValue() |
|
|
|
$this->page->navbar->request->getValue() |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generate new identity |
|
|
|
// Detect identity driver |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Detect driver |
|
|
|
|
|
|
|
switch (true) |
|
|
|
switch (true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case mb_strtolower( |
|
|
|
case parse_url( |
|
|
|
parse_url( |
|
|
|
|
|
|
|
$this->page->navbar->request->getValue(), |
|
|
|
$this->page->navbar->request->getValue(), |
|
|
|
PHP_URL_SCHEME |
|
|
|
PHP_URL_SCHEME |
|
|
|
) |
|
|
|
|
|
|
|
) == 'gemini': |
|
|
|
) == 'gemini': |
|
|
|
|
|
|
|
|
|
|
|
// Init identity model |
|
|
|
// Init identity model |
|
|
@ -236,9 +262,25 @@ class Auth |
|
|
|
|
|
|
|
|
|
|
|
throw new Exception; |
|
|
|
throw new Exception; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Logout previous session |
|
|
|
|
|
|
|
$this->page->container->browser->database->auth->logout( |
|
|
|
|
|
|
|
$this->page->navbar->request->getValue() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add new auth record |
|
|
|
|
|
|
|
$this->page->container->browser->database->auth->add( |
|
|
|
|
|
|
|
$id, |
|
|
|
|
|
|
|
$this->page->navbar->request->getValue() |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->destroy(); |
|
|
|
$this->destroy(); |
|
|
|