Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fachrat Informatik
user_wcf
Commits
b5d4c0f5
Commit
b5d4c0f5
authored
Nov 12, 2013
by
Fritz Webering
Browse files
Fixed copyright and license information
parent
ef79011a
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/stringutil.php
View file @
b5d4c0f5
<?php
/**
* Copyright (c) 2013 Fritz Webering <fritz@webering.eu>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the LICENSE file.
*/
namespace
OCA\User_WCF\lib
;
...
...
user_wcf.php
View file @
b5d4c0f5
<?php
/**
* Copyright (c) 201
2 Robin Appelman <icewind@owncloud.com
>
* Copyright (c) 201
3 Fritz Webering <fritz@webering.eu
>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the
COPYING-READM
E file.
* See the
LICENS
E file.
*/
namespace
OCA\user_wcf
;
/**
* This class authenticates users against a WCF database if they belong to
* one or more of the groups listed in the $authorizedGroups paramter. The
* database configuration is imported from the WCF configuration file of
* the WCF installation given in the $wcfPath paramter.
*/
class
User_WCF
extends
\
OC_User_Backend
implements
\
OC_User_Interface
{
protected
$authorizedGroups
;
protected
$groupsCondition
;
protected
$db
=
NULL
;
protected
$dbUser
,
$dbHost
,
$dbPassword
,
$dbName
;
public
function
__construct
(
$wcf
_p
ath
,
$authorized
_g
roups
)
{
require
$wcf
_p
ath
.
'/config.inc.php'
;
public
function
__construct
(
$wcf
P
ath
,
$authorized
G
roups
)
{
require
$wcf
P
ath
.
'/config.inc.php'
;
$this
->
dbHost
=
$dbHost
;
$this
->
dbUser
=
$dbUser
;
$this
->
dbPassword
=
$dbPassword
;
$this
->
dbName
=
$dbName
;
$this
->
wcfN
=
'wcf'
.
WCF_N
;
$this
->
authorizedGroups
=
$authorized
_g
roups
;
$this
->
authorizedGroups
=
$authorized
G
roups
;
$groups
=
array
();
foreach
(
$this
->
authorizedGroups
as
$group
)
{
$groups
[]
=
"
{
$this
->
wcfN
}
_group.groupName='
$group
'"
;
...
...
@@ -41,7 +48,7 @@ class User_WCF extends \OC_User_Backend implements \OC_User_Interface {
*/
public
function
checkPassword
(
$uid
,
$password
)
{
if
(
!
$this
->
connect
())
return
FALSE
;
$authenticated
_a
s
=
FALSE
;
$authenticated
A
s
=
FALSE
;
$username
=
$this
->
db
->
real_escape_string
(
$uid
);
$where
=
"LOWER(
{
$this
->
wcfN
}
_user.username)=LOWER('
$username
')"
;
...
...
@@ -50,19 +57,23 @@ class User_WCF extends \OC_User_Backend implements \OC_User_Interface {
if
(
$result
)
{
if
(
$result
->
num_rows
>
0
)
{
$row
=
$result
->
fetch_assoc
();
$doubleSalted
=
lib\StringUtil
::
getDoubleSaltedHash
(
$password
,
$row
[
'salt'
]);
$doubleSalted
=
lib\StringUtil
::
getDoubleSaltedHash
(
$password
,
$row
[
'salt'
]);
if
(
$doubleSalted
===
$row
[
'password'
])
{
$authenticated_as
=
$row
[
'username'
];
$authenticatedAs
=
$row
[
'username'
];
$this
->
warn
(
'User "'
.
$authenticatedAs
.
'" logged in successfully.'
);
}
}
else
{
$this
->
debug
(
"Username
$username
not found in WCF database in authorized groups."
);
$this
->
debug
(
"Username
$username
not found in WCF "
.
"database in authorized groups."
);
}
$result
->
close
();
}
return
$authenticated
_a
s
;
return
$authenticated
A
s
;
}
public
function
userExists
(
$uid
)
{
...
...
@@ -118,7 +129,8 @@ class User_WCF extends \OC_User_Backend implements \OC_User_Interface {
$result
=
$this
->
db
->
query
(
$query
);
if
(
$result
===
FALSE
)
{
$this
->
warn
(
"Error querying data from WCF database:
{
$this
->
db
->
error
}
(
{
$this
->
db
->
errno
}
). Query was:
$query
"
);
$this
->
warn
(
"Error querying data from WCF database: "
.
"
{
$this
->
db
->
error
}
(
{
$this
->
db
->
errno
}
). Query was:
$query
"
);
}
return
$result
;
}
...
...
@@ -128,7 +140,8 @@ class User_WCF extends \OC_User_Backend implements \OC_User_Interface {
$this
->
db
=
new
\
mysqli
(
$this
->
dbHost
,
$this
->
dbUser
,
$this
->
dbPassword
,
$this
->
dbName
);
if
(
$this
->
db
->
connect_error
)
{
$this
->
warn
(
'Unable to connect to database: '
.
$this
->
db
->
connect_error
);
$this
->
warn
(
'Unable to connect to database: '
.
$this
->
db
->
connect_error
);
$this
->
db
=
FALSE
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment