-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] new Keycloak Login Provider Plugin via OIDC #822
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace app\plugins\keycloak_oidc_login; | ||
|
||
use app\components\LoginProviderInterface; | ||
use app\plugins\ModuleBase; | ||
|
||
class Module extends ModuleBase | ||
{ | ||
public const LOGIN_KEY = 'keycloak_oidc'; | ||
public const AUTH_KEY_USERS = 'keycloak_oidc'; | ||
|
||
private static ?LoginProviderInterface $loginProvider = null; | ||
|
||
public static function getDedicatedLoginProvider(): ?LoginProviderInterface | ||
{ | ||
if (self::$loginProvider === null) { | ||
self::$loginProvider = new OidcLogin( | ||
'https://keycloak.domain.com', | ||
'antragsgruen.domain.com', | ||
'supderdupersecret' | ||
Comment on lines
+21
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would love to set these credentials in the config.json - in the Admin panels would be ok too but if this would ever be the only way to log in (is this even possible right now?) then it would difficult to change these values if ever needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I don't have a really good way of storing plugin-specific credentials. For the discourse-plugin (✝) I put the configuration in a separate file next to the config.json : https://github.com/CatoTH/antragsgruen/blob/main/plugins/discourse/Module.php#L31 Using the admin panel would work too, using something like https://github.com/CatoTH/antragsgruen/blob/main/plugins/member_petitions/Module.php#L65 , but might be an overkill there |
||
); | ||
} | ||
return self::$loginProvider; | ||
} | ||
|
||
public static function getManagerUrlRoutes(string $domainPlain): array | ||
{ | ||
return [ | ||
$domainPlain . '/keycloak-oidc' => '/keycloak_oidc_login/login/login', | ||
]; | ||
} | ||
|
||
public static function getAllUrlRoutes(array $urls, string $dom, string $dommotion, string $dommotionOld, string $domamend, string $domamendOld): array | ||
{ | ||
return array_merge( | ||
[ | ||
$dom . 'keycloak-oidc' => '/keycloak_oidc_login/login/login', | ||
], | ||
parent::getAllUrlRoutes($urls, $dom, $dommotion, $dommotionOld, $domamend, $domamendOld) | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to require the OIDC Libary via composer? The Simplesaml Class from other Plugins is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not put it there. I try to only keep the dependencies in the main composer.json that will be part of the main distribution via ZIP file, without any plugins. So I don't want to put extra weight in there for this, the SAML or Redis parts. On the servers with those plugins, I do take some extra steps therefore, by manually installing yiisoft/yii2-redis predis/predis simplesamlphp/simplesamlphp after updating the dependencies.