set simpleSAMLphp SP to send POST request - simplesamlphp

I have an issue
I connected SP and IDP, and all is ok except one thing: SP send GET request to iDp. and iDp demand data sent using POST protocol.
this is SP
'spname' => array(
'saml:SP',
'ProtocolBinding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'idp' => 'https://someurl.com/SomeSSO.aspx',
'acs.Bindings' => array(
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
),
'discoURL' => NULL,
'privatekey' => 'some.pem',
'certificate' => 'some.crt'
),
and this is iDp remote:
$metadata['https://something.com/SomeSSO.aspx'] = array(
'name' => array(
'en' => 'Something',
'no' => 'Something',
),
'description' => 'Something',
'SingleSignOnService' => 'https://xxxxxx.com/SomeSSO.aspx?ou_id=-850',
'SingleLogoutService' => 'https://xxxxxx.com/SomeSSO.aspx?ou_id=-850',
'certFingerprint' => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);
can someone help me?

You've stated your issue, but no actual question.
If you're desire is for the IdP to use GET as well, I believe you need to the HTTP-POST to HTTP-GET in the protocol binding attribute.

To configure SimpleSAMLphp to use HTTP POST instead of GET you will need to modify your remote IdP configuration to explicitly specify a HTTP POST binding, something like this should work:
$metadata['https://something.com/SomeSSO.aspx'] = array(
'name' => array(
'en' => 'Something',
'no' => 'Something',
),
'description' => 'Something',
'SingleSignOnService' => array (
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://xxxxxx.com/SomeSSO.aspx?ou_id=-850',
),
),
'SingleLogoutService' => array (
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://xxxxxx.com/SomeSSO.aspx?ou_id=-850',
),
),
'certFingerprint' => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);
SimpleSAMLphp includes a metadata parser which does the work of converting the IdP configuration details to the required format for SimpleSAMLphp. This functionality is mentioned briefly in the SimpleSAMLphp documentation here: https://simplesamlphp.org/docs/1.8/simplesamlphp-sp#section_2.
If your remote IdP supplies their metadata in XML format, consider using the metadata parser to generate your remote IdP configuration as the metadata parser will automatically generate the correct bindings for your remote IdP endpoints.

Related

How do I add an Excerpt box to custom post types in functions?

I just want the standard Excerpt box - not a metabox of my own creation, added to a Custom Post. The box shows up in Posts but not in Custom Posts. I've tried both of these older solutions but neither of them worked (maybe it's a WP 3.9 problem):
The custom post type name is "Scoop"
I added this to the register_post_type_scoop() $labels = array
'supports' => array('title','thumbnail','excerpt')
but it didn't work - neither did this:
add_post_type_support('Scoop', 'title');
add_post_type_support('Scoop', array('title', 'thumbnail', 'excerpt') );
Add a index value excerpt to the supports object. Below the example is:
add_action( 'init', 'create_testimonial_posttype' );
function create_testimonial_posttype(){
register_post_type( 'testimonials',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'clients'),
'supports' => array('title','thumbnail','editor','page-attributes','excerpt'),
)
);
}

Omnipay Stripe Extra Parameters

