Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
341ef37b
Commit
341ef37b
authored
Apr 28, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
authentication exception
parent
c53c45b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
olapy/core/services/models.py
olapy/core/services/models.py
+8
-2
olapy/core/services/xmla.py
olapy/core/services/xmla.py
+17
-14
No files found.
olapy/core/services/models.py
View file @
341ef37b
from
__future__
import
absolute_import
,
division
,
print_function
from
spyne
import
ComplexModel
,
Integer
,
String
,
Unicode
,
XmlAttribute
from
spyne
import
ComplexModel
,
Integer
,
Unicode
,
XmlAttribute
from
spyne.model.fault
import
Fault
class
Tuple
(
object
):
...
...
@@ -104,3 +104,9 @@ class DiscoverRequest(ComplexModel):
RequestType
=
Unicode
Restrictions
=
Restrictionlist
Properties
=
Propertielist
class
AuthenticationError
(
Fault
):
__namespace__
=
'spyne.examples.authentication'
faultcode
=
'Client.AuthenticationError'
,
faultstring
=
'Invalid authentication request'
olapy/core/services/xmla.py
View file @
341ef37b
...
...
@@ -8,11 +8,12 @@ from os.path import expanduser
from
lxml
import
etree
from
spyne
import
AnyXml
,
Application
,
ServiceBase
,
rpc
from
spyne.error
import
InvalidCredentialsError
from
spyne.protocol.soap
import
Soap11
from
spyne.server.wsgi
import
WsgiApplication
from
..mdx.tools.config_file_parser
import
ConfigParser
from
..services.models
import
DiscoverRequest
,
ExecuteRequest
,
Session
from
..services.models
import
DiscoverRequest
,
ExecuteRequest
,
Session
,
AuthenticationError
from
.xmla_discover_tools
import
XmlaDiscoverTools
from
.xmla_execute_tools
import
XmlaExecuteTools
from
.xmla_execute_xsds
import
execute_xsd
...
...
@@ -36,10 +37,15 @@ class XmlaProviderService(ServiceBase):
discover_tools
=
XmlaDiscoverTools
()
SessionId
=
discover_tools
.
SessionId
@
rpc
(
DiscoverRequest
,
_returns
=
AnyXml
,
_body_style
=
"bare"
,
_out_header
=
Session
)
_out_header
=
Session
,
_throws
=
InvalidCredentialsError
# _throws=AuthenticationError
)
def
Discover
(
ctx
,
request
):
"""
the first principle function of xmla protocol
...
...
@@ -60,15 +66,12 @@ class XmlaProviderService(ServiceBase):
if
config_parser
.
xmla_authentication
():
# TODO call labster login or create login with token (according to labster db)
if
ctx
.
transport
.
req_env
[
'QUERY_STRING'
]
!=
'admin'
:
# TODO try to 'monkey-patch' spyne and change response function name so we can authentication error to user
return
etree
.
fromstring
(
"""
<soap11env:Fault>
<faultcode>soap11env:Server</faultcode>
<faultstring>Authentication failed</faultstring>
<faultactor></faultactor>
</soap11env:Fault>
"""
)
if
ctx
.
transport
.
req_env
[
'QUERY_STRING'
]
!=
'mouadh'
:
raise
InvalidCredentialsError
(
fault_string
=
'You do not have permission to access this resource'
,
fault_object
=
None
)
# raise AuthenticationError()
if
request
.
RequestType
==
"DISCOVER_DATASOURCES"
:
return
discover_tools
.
discover_datasources_response
()
...
...
@@ -198,7 +201,7 @@ class XmlaProviderService(ServiceBase):
xmla_tools
.
generate_slicer_axis
(
df
),
xmla_tools
.
generate_cell_data
(
df
),
datetime
.
now
().
strftime
(
'%Y-%m-%dT%H:%M:%S'
)).
replace
(
'&'
,
'&'
))
'&'
,
'&'
))
# Problem:
# An XML parser returns the error “xmlParseEntityRef: noname”
...
...
@@ -250,8 +253,8 @@ def start_server(write_on_file=False):
logging
.
getLogger
(
'spyne.protocol.xml'
).
setLevel
(
logging
.
DEBUG
)
logging
.
info
(
"listening to http://127.0.0.1:8000/xmla"
)
logging
.
info
(
"wsdl is at: http://localhost:8000/xmla?wsdl"
)
#
server = make_server('127.0.0.1', 8000, wsgi_application)
server
=
make_server
(
'192.168.101.139'
,
8000
,
wsgi_application
)
server
=
make_server
(
'127.0.0.1'
,
8000
,
wsgi_application
)
#
server = make_server('192.168.101.139', 8000, wsgi_application)
server
.
serve_forever
()
...
...
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