summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-07-10 23:01:05 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-07-10 23:01:05 +0000
commit3677573bee663ff680489855724dcdc8360e6860 (patch)
tree875e729f0259937ce87dfe930b4fdd02b379887b /python
parent1ed5aafdc04e029d9a902fd8b6df2220820c519f (diff)
downloadlasso-3677573bee663ff680489855724dcdc8360e6860.tar.gz
lasso-3677573bee663ff680489855724dcdc8360e6860.tar.xz
lasso-3677573bee663ff680489855724dcdc8360e6860.zip
*** empty log message ***
Diffstat (limited to 'python')
-rw-r--r--python/environs/py_login.c44
-rw-r--r--python/environs/py_login.h2
-rw-r--r--python/examples/login.py36
-rw-r--r--python/lasso.py12
-rw-r--r--python/lassomod.c14
5 files changed, 97 insertions, 11 deletions
diff --git a/python/environs/py_login.c b/python/environs/py_login.c
index 5dcf08a5..d7734a2f 100644
--- a/python/environs/py_login.c
+++ b/python/environs/py_login.c
@@ -56,8 +56,8 @@ PyObject *login_getattr(PyObject *self, PyObject *args) {
login = LassoLogin_get(login_obj);
if (!strcmp(attr, "__members__"))
- return Py_BuildValue("[ssss]", "request", "response", "request_type",
- "msg_url");
+ return Py_BuildValue("[sssss]", "request", "response", "request_type",
+ "msg_url", "protocolProfile");
if (!strcmp(attr, "request"))
return (LassoNode_wrap(LASSO_PROFILE_CONTEXT(login)->request));
if (!strcmp(attr, "response"))
@@ -65,7 +65,9 @@ PyObject *login_getattr(PyObject *self, PyObject *args) {
if (!strcmp(attr, "request_type"))
return (int_wrap(LASSO_PROFILE_CONTEXT(login)->request_type));
if (!strcmp(attr, "msg_url"))
- return (charPtr_wrap(LASSO_PROFILE_CONTEXT(login)->msg_url));
+ return (charPtrConst_wrap(LASSO_PROFILE_CONTEXT(login)->msg_url));
+ if (!strcmp(attr, "protocolProfile"))
+ return (int_wrap(login->protocolProfile));
Py_INCREF(Py_None);
return (Py_None);
@@ -176,3 +178,39 @@ PyObject *login_init_authn_request(PyObject *self, PyObject *args) {
return (int_wrap(ret));
}
+
+PyObject *login_init_from_authn_request_msg(PyObject *self, PyObject *args) {
+ PyObject *login_obj;
+ gchar *authn_request_msg;
+ lassoHttpMethods authn_request_method;
+ gint ret;
+
+ if (CheckArgs(args, "OSI:login_init_from_authn_request_msg")) {
+ if(!PyArg_ParseTuple(args, (char *) "Osi:login_init_from_authn_request_msg",
+ &login_obj, &authn_request_msg, &authn_request_method))
+ return NULL;
+ }
+ else return NULL;
+
+ ret = lasso_login_init_from_authn_request_msg(LassoLogin_get(login_obj),
+ authn_request_msg,
+ authn_request_method);
+
+ return (int_wrap(ret));
+}
+
+PyObject *login_must_authenticate(PyObject *self, PyObject *args) {
+ PyObject *login_obj;
+ gboolean ret;
+
+ if (CheckArgs(args, "O:login_must_authenticate")) {
+ if(!PyArg_ParseTuple(args, (char *) "O:login_must_authenticate",
+ &login_obj))
+ return NULL;
+ }
+ else return NULL;
+
+ ret = lasso_login_must_authenticate(LassoLogin_get(login_obj));
+
+ return (int_wrap(ret));
+}
diff --git a/python/environs/py_login.h b/python/environs/py_login.h
index 4956aff7..cb48de1c 100644
--- a/python/environs/py_login.h
+++ b/python/environs/py_login.h
@@ -45,5 +45,7 @@ PyObject *login_new_from_dump(PyObject *self, PyObject *args);
PyObject *login_build_artifact_msg(PyObject *self, PyObject *args);
PyObject *login_build_authn_request_msg(PyObject *self, PyObject *args);
PyObject *login_init_authn_request(PyObject *self, PyObject *args);
+PyObject *login_init_from_authn_request_msg(PyObject *self, PyObject *args);
+PyObject *login_must_authenticate(PyObject *self, PyObject *args);
#endif /* __PYLASSO_PY_LOGIN_H__ */
diff --git a/python/examples/login.py b/python/examples/login.py
index d9e11230..04d21b57 100644
--- a/python/examples/login.py
+++ b/python/examples/login.py
@@ -3,6 +3,8 @@
import sys
sys.path.insert(0, '../')
+import string
+
import lasso
lasso.init()
@@ -16,7 +18,7 @@ server = lasso.Server.new("../../examples/sp.xml",
server.add_provider("../../examples/idp.xml", None, None)
-# creation d'une AuthnRequest
+# create AuthnRequest
splogin = lasso.Login.new(server, None)
ret = splogin.init_authn_request("https://identity-provider:2003/liberty-alliance/metadata")
splogin.request.set_isPassive(0)
@@ -28,5 +30,35 @@ splogin.request.set_protocolProfile(lasso.libProtocolProfileBrwsArt)
print "Request type =", splogin.request_type
print splogin.request.dump()
-print splogin.build_authn_request_msg()
+splogin.build_authn_request_msg()
print "message url =", splogin.msg_url
+
+#####################
+# Identity provider #
+#####################
+server = lasso.Server.new("../../examples/idp.xml",
+ None, "../../examples/rsakey.pem", "../../examples/rootcert.pem",
+ lasso.SignatureMethodRsaSha1)
+
+server.add_provider("../../examples/sp.xml",
+ "../../examples/rsapub.pem", "../../examples/rsacert.pem")
+
+# create AuthnResponse OR artifact (depending ProtocolProfile)
+idplogin = lasso.Login.new(server, None)
+
+# get query part in msg_url
+authn_request_msg = string.split(splogin.msg_url, '?')[1]
+ret = idplogin.init_from_authn_request_msg(authn_request_msg,
+ lasso.HttpMethodRedirect);
+
+print "ProtocolProfile =", idplogin.protocolProfile
+
+must_authenticate = idplogin.must_authenticate()
+print "User must be authenticated =", idplogin.protocolProfile
+
+if idplogin.protocolProfile == 1:
+ ret = idplogin.build_artifact_msg(1,
+ lasso.samlAuthenticationMethodPassword,
+ "",
+ lasso.HttpMethodRedirect)
+ print "ret = %d, msg_url = %s" % (ret, idplogin.msg_url)
diff --git a/python/lasso.py b/python/lasso.py
index 0f825ec1..33f82c6f 100644
--- a/python/lasso.py
+++ b/python/lasso.py
@@ -791,6 +791,11 @@ class AuthenticationStatement(Node):
SignatureMethodRsaSha1 = 1
SignatureMethodDsaSha1 = 2
+HttpMethodGet = 1
+HttpMethodPost = 2
+HttpMethodRedirect = 3
+HttpMethodSoap = 4
+
MessageTypeNone = 0
MessageTypeAuthnRequest = 1
MessageTypeAuthnResponse = 2
@@ -869,6 +874,13 @@ class Login:
def init_authn_request(self, remote_providerID):
return lassomod.login_init_authn_request(self, remote_providerID)
+ def init_from_authn_request_msg(self, authn_request_msg, authn_request_method):
+ return lassomod.login_init_from_authn_request_msg(self, authn_request_msg,
+ authn_request_method)
+
+ def must_authenticate(self):
+ return lassomod.login_must_authenticate(self)
+
class Logout:
"""\brief Short desc
diff --git a/python/lassomod.c b/python/lassomod.c
index 74aefaae..4ebbc412 100644
--- a/python/lassomod.c
+++ b/python/lassomod.c
@@ -202,12 +202,14 @@ static PyMethodDef lasso_methods[] = {
/* environs */
/* py_login.h */
- {"login_getattr", login_getattr, METH_VARARGS},
- {"login_new", login_new, METH_VARARGS},
- {"login_new_from_dump", login_new_from_dump, METH_VARARGS},
- {"login_build_artifact_msg", login_build_artifact_msg, METH_VARARGS},
- {"login_build_authn_request_msg", login_build_authn_request_msg, METH_VARARGS},
- {"login_init_authn_request", login_init_authn_request, METH_VARARGS},
+ {"login_getattr", login_getattr, METH_VARARGS},
+ {"login_new", login_new, METH_VARARGS},
+ {"login_new_from_dump", login_new_from_dump, METH_VARARGS},
+ {"login_build_artifact_msg", login_build_artifact_msg, METH_VARARGS},
+ {"login_build_authn_request_msg", login_build_authn_request_msg, METH_VARARGS},
+ {"login_init_authn_request", login_init_authn_request, METH_VARARGS},
+ {"login_init_from_authn_request_msg", login_init_from_authn_request_msg, METH_VARARGS},
+ {"login_must_authenticate", login_must_authenticate, METH_VARARGS},
/* py_logout.h */
{"logout_new", logout_new, METH_VARARGS},