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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stud.IP
Plugins
MatrixPlugin
Commits
173d0324
Commit
173d0324
authored
3 years ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
using access token, thus skipping login in requireSystemAccount()
parent
d1c28135
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
migrations/04_rename_matrix_login_token_entry.php
+72
-0
72 additions, 0 deletions
migrations/04_rename_matrix_login_token_entry.php
models/MatrixAccount.php
+6
-8
6 additions, 8 deletions
models/MatrixAccount.php
plugin.manifest
+1
-1
1 addition, 1 deletion
plugin.manifest
with
79 additions
and
9 deletions
migrations/04_rename_matrix_login_token_entry.php
0 → 100644
+
72
−
0
View file @
173d0324
<?php
/**
* Class RenameMatrixLoginTokenEntry
* Service account has an access token instead of a login token.
* Reflect this in the config entry name.
*
* 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
RenameMatrixLoginTokenEntry
extends
Migration
{
public
function
description
()
{
return
'Service account has an access token instead of a login token. Reflect this in the config entry name.'
;
}
public
function
up
()
{
DBManager
::
get
()
->
execute
(
"UPDATE `config` SET `field` = :newname, `description`= :newdesc WHERE `field` = :oldname"
,
[
'oldname'
=>
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
,
'newname'
=>
'MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN'
,
'newdesc'
=>
'WebSSO-Token zur Authentifizierung des Serviceaccounts. Ist dieser Wert gesetzt, '
.
'wird ein eventuell ebenfalls eingetragenes Passwort nicht verwendet.'
]
);
DBManager
::
get
()
->
execute
(
"UPDATE `config_values` SET `field` = :newname WHERE `field` = :oldname"
,
[
'oldname'
=>
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
,
'newname'
=>
'MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN'
]
);
}
public
function
down
()
{
$update
=
[
'oldname'
=>
'MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN'
,
'newname'
=>
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
,
'newdesc'
=>
'WebSSO-Token zum Login des Serviceaccounts. Ist dieser Wert gesetzt, '
.
'wird er statt eines möglicherweise ebenfalls angegebenen Passworts verwendet.'
];
DBManager
::
get
()
->
execute
(
"UPDATE `config` SET `field` = :newname, `description`= :newdesc WHERE `field` = :oldname"
,
[
'oldname'
=>
'MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN'
,
'newname'
=>
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
,
'newdesc'
=>
'WebSSO-Token zum Login des Serviceaccounts. Ist dieser Wert gesetzt, '
.
'wird er statt eines möglicherweise ebenfalls angegebenen Passworts verwendet.'
]
);
DBManager
::
get
()
->
execute
(
"UPDATE `config_values` SET `field` = :newname WHERE `field` = :oldname"
,
[
'oldname'
=>
'MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN'
,
'newname'
=>
'MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN'
]
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
models/MatrixAccount.php
+
6
−
8
View file @
173d0324
...
...
@@ -58,20 +58,18 @@ class MatrixAccount extends SimpleORMap
{
if
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
)
!=
''
&&
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_PASSWORD
)
!=
''
||
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_
LOGIN
_TOKEN
)
!=
''
))
{
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_
ACCESS
_TOKEN
)
!=
''
))
{
// Login token specified, use this.
if
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN
)
!=
''
)
{
$account
=
new
Patrix\Account
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
),
''
,
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_LOGIN_TOKEN
));
$viaToken
=
true
;
// Access token specified, use this (and skip login because the token can be used directly).
if
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN
)
!=
''
)
{
$account
=
new
Patrix\Account
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_USERNAME
),
''
);
$account
->
setAccessData
(
trim
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN
),
'Stud.IP'
);
// 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
));
$viaToken
=
false
;
MatrixClient
::
get
()
->
login
(
$account
)
;
}
MatrixClient
::
get
()
->
login
(
$account
,
$viaToken
);
return
$account
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
plugin.manifest
+
1
−
1
View file @
173d0324
pluginname=Matrix-Chat
pluginclassname=MatrixPlugin
origin=data-quest
version=1.
1.
2
version=1.2
screenshot=assets/images/matrix_logo.png
description=Matrix chat for Stud.IP courses
studipMinVersion=4.5
...
...
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