PushWoosh - Location based notifications via Remote API - php

I am looking to filter notifications based on users current location. I get that I can set geozones through the PushWoosh web-site, but I can't seem to find any way to do this through the remote API.
I want to do something like this:
$this->pwCall('createMessage',
array
(
'application' => 'XXXXX-XXXXX',
'auth' => 'XXXXXX[...]',
'lng' => 42,
'lat' => 42,
'range' => 1000,
'notifications' => array
(
array
(
"platforms" => array(3),
'send_date' => 'now',
"ignore_user_timezone" => true,
'content' => "$message",
'data' => array("type" => $type),
"android_header" => "$header",
)
)
)
);
In other words: Send the notification to any device within a certain range from a specific location, but I can't get it to work. Is it even possible to do something like this?
Thank you in advance!

Related

SimpleSAMLphp shows saml2-acs.php not found (error 404) when integrating with Microsoft Azure Directory SSO using SAML2

I have created a link from my web directory such that https://resolute.organization.in/sso points to the simplesaml directory /var/www/simplesamlphp/www
My simpleSAML configuration page:
The complete link https://resolute.organization.in/sso/module.php/saml/sp/saml2-acs.php/default-sp shows 404 Not Found while testing Authentication Sources --> default-sp.
My config.php:
$config = ['baseurlpath' => 'https://resolute.organization.in/sso/',
'secretsalt' => 'my_secret_salt',
'auth.adminpassword' => 'my_admin_pass',
];
Rest all are default values in config.php
My authsources.php:
$config = [
'admin' => [
'core:AdminPassword',
],
'default-sp' => [
'saml:SP',
'entityID' => 'https://resolute.organization.in/',
'idp' => 'https://sts.windows.net/{some-unique-key}/', //From metadata.xml for the app with entity ID in AD as *https://resolute.organization.in/*
'discoURL' => null,
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
'simplesaml.nameidattribute' => 'eduPersonTargetedID',
],
]
My metadata array in saml20-idp-remote.php:
$metadata['https://sts.windows.net/{some-unique-key}/'] = array (
'entityid' => 'https://sts.windows.net/{some-unique-key}/',
'contacts' =>
array (
),
'metadata-set' => 'saml20-idp-remote',
'SingleSignOnService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://login.microsoftonline.com/{some-unique-key}/saml2',
),
1 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://login.microsoftonline.com/{some-unique-key}/saml2',
),
),
'SingleLogoutService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://login.microsoftonline.com/{some-unique-key}/saml2',
),
),
'ArtifactResolutionService' =>
array (
),
'NameIDFormats' =>
array (
),
'keys' =>
array (
0 =>
array (
'encryption' => false,
'signing' => true,
'type' => 'X509Certificate',
'X509Certificate' => '{really_long_key}',
),
),
);
My Federation page:
The [show metadata] link shows 404 as well, the link in the URL bar in this case is:
https://resolute.organization.in/sso/module.php/saml/sp/metadata.php/default-sp?output=xhtml
IdP metadata link shows the metadata array properly.
Please help me out with what am I missing here as I have been breaking my head over this for a few days now.
Figured out the issue, it had something to do with Nginx server configuration that could not handle multiple php pages in one link. Switched to Apache and everything works fine.
It depends on how php handles the url parameters and occurs when using php-fpm either with NGINX or Apache mpm_worker/event.
In order to fix this, set
cgi.fix_pathinfo=1 in php.ini

SimpleSAMLphp generate assertion

