FILTERED instead of the param itself in the console debug message - phoenix-framework

I'm following the authentication example in the Phoenix book and I can't get the username/password to work during Login even though I'm sure they match previous registration/creation.
When trying to understand the problem I realised that I can't see the password in the console but instead I have:
Processing by FabASA.SessionController.create/2
Parameters: %{"session" => %{"password" => "[FILTERED]", "username" => "lol"}}
Pipelines: [:browser]
Why does [FILTERED] appear and how to see the password value?

By default Phoenix filters out any parameters containing password. This is to prevent passwords from being printed to log files.
You can remove this default by passing an empty list to the filter_parameters config, probably in config/dev/exs.
config :phoenix, :filter_parameters, []
The documentation for this is in Phoenix.Logger

Related

Set parameter value programatically while generating QuickSight embedded report URL

I am working on the QuickSight embedded report url generation. I am trying to set the parameter default value programatically using below JAVA code.It is not working.
GetDashboardEmbedUrlRequest req = new GetDashboardEmbedUrlRequest()
.withAwsAccountId(awsAccountId)
.withDashboardId(reportInput.getDashboadId())
.withUserArn(userArn)
.withIdentityType(EmbeddingIdentityType.QUICKSIGHT)
.withSessionLifetimeInMinutes(sessionTimeout);
req.putCustomQueryParameter("CampaignName", "ABC");
req.putCustomQueryParameter("reportDev", "Program");
// get the dashboard URL
String embedUrl = quickSightClient.getDashboardEmbedUrl(req).getEmbedUrl();
LOGGER.info("URL:{}",embedUrl);
In the above code, "CampaingName" is multivalues parameter attached to the dropdown control. It's default value is set to "[All]" while building a report. Parameter "reportDev" is single value parameter with no default value and no control or any thing attached to it. Dummy parameter I introduced for testing.
After running the code, when I copy the url printed in console by logger and run it in the browser, report opens properly but with "CampaignName" and "reportDev" both set as "ALL".
Sample generated ulr is as below
https://xx-xxxx-x.quicksight.aws.amazon.com/embed/xxxxxxxxxxxxxxxxx/dashboards/xxxxxxxxxxxxxxxxxxx?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&identityprovider=quicksight&isauthcode=true
Well if I get the dashboard url and pass the parameter in the url to, it worked properly. "CampaignName" is set to "ABC" and "reportDev" set to "Program". According the data in the report also got filtered. Url working corrctly as below.
https://xx-xxxx-1.quicksight.aws.amazon.com/embed/xxxxxxxxxxxx/dashboards/xxxxxxxxxxxxxxx#p.reportEnv=Program&p.CampaignName=ABC
Can anybody please tell me what is missing in my code. I tried below variation as well but no luck.
req.putCustomQueryParameter("p.CampaignName", "ABC");
req.putCustomQueryParameter("p.reportDev", "Program");
Have you tried to drop the p. from the parameter name, eg
req.putCustomQueryParameter("CampaignName", "ABC");
req.putCustomQueryParameter("reportDev", "Program");
I know that worked for the javascript sdk.

How can I get Google Auth working with Laravel?

I'd like to know if there's an easy fix for this error that I'm getting while trying to add support for Google sign-in to my website, since I can only reproduce it while on a Laravel-based environment. Vanilla PHP applications do run just fine.
This is my relevant code:
if ($request->has('googleToken')) {
$client = new Google_Client(['client_id' => env('GOOGLE_PLATFORM_CLIENT_ID') ]);
$payload = $client->verifyIdToken($credentials['googleToken']);
if (!$payload) {
return response([ 'error' => 'Invalid token, please try using form-based authentication.' ], Response::HTTP_FAILED_DEPENDENCY);
}
$user['googleToken'] = $credentials['googleToken'];
}
I know I'm doing too relaxed validations, but please just focus on the fact that I'm just testing and I plan to change this code in the near future.
The code above, receives its data through an Axios PUT request from the frontend with the payload looking like this:
{
googleToken: "eyJhbGciOiJSUzI1NiIsImtpZCI6IjE5ZmUyYTdiNjc5NTIzOTYwNmNhMGE3NTA3OTRhN2JkOWZkOTU5NjEiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXpwIjoiNTkyODkzNjE3ODYzLXRscDdvaDByaTk2dTZxZGxrOXYwbHAyanQyNDlkdDNsLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiNTkyODkzNjE3ODYzLXRscDdvaDByaTk2dTZxZGxrOXYwbHAyanQyNDlkdDNsLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTE1NTg0MDg0NTE2OTMxOTQzODU..."
mailAddress: "user#mail.com"
}
The problem is that the payload would simply return false. I decided to try to investigate the issue, so I went to the definition of verifyIdToken contained within Google_Client and, from there, jumped over to the function that finally returns to its parent, which is verifyIdToken from the class Verify.
Inside of that class, there's a pretty loose try/catch block in which I decided to try adding a generic exception case so that I could quickly print the error message for debugging. I did, and this is the output I got:
OpenSSL unable to verify data: error:0909006C:PEM routines:get_name:no start line
This is what's failing internally, and from this point on, I don't really have an idea about how to proceed since the error feels very cryptic, or at least it's not in my field of knowledge.
The OpenSSL error you quoted indicates that your client was not able to read any/further PEM-encoded data. Refer to https://www.openssl.org/docs/man1.1.1/man3/PEM_read.html.
OpenSSL unable to verify data: error:0909006C:PEM routines:get_name:no start line
Here,
'PEM routines' represents the library within OpenSSL
'get_name' is the function
'no start line' is the reason
Is you client able to access the necessary certificates/keys?

How to properly use the CI-Merchant library's config file

I am trying to add items to merchant.php (the CI-Merchant library's config file, which I believe is auto-loaded by CodeIgniter). I want to be able to set the settings for the payment gateway (driver) I am choosing in the settings so that I don't have to write it out in every controller that is calling the library/driver and I do not want to hardcode the settings in the driver.
These are the settings I am trying to save, but I could have others with different gateways:
$config['authorize_net']['api_login_id'] = '***';
$config['authorize_net']['transaction_key'] = '***';
$config['authorize_net']['test_mode'] = TRUE;
$config['authorize_net']['developer_mode'] = TRUE;
However this is causing 2 warnings. The first:
A PHP Error was encountered
Severity: Warning
Message: stripos() expects parameter 1 to be string, array given
Filename: libraries/merchant.php
Line Number: 97
And the second:
A PHP Error was encountered
Severity: Warning
Message: strtolower() expects parameter 1 to be string, array given
Filename: libraries/merchant.php
Line Number: 103
So it seems to me that CodeIgniter is automatically passing the merchant.php config file to the library but it was not expecting it (which also confuses me, because in the CI-Merchant download it comes with the config file).
My worst case scenario would be to change the "default settings" in merchant_authorize_net.php the but I really want to avoid this, below is what that default settings function looks like.
public function default_settings()
{
return array(
'api_login_id' => '',
'transaction_key' => '',
'test_mode' => FALSE,
'developer_mode' => FALSE,
);
}
My questions are:
Is there a proper way to use the CI-Merchant's config file?
If not, is there a way to have driver-specific config files in CodeIgniter?
The config file is actually just there as boilerplate code which should probably be removed. CI-merchant itself doesn't have any logic to automatically read the config file for you.
Generally the recommended approach is to store the settings in your own config file (or environment variables), and then use those settings in your controller to initialize the library. You are correct that it's best to try and avoid editing anything inside the library folder.
If you are starting a new project I also recommend you check out Omnipay, the successor to CI-Merchant, as CI-Merchant will not be receiving any further development.

Mongo::OperationFailure - need to login when using from_uri

My goal is to connect with my heroku/mongolab database but I keep getting this error:
Mongo::OperationFailure at /mongotest/a/b
: need to login
file: networking.rb
location: send_message_with_gle
line: 89
The code I'm using is:
client = Mongo::MongoClient.from_uri(ENV['MONGOLAB_URI'])
db = client.db('test')
testcoll = db['testcoll']
testcoll.insert({:'_id' => "def", :'test' => "woop de doop"})
testcoll.find()
ENV['MONGOLAB_URI']=mongodb://heroku_app########:password#ds0xxxxx.mongolab.com:xxxxx/heroku_app########
I know that the uri is correct and contains the username and password, so why the error? Also, the error occurs on the insert() line, not the line where I authenticate.
Welp, turns out the url connects me to the heroku_app######## database, but I'm then trying to access the database called test so obviously I'm not authenticated. Would have been nice Mongo had returned an error specifying that I had logged in but not to the right database. Oh well.
I hadn't paid enough attention to the format of the uri, which is
mongodb://username:password#host:port/database
The database part is... pretty important, it turns out.
(I actually found the answer to this while writing the test, but if this answer had existed it might have saved me an embarrassingly large amount of time, so I'm writing it again and answering it myself.)

Splunk-client (with Nokogiri) giving Undefined Namespace Prefix

I'm using splunk-client to extract results from splunk. Here's the code:
query = "sourcetype=collection #{order_id}"
search = #splunk_client.search(query)
search.wait
The search is happening fine, and it seems like I'm doing everything according to the example (https://github.com/cbrito/splunk-client), but I get this error on the 'search.wait' line:
Undefined namespace prefix: //s:key[#name='isDone']
Any ideas what could be going wrong? Running these commands in irb works fine. Is there some sort of blocking issue?
There is currently very little error checking which occurs within the gem itself. The reason for the error is that wait looks for the status of the isDone key to change to true.
Since your credentials were not properly setup in the first place, the gem creates a search object with an invalid session. The search does not initially fail, because enough response came back from Splunk that Nokogiri processes it into an object without a Splunk search sid.
In the future I should likely raise an exception if a proper sid is not returned to avoid confusion.
Source: I wrote the gem.
I found out the issue -- the splunk client wasn't authenticating properly, and so search was actually a broken SplunkJob object (with a nil username and authentication key). It's strange that there was no error raised until the wait command, but upon inspecting the search object, one of the fields stated that the object was malformed.

Resources