I am trying to use rest api basic authentication and testing it through postman. On the authorization field, I used Type as Basic Auth and used the username and password in the field as in image below:
Then it automatically generates the following on Header :
So what I basically want is to print the value of Authorization i.e Basic YWRtaW46YWRtaW4= on my controller. Printing the username and password works fine with print_r($this->input->server('PHP_AUTH_USER')) and print_r($this->input->server('PHP_AUTH_PW')). However I didn't find a way to print the value from header field. Is there any best practice to achieve this. Any help appreciated. Thank You !
just copy paste this code and you get your output in this format ==>
Basic YWRtaW46YWRtaW4=
$token = $this->input->get_request_header('Authorization');
print_r($token);
die;
What I understand is you want to print the value from the header.
There is a way to print it to the console or to the Test tab.
var (name) = postman.getResponseHeader("value-you-want-to-print");
// to console
console.log((name));
// to Test
tests[(name)] = (name);
Related
In Power Automate, I am using an HTTP activity with the following parameters:
Method: POST
Uri: Example.com
Body:
{
"Username":"MyName",
"Password":"#mycode",
"PrivateKey":"1234"
}
This request works fine in Postman, but in Power Automate, it returns an error which says The power flow's logic app flow template was invalid. Unable to parse template language expression 'mycode': expected token 'LeftParenthesis' and actual 'EndOfData'. Which seems to me like it's unable to read the "#" sign because the password is supposed to be #mycode, not mycode
Is there an escape character I can use for this? Unfortunately I'm not able to change the password.
In Power Automate, special characters are always escpaed if you write them twice.
In your case it would look like this: "##mycode"
You can initialise a variable and store your data in it later pass in "send http action".
‘Send http action’
Screenshot link
Source video link
All Viewers I am New in Codeigniter, I need your guide to done my work, I want to Encrypted full URL like below example.
For example this is my url www.example.com & my controller is home, so full url is www.example.com/home
now I want to encrypted all controller, function like below
www.example.com/5115784bef2514430e7f74d9a71d4142a942efb0f7cc428626bda7633326f9d015fbacc60d93cd6b858f9b6e05c1e56263acb24297cecc720467eb4f222d81e5hdn5B
I can encrypted & decrypted the text well, but I just don't get how can I decrypted from url & make understand which controller or function its called, I want to decrypted everything after base_url.
please don't suggest me about using common controller, because I already know that & anyhow common controller its hide everything so its not required the encryption as I believe.
Waiting for your positive response, hopefully my problem will be solve soon. T.I.A
Well i never encrypt any URL before but you can use a php function url_encode
And "str_replace" function.
the reason for using "str_replace" beacause url_encode only encode special character in URL.
Hope I help some.
Try the code below.
urlencode(str_replace("your_domain.com/YourCOntrollerName/YourMethodName" , "SM5ah52" , yor_domain.com . "YourCOntrollerName/YourMethodName/YOuData"));
If not this. There is an library in CI Framework called Encryption.
You can get help from there Encryption.
Go with URI Routing and define one controller to decode whatever you are passing, and call proper controller / method from it.
You can use URI Routing with regular expressions.
$route["other_controllers/method"] = "other_controllers/method"; //you can add this kind of lines to not to affect other controllers
$route["([a-zA-Z0-9]+)"] = "home/decrypt/$1";
In the home controller, You can
Redirect to the page
Or
Load a view
public function decrypt($token){
//geting the page according to the token from database.
$desired_page = $this->some_model->get_page($token);
//if you want to redirect
redirect($desired_page);
//if you want to load a view
$this->load->view($desired_page);
}
When I wish to login as "pieraś", the page detects login "pieraĹ"
I tried selecting "URL ENCODE", changing jmeter.property csvdataset.file.encoding_list to "ISO 8859-2" only as well ass UTF-8 only.
JMETER request picture
How to make it work right?
In the HTTP request field "Content Encoding:" manually enter value "ISO-8859-2".
It works against jmeter.property "sampleresult.default.encoding"
I tried to use "pieraś" in jmeter, looks like JMeter is passing and processing this value properly. Some sample snap given below:
New to JMeter, and I'm probably missing some simple thing but I can't find it anywhere.
I'm trying to log into a web application so I send a GET request to the home page to retrieve the csrf token and then I use the regular expression extractor to retrieve it:
I then try to place the extracted token into the POST request:
But the extracted token doesn't show up in the request sent via the View Results Tree. Only the UserId and Password are passed which I manually defined:
My regular expression is finding a match as you can see here:
but even if it wasn't finding a match, it should still pass "NotFound" correct?
Any help is greatly appreciated!
Edit: Added a Debug Sampler and it is correctly showing the variable Token with it's correct value. So Token just isn't being added to the request via the RegEx User Parameter Pre Processor.
It's difficult to see what you're doing without seeing the LoginPage step, but you need to make sure you are adding the csrf token you've extracted in the right place.
Typically it could be as a query param, part of a post body or an http header.
As you can see the token has been extracted from your initial response in the Debug sampler, there must be something wrong in how or where the token is being applied to the LoginPage request. (As you say the RegEx User Parameter Pre Processor isn't adding it)
I've never used the PreProcessor and the Jmeter documentation explanation is a bit vague on what it does, but you can add the variables into your request without it using the variable saved for the capture groups - for input name this will be ${Token_g1} and for value it will be ${Token_g2} - which you will be able to see from the Debug Sampler. You'll need to add a Header or Cookie Manager to the Login Page element if this is where the token is.
By setting the template in the Extractor to $1$$2$ you create a variable with the name and value concatenated together. I'm not sure why you would need this, and I would guess that the name doesn't change - in which case you can just use capture group 2, or if you want to use the Variable name Token then update your template to be $2$
I'm using JMeter to stress test an API. I've got Basic Authentication set up - seems to be working great.
Now, i'm trying to randomize the credentials that JMeter passes across the wire. So, there's two ways I know I can do this.
Add a custom HTTP Header (via an HTTP Header Manager Element) and set then value to the random fields (ie. something I've read in from a csv file)
Use the HTTP Authorization Manager Element and pass in the username and password there.
Now, if I try and use method (1) above, I need to create the following header/data :-
Authorization: Basic <some Base64 encoded string in the format username:password>
eg.
Authorization: Basic OnVzZXIxOnBhc3Mx
Kewl. simple. BUT that header value is not getting passed across the wire :( I can add any other header type and it's passed across the wire..
hmm .. ok then .. lets try method (2).
Now that works .. but I can only hardcode in the username & password. I can't see how I can pass in a username VARIABLE (ie. ${usernmae} ) or a password VARIABLE (ie. ${password} ).... If it's hardcoded, then the server correctly replies with the correct page/data.
so .. can someone please help?
I would recommend trying the following:
Create a HTTP Authorization Manager Element
Setup the username and password to be variables, ${username} , ${password}
Create a CSV file with your usernames and passwords (do not use a header row)
create a CSV Data Set Config Element, with the variable names set to "username,password" (no quotes, and no space after the comma)
Each thread/loop will read a different value from the CSV file.
Alternately, if you want the value to be truely random for the login, there are some functions you can use to generate random numbers or send in the time of execution.