I'm using SimpleSAMLphp as an IdP for a bunch of applications we have, chiefly a Drupal site. I've used SQL as an authsource on the IdP and that works to authenticate users, the response returns to Drupal and the users are authenticated. All good !
However we also need to use social login (login with Twitter, Facebook etc). SimpleSAMLphp supports OAuth, I've set it up and the login works on the IdP with the social accounts, SimpleSAML creates the session and cookies but I'm not authenticated on the Drupal site.
What I need to do is complete the request by returning to Drupal and authenticating the user there, that is, to issue an assertion back to Drupal on success.
Just like in the SQL source, I've mapped the attributes in each of the source files (Twitter.php, Facebook.php etc) however where SQL auth returns to Drupal and creates a session, the others just display their attributes in a template.
How do I generate and send back an assertion for Drupal from these social logins so as to authenticate my users there ?
saml10-sp-remote.php (IdP)
$metadata['https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/metadata.php/sp'] = array (
'SingleLogoutService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-logout.php/sp',
),
1 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-logout.php/sp',
),
),
'AssertionConsumerService' =>
array (
0 =>
array (
'index' => 0,
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-acs.php/sp',
),
1 =>
array (
'index' => 1,
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml1-acs.php/sp',
),
2 =>
array (
'index' => 2,
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-acs.php/sp',
),
3 =>
array (
'index' => 3,
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml1-acs.php/sp/artifact',
),
),
'certData' => 'xxxx',
);
authsources.php (IdP)
'sql' => array(
'sqlauth:SQL',
'dsn' => 'mysql:host=localhost;dbname=db',
'username' => 'user',
'password' => 'pass',
'query' => 'SELECT u.uid, u.name, u.mail, r.name AS role FROM users u JOIN users_roles ur on ur.uid = u.uid JOIN role r on r.rid = ur.rid where u.mail = :username AND pass = MD5(:password);',
),
'facebook' => array(
'authfacebook:Facebook',
'api_key' => 'xxxx',
'secret' => 'xxxx',
'req_perms' => 'email',
),
'linkedin' => array(
'authlinkedin:LinkedIn',
'key' => 'xxxx',
'secret' => 'xxxx',
),
'twitter' => array(
'authtwitter:Twitter',
'key' => 'xxxx',
'secret' => 'xxxx',
'force_login' => true,
),
saml20-idp-remote.php (SP, Drupal)
$metadata['http://idp_url/simplesaml/saml2/idp/metadata.php'] = array (
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'http://idp_url/simplesaml/saml2/idp/metadata.php',
'SingleSignOnService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://idp_url/simplesaml/saml2/idp/SSOService.php',
),
),
'SingleLogoutService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://idp_url/simplesaml/saml2/idp/SingleLogoutService.php',
),
),
'certData' => 'xxx',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
);
saml20-idp-hosted.php (IdP)
$metadata['__DYNAMIC:1__'] = array(
'host' => '__DEFAULT__',
'privatekey' => 'mysite.com.key',
'certificate' => 'mysite.com.crt',
'auth' => 'sql',
);
Background
Your issue is that your Identity Provider is configured to use sql auth and not twitter, linkedin, etc. The drupal site will send you to the IDP and the IDP is only knowledgable about sql. While you do have authsources configured for social, SSP lets you test and verify those independently of your IDP configuration. This is why SSP is just display the social attributes in a template, and not letting you log into drupal with them.
Option A
multiauth will let you define an authsource that includes your social and sql. You then configure your idp to use the new multiauth authsource
Option B
An IDP per social provider. We run an IDP per social provider. We have multiple IDPs (with unique entityIDs) define in saml20-idp-hosted.php - one for each social account. We do it this way because each of our SPs only wants to trust a subset of all configured social IDPs.
Each SP in this option would include the additional IDP data in saml20-idp-remote.php
Option C
Outsource. We run this sort of social to saml gateway as a SaaS product. This makes sense if you don't like running things yourself, or if you have a several SPs that all want different social providers, or to use different social api keys/secrets per SP.

Refactor AWS query to minimize write requests

I need to be able to write information to an AWS dynamoDB. However not every write includes the same information, but I would like to use the same code. I can make it work by making multiple requests, but I was wondering if there a way I can refactor this so it can be done with one request?
// This code makes the initial write using what is always posted.
$newRecord = $client->putItem(array(
'TableName' => 'ximoRepV3',
'Item' => array(
'rep_num' => array('S' => $rep_num),
'fc_key' => array('BOOL' => false),
...
)
));
// Then I have a series of if's for writes that are not always present.
if (!empty($salt)){
$saltUpdate = $client->updateItem ( array (
'TableName' => 'ximoRepV3',
'Key' => array (
'rep_num' => array (
'S' => $rep_num
)
),
'ExpressionAttributeValues' => array (
':salt' => array('S' => $salt)
),
'UpdateExpression' => 'SET salt = :salt'
));
}