Im trying to use the Omnipay API with Stripe, but I can't pass in extra parameters such as "Name", "Metadata", or "Zip".
// The token is grabbed from stripe JS
$this->stripe_gateway = Omnipay::create('Stripe');
$response = $this->stripe_gateway->purchase([
'amount' => $amount,
'currency' => 'usd',
'name' => $name,
'description' => $product->title,
'zip_address' => $zip,
'metadata' => [
'name' => $name,
'user_id' => $this->session->get('id')
],
'token' => $stripeToken,
])->send();
I cant get anything to work, is this not built into the API?
Omnipay uses it's own parameter names, not Stripe's. That's because Omnipay tries to abstract most of the differences between the various payment gateways.
Right now, the omnipay/stripe package doesn't support sending some of those parameters (only amount, currency, description, and now metadata). You can see the supported parameters here:
https://github.com/omnipay/stripe/blob/master/src/Message/AuthorizeRequest.php
That said, you can still easily access the underlying Stripe request to add your own custom parameters:
$request = $this->stripe_gateway->purchase([
'amount' => $amount,
'token' => $stripeToken,
'metadata' => ['foo' => 'bar'],
]);
$data = $request->getData();
$data['zip_address'] = '12345';
$data['another_custom_parameter'] = 'wow';
$response = $request->sendData($data);
Note that:
$data = $request->getData();
$response = $request->sendData($data);
is exactly the same as calling:
$response = $request->send();
Alternatively, you could create a pull request to add extra parameters to the Omnipay Stripe package. I just added the metadata parameter as an example of this:
https://github.com/omnipay/stripe/commit/99c82dc42c7c0b9ec58d8c4fb917f3dc5d1c23e2

Symfony security system, redirect loop (need to access the user in every page)?

I need to access the current user logged in (if any) in any part of the application. Special paths like /admin requires special permissions (roles).
This is the firewall configuration (just one firewall) protecting the entire application but not allowing anonymous users (because I need the current user even in homepage).
I got a redirect loop even requesting /. Any help?
'security.firewalls' => array(
'secured' => array(
'pattern' => '.*',
'anonymous' => false,
'form' => array(
'login_path' => '/login',
'check_path' => '/login_check',
'username_parameter' => 'login[username]',
'password_parameter' => 'login[password]',
),
'logout' => array('logout_path' => '/logout')
)
)
Access rules requires ROLE_ADMIN only for paths starting with /admin . The rest is anonymous:
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^.*', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
To allow acces via IS_AUTHENTICATED_ANONYMOUSLY have have to allow anonymous.
'security.firewalls' => array(
'secured' => array(
'pattern' => '/',
'anonymous' => true,
// other stuff
)
)
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^/', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
If the user is logged in you can access them in every page. IS_AUTHENTICATED_ANONYMOUSLY is only a role, which have unauthenticated users (anonymous).

How to query by custom post type values in WordPress?

I have a Custom Post Type using the Custom Post Type UI plugin called Case Studies. I'm also using the Custom Fields to add a capability field to the Case Studies.
How can I query Case Studies where the capability is equal to some ID?
$query = array('post_type' => 'case-studies','posts_per_page' => 3);
is my query so far
It could be
$query = array(
'post_type' => 'case-studies',
'meta_key' => 'capability',
'meta_value' => 10, // some ID
'posts_per_page' => 3
);
$the_query = new WP_Query( $query );
while ( $the_query->have_posts() ) : $the_query->the_post();
// echo here
endwhile;
wp_reset_postdata();
You need to set your key to capability, and then query value by your post ID.
'meta_query' => array(
array(
'key' => 'capability',
'value' => $post->ID,
'compare' => 'example'
)
)

Ajax request in magento module

I developing magneto module, In this module i want to make a ajax request in admin panel.I don't understand were to add script and controllers.please help me.
My requirement:
When change the select box(On change) i want add some field in the form.
Mycode:
/app/code/local/<Namespace>/<Module>/Block/Adminhtml/<Module>/Edit/Tab/Form.php
$fieldset->addField('type', 'select', array(
'label' => Mage::helper('<Module>')->__('Article Type'),
'name' => 'status',
'values' => array(
array(
'value' => '',
'label' => Mage::helper('<Module>')->__('Choose'),
),
array(
'value' => 1,
'label' => Mage::helper('<Module>')->__('Normal'),
),
array(
'value' => 2,
'label' => Mage::helper('<Module>')->__('video'),
),
),
'required' => true
));
I am creating fields using this.
How can i add another field on change.
Where should i add script
Where should i add controller
I created this module using this instructions
Let this field always be on the form. But make it invisible and show when you need it.
In the same template where the form is.
Place controller in your module. On stackoverflow you can find many questions about creating your own magento module and controller.

Resources