Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Penguidom
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
Penguidom
Commits
da92a8ad
Commit
da92a8ad
authored
7 years ago
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login now working
parent
1190f6d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
42 deletions
+27
-42
users.conf
conf/defaults/users.conf
+2
-0
penguidom.py
penguidom/penguidom.py
+0
-2
auth.py
penguidom/web/auth.py
+20
-32
web.py
penguidom/web/web.py
+5
-8
No files found.
conf/defaults/users.conf
0 → 100644
View file @
da92a8ad
#username:salt:sha256 salted password
admin
:
admin
:
d82494f05d6917ba02f7aaa29689ccb444bb73f20380876cb05d1f37537b7892
This diff is collapsed.
Click to expand it.
penguidom/penguidom.py
View file @
da92a8ad
...
...
@@ -135,5 +135,3 @@ class penguidomService(service.Service):
cfg
.
readConfig
()
return
cfg
This diff is collapsed.
Click to expand it.
penguidom/web/auth.py
View file @
da92a8ad
...
...
@@ -29,20 +29,13 @@ import twisted.cred.checkers
import
twisted.cred.error
import
logging
from
twisted.internet
import
defer
try
:
import
hashlib
md5
=
hashlib
md5
.
new
=
hashlib
.
md5
sha1
=
hashlib
.
sha1
except
:
import
md5
import
sha1
from
nexlibs.utils
import
genutils
import
os
,
sys
log
=
logging
.
getLogger
(
"Webgui"
)
USERFILE
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
sys
.
argv
[
0
])),
'conf'
,
'users.conf'
)
class
mindFactory
(
object
):
loginsaved
=
False
...
...
@@ -62,39 +55,34 @@ class clientAuth(object):
cred
.
credentials
.
IUsernamePassword
,
)
users
=
{}
def
__init__
(
self
):
pass
with
open
(
USERFILE
)
as
fp
:
for
cnt
,
line
in
enumerate
(
fp
):
if
not
line
.
startswith
(
'#'
)
and
len
(
line
)
>
0
:
try
:
l
=
line
.
split
(
':'
)
self
.
users
[
l
[
0
]]
=
{
'salt'
:
l
[
1
],
'hash'
:
l
[
2
]
.
rstrip
(
"
\r\n
"
)}
except
:
pass
def
checkAuth
(
self
,
usr
,
pwd
):
log
.
debug
(
"CheckAuth for "
+
str
(
usr
)
+
" "
+
str
(
pwd
))
return
self
.
core
.
getAuth
(
usr
,
genutils
.
hashPwd
(
pwd
))
log
.
debug
(
"CheckAuth for "
+
str
(
usr
))
if
usr
in
self
.
users
.
keys
():
return
defer
.
succeed
((
genutils
.
hashPwd256
(
""
.
join
([
self
.
users
[
usr
][
'salt'
],
pwd
]))
==
self
.
users
[
usr
][
'hash'
]))
return
defer
.
succeed
(
False
)
def
getAuth
(
self
,
usr
,
pwd
):
log
.
debug
(
"getAuth for "
+
str
(
usr
)
+
" "
+
str
(
pwd
))
return
self
.
checkAuth
(
usr
,
pwd
)
.
addCallback
(
self
.
getPerms
,
pwd
)
def
getPerms
(
self
,
res
,
pwd
):
log
.
info
(
"getPerms "
+
str
(
res
))
"""
if len(res) > 0:
if res[0].admin == True:
perms['admin'] = True
return perms
"""
if
len
(
res
)
>
0
:
perms
=
res
[
0
]
perms
.
loginpwd
=
pwd
return
perms
return
False
log
.
debug
(
"getAuth for "
+
str
(
usr
))
return
self
.
checkAuth
(
usr
,
pwd
)
def
requestAvatarId
(
self
,
c
):
log
.
debug
(
'
AUTH: '
+
str
(
c
)
+
" "
+
str
(
c
.
username
))
log
.
debug
(
'
requestAvatarId: '
+
str
(
c
.
username
))
return
self
.
checkAuth
(
c
.
username
,
c
.
password
)
.
addCallback
(
self
.
getPerms
,
c
.
password
)
.
addCallback
(
self
.
AvatarResults
,
c
)
def
AvatarResults
(
self
,
res
,
c
):
log
.
debug
(
"AvatarResults "
+
str
(
res
)
+
" "
+
str
(
c
))
log
.
debug
(
"AvatarResults "
+
str
(
res
)
+
" "
+
str
(
c
.
username
))
if
res
:
return
defer
.
succeed
([
c
,
res
])
raise
cred
.
error
.
UnauthorizedLogin
()
This diff is collapsed.
Click to expand it.
penguidom/web/web.py
View file @
da92a8ad
...
...
@@ -202,8 +202,6 @@ class RootPage(rend.Page):
def
child_
(
self
,
ctx
):
if
str
(
self
.
core
.
configGet
(
'web'
,
'enableusergui'
))
.
lower
()
not
in
[
'yes'
,
'1'
,
'y'
,
'true'
]:
return
"Permission Denied"
html
=
"""
Redirecting...
"""
...
...
@@ -278,7 +276,7 @@ class SessionWrapper(guard.SessionWrapper):
def
renderHTTP
(
self
,
ctx
):
request
=
inevow
.
IRequest
(
ctx
)
host
=
request
.
getHeader
(
'host'
)
log
.
info
(
"USERNAME: "
+
str
(
request
.
getUser
())
+
" "
+
str
(
request
.
getPassword
())
)
log
.
info
(
"USERNAME: "
+
str
(
request
.
getUser
()))
log
.
debug
(
"SessionWrapper HOST CALLED: "
+
str
(
host
))
return
guard
.
SessionWrapper
.
renderHTTP
(
self
,
ctx
)
...
...
@@ -302,7 +300,6 @@ class SessionWrapper(guard.SessionWrapper):
request
.
args
[
"username"
]
=
[
request
.
getUser
()]
request
.
args
[
"password"
]
=
[
request
.
getPassword
()]
log
.
info
(
"Calling Guard..."
+
str
(
request
.
args
))
return
guard
.
SessionWrapper
.
locateChild
(
self
,
ctx
,
segments
)
...
...
@@ -529,13 +526,13 @@ class PenguidomAuthRealm(object):
resc
.
core
=
self
.
core
return
(
inevow
.
IResource
,
resc
,
noLogout
)
else
:
# Qui dovrebbe arrivare in caso di autenticazione
# avatarId dovrebbe contenere il ritorno al checkauth
# Here it is, we are authenticated.
# avatarId should contain the results of the authentication
# process
resc
=
RootAuthPage
(
avatarId
,
self
.
port
,
mind
)
resc
.
realm
=
self
resc
.
core
=
self
.
core
if
str
(
self
.
core
.
configGet
(
'web'
,
'enableajaxgui'
))
.
lower
()
in
[
'yes'
,
'1'
,
'y'
,
'true'
]:
resc
.
putChild
(
'sockjs'
,
ajax
.
getSocketJSResource
(
self
.
core
))
resc
.
putChild
(
'sockjs'
,
ajax
.
getSocketJSResource
(
self
.
core
))
return
(
inevow
.
IResource
,
resc
,
resc
.
logout
)
raise
NotImplementedError
(
"Can't support that interface."
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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