How to configure multiple SP for a single IdP

I've been following along this tutorial:
http://www.worldgoneweb.com/2013/installing-simplesamlphp-and-use-it-as-sp-and-idp-for-development-env-only/
.... it has really helped to setup authentication between SP and IdP. However, when configuring the metadata/saml20-remote-sp.php file it tells me to copy and paste the contents of a box (SP: Federation > Show metadata > simpleSAMLphp flat file format box) to that file. I've done this, and it works great for a single SP - I just don't really know how to add another SP. I checked the documentation but it only shows minimum set required, and no mention/example of multiple SPs.
Below is my IdP's metadata/saml20-remote-sp.php with a single SP:
$metadata['http://local-ssoidp'] = array (
'SingleLogoutService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://local-mwqasys/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
),
),
'AssertionConsumerService' =>
array (
0 =>
array (
'index' => 0,
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'http://local-mwqasys/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
),
1 =>
array (
'index' => 1,
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
'Location' => 'http://local-mwqasys/simplesaml/module.php/saml/sp/saml1-acs.php/default-sp',
),
2 =>
array (
'index' => 2,
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
'Location' => 'http://local-mwqasys/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
),
3 =>
array (
'index' => 3,
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
'Location' => 'http://local-mwqasys/simplesaml/module.php/saml/sp/saml1-acs.php/default-sp/artifact',
),
),
);
How can I add additional SPs to this? I considered merging the arrays together (arrays given from each SP's show metadata page) but want to gain a little better understanding other than guesswork. Can anyone please advise on how this is done. Thanks.
You can just add a second SP under your first one.
So copy what you currently have and paste it at the bottom of the file. Then edit the second copy with the details of your second SP.
Cheers

Taking a sub panel in sugarcrm and making it into two, one that displays entries depending if a checkbox is checked, the other non checked entries

Taking a sub panel in sugarcrm and making it into two, one that displays entries depending if a checkbox is checked, the other non checked entries.
I have a module called mod_loaninvestor, and its sub panel is whole_subpanel_mod_loaninvestor_contacts
Now I know vardefs is where you create the duplicate and rename it like this
<?php
//WARNING: The contents of this file are auto-generated
// created: 2014-01-24 13:12:28
$layout_defs["Contacts"]["subpanel_setup"]['mod_loaninvestor_contacts'] = array (
'order' => 100,
'module' => 'mod_LoanInvestor',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
// 'where' => "(mod_LoanInvestor.active_investment == "1")",
'title_key' => 'LBL_MOD_LOANINVESTOR_CONTACTS_FROM_MOD_LOANINVESTOR_TITLE',
'get_subpanel_data' => 'mod_loaninvestor_contacts',
'top_buttons' =>
array (
/*
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
*/
),
);
// created: 2014-01-24 13:12:28
$layout_defs["Contacts"]["subpanel_setup"]['mod_loaninvestor_contacts1'] = array (
'order' => 100,
'module' => 'mod_LoanInvestor',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'title_key' => 'LBL_MOD_LOANINVESTOR_CONTACTS_FROM_MOD_LOANINVESTOR_TITLE',
'get_subpanel_data' => 'mod_loaninvestor_contacts',
'top_buttons' =>
array (
/*
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
*/
),
);
?>
How would I make it so the first one would only show entries with the following checked
and the other display only entries with that field unchecked?
Thanks for your help!
You're halfway there. On top of defining new layoutdefs, you need to create a new subpanel definition.
Dig into mod_LoanInvestor and the metadata/subpanels/default.php and copy it to default2.php or whatever you'd like to call it. You'll want to use a WHERE clause to separate the two.
https://gist.github.com/matthewpoer/8871568
Here's a gist where I'm doing this with transactions records to seperate scheduled (future) transactions from past (posted payments).

Categories