Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MatrixPlugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stud.IP
Plugins
MatrixPlugin
Commits
4cc5d80d
Commit
4cc5d80d
authored
3 years ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
system account login via WebSSO token
parent
b4afcfaa
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
migrations/02_add_matrix_login_token.php
+48
-0
48 additions, 0 deletions
migrations/02_add_matrix_login_token.php
models/MatrixAccount.php
+16
-5
16 additions, 5 deletions
models/MatrixAccount.php
vendor/libpatrix
+1
-1
1 addition, 1 deletion
vendor/libpatrix
with
65 additions
and
6 deletions
migrations/02_add_matrix_login_token.php
0 → 100644
+
48
−
0
View file @
4cc5d80d
<?php
/**
* Class AddMatrixLoginToken
* Adds the option for the service account to have a login token
* instead of a password.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Thomas Hackl <hackl@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Matrix
*/
class
AddMatrixLoginToken
extends
Migration
{
public
function
description
()
{
return
'Adds the option to have a login token for WebSSO instead of a password.'
;
}
public
function
up
()
{
try
{
Config
::
get
()
->
create
(
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
,
[
'value'
=>
''
,
'type'
=>
'string'
,
'range'
=>
'global'
,
'section'
=>
'matrix'
,
'description'
=>
'WebSSO-Token zum Login des Serviceaccounts. Ist dieser Wert gesetzt, '
.
'wird er statt eines möglicherweise ebenfalls angegebenen Passworts verwendet.'
]);
}
catch
(
Exception
$e
)
{
}
}
public
function
down
()
{
// Remove config entry.
Config
::
get
()
->
delete
(
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
models/MatrixAccount.php
+
16
−
5
View file @
4cc5d80d
...
@@ -56,14 +56,24 @@ class MatrixAccount extends SimpleORMap
...
@@ -56,14 +56,24 @@ class MatrixAccount extends SimpleORMap
*/
*/
public
static
function
requireSystemAccount
()
public
static
function
requireSystemAccount
()
{
{
if
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
!=
''
if
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
)
!=
''
&&
&&
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_PASSWORD
!=
''
)
{
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_PASSWORD
)
!=
''
||
$account
=
new
Patrix\Account
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
,
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_TOKEN
)
!=
''
))
{
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_PASSWORD
);
// Login token specified, use this.
if
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_TOKEN
)
!=
''
)
{
$account
=
new
Patrix\Account
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
),
''
,
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_TOKEN
));
// No token, login by username and password.
}
else
{
$account
=
new
Patrix\Account
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
),
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_PASSWORD
));
}
MatrixClient
::
get
()
->
login
(
$account
);
MatrixClient
::
get
()
->
login
(
$account
);
return
$account
;
return
$account
;
}
else
{
}
else
{
//$username = 'studip-' . Config::get()->STUDIP_INSTALLATION_ID;
$username
=
'studip'
;
$username
=
'studip'
;
$password
=
self
::
randomPassword
();
$password
=
self
::
randomPassword
();
$sysaccount
=
new
\Patrix\Account
(
$username
,
$password
);
$sysaccount
=
new
\Patrix\Account
(
$username
,
$password
);
...
@@ -74,6 +84,7 @@ class MatrixAccount extends SimpleORMap
...
@@ -74,6 +84,7 @@ class MatrixAccount extends SimpleORMap
}
else
{
}
else
{
return
null
;
return
null
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
libpatrix
@
4d31e1a0
Subproject commit 4
03ac1cf84c817250e8b2757feb07d85dabdad7f
Subproject commit 4
d31e1a0c3a02b75415b478d698b8096c057d749
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment