While currently cookie based authenticatation is the predominant method of implementation, it relies heavily on the domain based security rules implemented by modern browsers. This model would cause challenges when implementing apps in hybrid environments.
The full life cycle for signing up (create), authenticating (read), updating username/password (update) has been implemented in a self contained package. It is worth mentioning that token persistence has been intentionally decoupled from this package to allow for flexible use in a variety of scenarios (cross-domain, toolbar, embedded, etc.).
push(["overlay", {
"parts" : "ext","what" : "ui/w/shell/login/full",
"initval" : {"node" : modtask.node
},"success" : [
["query", false, "val", modtask, "user"],function(push) {
modtask.modsess.setUser(modtask.user,
function() {push([
["push", "onuserstate", modtask]]);
});
}]
}, modtask] ); modtask.modsess os the interface that should provide sessions persistence via setUser/getUser interface. Below are a few examples.['frame_getsessman', modtask],
function() {modtask.sessman.getUser(
function(user) {}
The frame does not really care how the session is managed. The advantage of this approach is that the UI can be reused in the following scenarios:
case 'frame_getsessman':
params['sessman'] = modtask.ldmod('ui/w/shell/sessman/ckbased').sp({node: modtask.getNode()
});callback(transition);
return true;break;
case 'frame_getsessman':
params['sessman'] = {getUser: function(okpush) {
modtask.getGlobal('user', function(val) {if (!val) val = false;
okpush(val);});
}}
callback(transition);return true;
break;The embedded login wall which is useful for scenarios where the application functionality needs to be made available only to authenticated users (i.e. most of the appid/register/embedded) use the cookie based sesssion manager.
modtask.sessionCheck = function(push) {
push({parts: 'ext',
what: 'ui/w/shell/auth/simple',onuserstate: [
function(push) {push(['replace', modtask.statusInstructions])
}]
})}
The problem with the current implementation for auth/simple is that it does not decouple the session from its implementation and uses ckbased hardwired. A better approach would be to decouple it. Also to make it work cross domain, a new session manage type would need to be created that would rely on iframes (the iframe would store the cookie and would be on the izyware.com or another trusted thirdparty site) and window messaging for communicating state.
ui/node/direct\
is the main component that is used to access cloud resources.
var node = modtask.ldmod('ui/node/direct').sp({
// Optional: What sort of access do I have? false means minimal
accesstoken: false, // Where is the service located at?dataservice: 'https://izyware.com/',
// Optional: If using tunnelling to access resources, pass the id
tunnelendpointid: 'endpointid', // What communication stack should I use?groupidobject: {
transportmodule: 'qry/transport/scrsrc'},
// log queries, etc.
verbose: true, // default is trueencryptqueries : false
});All the other servies, including the identity management system use:
node.runQuery2(
q,okpush,
failpush);
The following steps are used for generating an authentication token:
modtask.ldmod('ui/node/api/user').sp({
node: node}).authenticate({
user : 'username',password : 'password'
},function(user) {
// pass user.accesstoken to your node object},
function(outcome) {}
);If successful, this will return a user object which will have the information about the user (role, etc.) and also the authentication token.
The authentication token may be used to request privilaged services via the \accesstoken\
property of the node object.
node.sp('accesstoken', user.accesstoken).runQuery2(
...);
Unless running in an extension or a mobile app, the session token needs to be persisted in order to avoid login attempts from happening everytime the the page is refresh.
Case in point is the Shell. After the user is logged in successfully, it uses he \rel:session\
to cookie the current web domain container:
"success" :
[["query", false, "val", modtask, "user"],
function(push){
modtask.ldmod("rel:session").setUser(modtask.user,
function(){
push(["push", "onuserstate"]);}
);}
]modtask.ldmod("ui/node/auth").set(user.accesstoken) action.
When the Shell is loaded due to entering the page or refresh, it will call:
modtask.ldmod("rel:session").getUser(function(user) { })
This will perform the following checks:
cached\
user is defined, just return it, otherwisesetUser\
cookie is not defined return no user, otherwisemodtask.ldmod("ui/node/api/user").sp({ node : modtask.node }).loadsession(
{ "accesstoken" : accesstoken },function(user) {},
...The sharer sends a user agnostic* link to sharee.
- when landing on the link, if the session is logged in access will be granted to that session- if not logged in you can either
- force login/account create- use temporary accounts to allow temporary access
the sharer sends a sharee specific* link to sharee
- because this assumes the sharee is already in the system, if logged in as the sharee it will just work, otherwise if logged in as somebody else or not as sharee it will force them to relogin as the new user.bootstrap/5/sessman
* replaces sendmail,user,' + commaEncode(params.user) + ',' + commaEncode(params.password) + ',5';
for runQuery2
* lower cases and white space cleanses the username before auth
api?whoamifull
* populate session user information from usermetadata
usermetadata
data schema