I am successfully connecting to a web service via SoapUI.
WSA Addressing must be true.
Add default wsa:To option should be checked.
When I apply these two items, I can get data successfully.
I need to connect and pull data with Laravel.
What can I do for it?
SOAPUI Image
$client = new \SoapClient($this->getServiceUrl(), [
'soap_version' => SOAP_1_2,
'wsdl_cache' => 0,
'trace' => 1
]);
Result of php : looks like we got no xml document or response
The requested URL was rejected. Please consult with your administrator."
Snippet required to integrate WSA Addressing true and Add default wsa:To options into Laravel.
Related
I am trying to set up SSO from my Laravel 8.13 site to my related Freshdesk support portal.
What I want is for a user, who is logged into my site, then to be able to click a button and get seamlessly signed into my Freshdesk support portal so they can view the non-public documentation there and raise tickets if required.
Using Laravel Passport 10.1 I can create a token (tested using Postman) but get an error from Freshdesk when trying to authenticate.
An error occurred while attempting to retrieve the userinfo resource: could not extract response: no
suitable httpmessageconverter found for response type [java.util.map<java.lang.string,
java.lang.object>] and content type [text/html;charset=utf-8]
I have not used OAuth before and am having issues. It may of course be that my understanding of OAuth is just completely wrong but I am finding available documentation on Laravel Passport / Freshdesk OAuth connectivity hard to come by.
I have been through as many related SO questions as I have found but nothing so far seems to exactly fit my issue.
I have also got open tickets with Freshdesk and have had an online support session with a Freshdesk support member but they told me the issue was on my side and they couldn't help further.
I would have thought the client type to use was a Personal Access Client but I have tried that as well as a Password Grant Client and get the same message (as above) for both client types.
As far as the "User info URL*" field on Freshdesk goes,
I have tried
http://testsite.ngrok.io/oauth/tokens
and
http://testsite.ngrok.io/oauth/personal-access-tokens
and
http://testsite.ngrok.io/api/user
But no luck - same message regarding not finding userinfo resource as above.
If I browse directly to
http://testsite.ngrok.io/oauth/personal-access-tokens
I get the following returned:
[{"id":"e595f342722c1045e061f2f026fa7f07181b3d5c69016e9999c5640f1e65928ff6fe2621565ff666c5",
"user_id":43128,"client_id":7,"name":null,"scopes":"openid","email","profile"],"revoked":false,
"created_at":"2021-01-26 10:16:12","updated_at":"2021-01-26 10:16:12",
"expires_at":"2022-01-26T10:16:12.000000Z","client":
{"id":7,"user_id":null,"name":"freshworksPersonalAccessClient",
"provider":null,
"redirect":"https:\/\/testsite.freshworks.com\/sp\/OAUTH\/27402945223480041\/callback",
"personal_access_client":true,"password_client":false,"revoked":false,
"created_at":"2021-01-19T23:19:39.000000Z","updated_at":"2021-01-19T23:19:39.000000Z"}}]
so something is returned but I am not sure if that is in any way near what Freshdesk is looking for. The support documentation for Freshdesk states :
But I do not know where to create that info or in what format it needs to be sent to Freshdesk.
I have looked at this question and believe that (even though it is for older versions) there might be something in the code for "getUserEntityByUserCredentials" in the UserRepository.php file but I have put logger calls in that function and it doesn't seem to be called.
Any assistance would be absolutely great. If any further information is required please let me know.
Although I would prefer to keep it within the Laravel ecosystem, I am also open to any other way to set up SSO to Freshdesk without using a third party Identity Provider like ADFS, OneLogin, Okta, Azure and suchlike. I just need to get this done.
Solved it. Basically my issue was the format and content returned by the User info URL.
I set up a route for
/userinfo
to a function in a TestController. In that function I decoded the Bearer token to get the user_id and then used that to retrieve the user details.
Then I created an array and response as below:
$thisDecodedUser = User::query()->findOrFail($thisDecodedUserId);
if ($thisDecodedUser) {
$thisDecodedUserFirstName = $thisDecodedUser->first_name;
$thisDecodedUserLastName = $thisDecodedUser->last_name;
$thisDecodedUserEmail = $thisDecodedUser->email;
}
$user_info = array();
$user_info['sub'] = "$thisDecodedUserId";
$user_info['id'] = "$thisDecodedUserId";
$user_info['email'] = "$thisDecodedUserEmail";
$user_info['.id'] = "$thisDecodedUserId";
$user_info['.email'] = "$thisDecodedUserEmail";
$user_info['email_verified'] = "true";
return response(json_encode($user_info))
->withHeaders([
'Content-Type' => 'application/json',
]);
The code needs refactoring but at least it works for now.
Thank you for pointing me in the right direction in this answer : https://stackoverflow.com/a/65929987/920598
Even if the array you use contains unused keys.
Actually, the available fields and their format are described here https://support.freshdesk.com/en/support/solutions/articles/50000002088-configuring-custom-sso-policies-under-org
For example, if you want to sync the firstname, the lastname and the language, here's the keys you need to set :
<?php
$user_info = [
'sub' => (string)$user->id,
'unique_id' => (string)$user->id,
'email' => $user->email,
'FirstName' => (string)$user->firstname,
'LastName' => (string)$user->lastname,
'language' => $user->default_ln === 1 ? 'fr' : 'en'
];
I use Guzzle in my Laravel 7 project and XAMPP 7.4.5, I'm trying to make a GET to my local API localhost/events_platforma/view/users It works fine but when I'm trying to make a POST request to https://localhost/events_platforma/register it fails and gives out that cURL error and My API Are on SLIM.
I have added this file
curl.cainfo = curl.cainfo="C:\xampp\php\extras\ssl\cacert.pem"
But still, give out an error
The quick solution for localhost is to turn off the certificate verification using options in guzzle of verify as false.
A quick small example below
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'http://exmaple.org'
]);
$client->request('GET', '/', ['verify' => false]);
If you are using Http-client provided by laravel you can add guzzle options like this,
$response = Http::withOptions([
'verify' => false,
])->get('http://example.org/');
NOTE:
Though even guzzle suggests to not using it, but if you are testing your own apis it can work.
Though you can simple add your certificates as per request just by providing path.
Mozilla provides a commonly used CA bundle which can be downloaded here (provided by the maintainer of cURL).
// Use a custom SSL certificate on disk.
$client->request('GET', '/', ['verify' => '/path/to/cacert.pem']);
Read more about certificates from https://curl.se/docs/sslcerts.html .
Read more about verify from guzzle docs verify
Works find locally. Using ASP.NET core 3.1
Publish to dev I notice the swagger only has HTTP option and when I try a GET on a service I get below?
Is there something on the dev server that is causing this that I need to change ?
SEC7111: [Mixed-Content] The origin 'https://corerd.rb.gov' was loaded in a secure context but tried to load an insecure resource at 'http://corerd.rb.gov/PWDRS/api/TestWebApi'.
No Results
Figured it out.. Though still don't know why it defaults to HTTP
app.UseOpenApi(configure => configure.PostProcess = (document, _) => document.Schemes = new[] { NSwag.OpenApiSchema.Https });
Alternatively, setting the Schemes to null disabled explicit schemes.
app.UseOpenApi(configure => configure.PostProcess = (document, _) => document.Schemes = null);
From the specification:
If schemes are not specified, the scheme used to serve the API specification will be used for API calls.
I am using subfission/cas for my application. I have followed all installation steps. I am using windows, if that matters. More precisely, I have configured the following:
I ran the following in my terminal
composer require "subfission/cas" "dev-master"
I configured my Kernel.php accordingly, adding the following:
'cas.auth' => 'Subfission\Cas\Middleware\CASAuth',
'cas.guest' => 'Subfission\Cas\Middleware\RedirectCASAuthenticated',
I ran the following command:
php artisan vendor:publish
I also set up my cas server in my cas.php config file:
'cas_hostname' => env('CAS_HOSTNAME', 'cas.myserver.me'),
'cas_real_hosts' => env('CAS_REAL_HOSTS', 'cas.myserver.me'),
What I want is a middleware for all my routes, so I added the following route rule in my routes:
Route::middleware(['cas.auth'])->group(function ()
{
Route::get('/', function ()
{
return view('welcome');
});
});
Basically, I want to redirect everyone who is not logged in to the login page whenever I access the main page (for now, I will add more routes in the future). What happens is that the users are redirected to the login page when they are not logged in, but after the login I receive the following error:
ErrorException (E_WARNING)
DOMDocument::loadXML(): Opening and ending tag mismatch: hr line 1 and body in Entity, line: 1
No matter what view I'm redirecting the user to. I tried the default welcome page as well as an empty view, but I still get the same error.
EDIT: I have used the dev-master branch from subfission/cas for the above error and after switching to 2.1.1, I get a different error:
session_name(): Cannot change session name when headers already sent
EDIT 2: I did some more digging and I enabled internal errors in my cas client class with:
libxml_use_internal_errors(true);
And now I get the following:
Authentication failure: SA not validated Reason: bad response from the CAS server
And the cas response is:
The thing is that I use the same cas server for another 2 projects and it works well for those (but those aren't laravel projects.
I know it's been a while, but for anyone else having issues like this, the issue is the protocol selected for which your web service communicates with your CAS(Central Authentication Service) provider. There are two main protocols used for SSO/CAS in this package:
SAML(Security Assertion Markup Language) version 1.1 & 2
CAS Protocol v3.0
[Confusingly enough, CAS protocol shares the same namespace as the service.]
The idea is to match the protocol and version with your identity provider. It sounds like your provider is using CASv3.0, which is why disabling SAML worked.
Also, if you enable debug mode, you will see further error details in your log file to help your troubleshoot.
Best of luck!
I managed to solve the issue by disabling the SAML in the cas configure file:
'cas_enable_saml' => env('CAS_ENABLE_SAML', true),
change to
'cas_enable_saml' => env('CAS_ENABLE_SAML', false),
I cant find how to send push notification by using Parse.com from my web server to android device using laravel. can anybody help me ?
Take a look at this documentation:
https://parse.com/docs/php/guide#push-notifications
and to this GitHub project:
https://github.com/ParsePlatform/parse-php-sdk
This PHP Lib can be included to your laravel project
Push:
ParseClient::initialize( $app_id, $rest_key, $master_key );
$data = array("alert" => "Hi!");
// Push to Channels
ParsePush::send(array(
"channels" => ["PHPFans"],
"data" => $data));
// Push to Query
$query = ParseInstallation::query();
$query->equalTo("design", "rad");
ParsePush::send(array(
"where" => $query,
"data" => $data));
You have to delegate the Parse itself to send your push notification instead of using your web server (more secure). So, you can manage this delegation via writing a cloud function in Parse backend, and call this cloud function from your web server. From links in comment section of post, you can call the cloud function via the Php SDK of Parse;
$results = ParseCloud::run("aCloudFunction", array("from" => "php"));
In cloud function, you have to query the installation table and find the user and send your push.Hope this helps.
Regards.