Need to read cookies value by it's name angularjs - angularjs

I've cookie in my application and I need to read it using angularJS ngCookies.
When I exported the cookies from browser extension it looks like following json :
[
{
"domain": "localhost",
"hostOnly": true,
"httpOnly": false,
"name": "JSESSIONID",
"sameSite": "no_restriction",
"secure": true,
"session": true,
"storeId": "0",
"value": "00FC04BF082458FFE6F175C7E03F5712",
"id": 18
}
]
there can be more objects in this JSON along with 'JSESSIONID'. so I want to read only JSESSIONID's value.
my Code :
var jsessionCookie = $cookies.get('JSESSIONID');
console.log(" Cookies 'JSESSIONID' : "+jsessionCookie);
I'm getting undefined object.

The code you have seems fine, but the underlying issue is different.
You have your cookie marked as
"httpOnly": true
This means that cookie cannot be accessed by client side code including Angular.js.
The only way to access it is to change the code that generates the code so the cookie is not marked as httpOnly. There are some security considerations for making the change, so make sure you understand what you are doing.
You can read more about HttpOnly at OWASP web site.

To store a cokkie,
$cookies.put("cookie_name","cookie_value",{"expires":expireDate,"domain":"domain_name"});
To get a stored cookie
var cookieValue = $cookies.get("cookie_name);

Related

Microsoft Graph API beta/reports has no data

I have been trying to access MFA information for my account using the Microsoft Graph API. This information is included in the beta version of the API and is located at https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails. Although I can GET this with no issue, there seem to be no results available, as the response is:
{'#odata.context': 'https://graph.microsoft.com/beta/$metadata#reports/credentialUserRegistrationDetails', 'value': []}
when I expect something more like:
"#odata.context":"https://graph.microsoft.com/beta/reports/$metadata#Collection(microsoft.graph.credentialUserRegistrationDetails)",
"value":[
{
"id" : "id-value",
"userPrincipalName":"userPrincipalName",
"userDisplayName": "userDisplayName-value",
"authMethods": ["email", "mobileSMS"],
"isRegistered" : false,
"isEnabled" : true,
"isCapable" : false,
"isMfaRegistered" : true
}
]
}
I make this API call using the reports.read.all permission and whilst I may be lacking other permissions to be able to access the data, I really have no idea how to start troubleshooting this issue. I was wondering if anyone could shed some light on why I cant see any "value" data?

Access Storage Account Key from a resource outside the ARM template

I'm using several ARM templates in our project, each of them meant for a different component, and there's also a Common ARM template that includes all resources that most of the elements need to work, as SqlServer, Storage Accounts, Redis cache(only one of this resources for all the elements)
The thing is, as Storage account is in a separate ARM template(Common infrastructure ARM template), I'm not able to access the Storage account keys from the component template. I need this to properly set the value of the connection string for the component to use it. If I include the storage account resource in the component template, I can access it via:
[concat('DefaultEndpointsProtocol=https;AccountName=',
variables('YFO.StorageAccount.Name'), ';AccountKey=',
listKeys(resourceId('Microsoft.Storage/storageAccounts',
variables('YFO.StorageAccount.Name')), providers('Microsoft.Storage',
'storageAccounts').apiVersions[0]).keys[0].value)]
But when I remove it from the component template, as it should be, then I get the following error:
New-AzureRmResourceGroupDeployment :
Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template reference '**********' is not valid: could not
find template resource or resource copy with this name. Please see
https://aka.ms/arm-template-expressions/#reference for usage details.'
It seems listKeys won't do the work if the resource is outside the template you are trying to deploy
For the AppInsights component, I was able to do this with:
[reference(concat('Microsoft.Insights/components/',
variables('AppInsightsName'))).InstrumentationKey]
even if the AppInsights resource is located out of the component ARM template, but I cannot do it with Storage account as the object returned for Storage Account in reference function is as following:
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": false,
"encryption": {
"services": {
"file": {
"enabled": true,
"lastEnabledTime": "2018-08-18T06:05:57.3069884Z"
},
"blob": {
"enabled": true,
"lastEnabledTime": "2018-08-18T06:05:57.3069884Z"
}
},
"keySource": "Microsoft.Storage"
},
"provisioningState": "Succeeded",
"creationTime": "2018-08-18T06:05:56.8228127Z",
"primaryEndpoints": {
"blob": "https://yfomormonttest.blob.core.windows.net/",
"queue": "https://yfomormonttest.queue.core.windows.net/",
"table": "https://yfomormonttest.table.core.windows.net/",
"file": "https://yfomormonttest.file.core.windows.net/"
},
"primaryLocation": "westeurope",
"statusOfPrimary": "available",
"secondaryLocation": "northeurope",
"statusOfSecondary": "available"
}
Any clue?
Thanks and regards.
The problem was in providers('Microsoft.Storage', 'storageAccounts').apiVersions[0] to get the API version that listkeys needs as a parameter. Setting directly the parameter as 2018-07-01 did work

Getting shareable link to document in react app

I am currently making an app that generates Itineraries and I am able to convert the html to pdf using PDFjs using something like this:
var doc = new jsPDF();
doc.fromHTML(html);
doc.save("YourItinerary.pdf");
How should I proceed about making a shareable link to this pdf on client-side preferably using an API such as Google Drive?
Getting the shareable link would be to get the webViewLink which you can try by passing webViewLink as parameter in the 'fields' property in Files.get. This returns a link you can open in any browser. However, you also have to deal with permissions.
To make the webViewLink (your shareable link) work for anyone you can use in Permissions.create:
{
"role": "writer",
"type": "anyone",
}
To make the webViewLink available to certain users only you'll have a request body like:
{
"role": "writer",
"type": "user",
"emailAddress": "someuser#gmail.com"
}

Open URL in IBM Watson conversation

I am using a Blumix free account to develop a chat-bot using watson conversation.
How do I add a clickable URL in the response, or automatically call a URL in browser?
I have edited the "advanced response" using the suggestions as described on this page but could not get it work.
How can I achieve that?
I don't know if I understood your question correctly, but.. if you wants add some url inside flows Conversation Service (IBM Watson), try it:
1º: Add the url with tag <a target> and href= your URL inside flows. See the example:
JSON:
"output": {
"text": "This is a link <a target=\"_blank\" href= \"https://www.choosemyplate.gov\">Food and nutrition Guide</a>.\n<br/><br/>Talk to you later, bye for now!"
},
2º See that it did not work inside the Conversation, because it will be your browser that will render the html.
3º If you open with your browser, it works, see:
See that the link is showing up, and this will work for other things in html, like button, for example...
But if you can: based on user input should access a url:
This is done by using two features: Context.request skip_user_input
A request is a special context variable that has args, name and result. It is used to tell the calling app that it should do some action based on this variable.
Setting skip_user_input is optional. In many cases, you might want to execute some business logic in your application and then provide its results via result. Setting skip_user_input to true, will tell Watson Conversation to not wait for input from the user. Thus, your condition on the next node should be based on the content inside result.
{
"output": {},
"context": {
"request": {
"args": {
"url_to_invoke": "your_url"
},
"name": "Call_A_URL",
"result": "context.response"
},
"skip_user_input": true
}
}
Reference: IBM Professional #Dudi: here.

String concatenation issue with Azure Logic Apps

I'm creating an ARM template that deploys an Web App (an Mvc Api) and a Logic App.
I'm attempting to define an HTTP Action within the Logic App such that it dynamically concatenates the base Uri of the Api as well as a property of the current item using splitOn and #triggerBody(). The base Uri itself is concatenated from a set of parameters in the ARM template into a variable variables('hockeyAppAPISettings').Uri.
Here's the relevant snipped of the action definition:
"actionName": {
"conditions": [ ],
"inputs": {
"authentication": {
"audience": "[variables('apiSettings').Authentication.Audience]",
"clientId": "[variables('apiSettings').Authentication.ClientId]",
"secret": "[variables('apiSettings').Authentication.Secret]",
"tenant": "[variables('apiSettings').Authentication.Tenant]",
"type": "ActiveDirectoryOAuth"
},
"method": "patch",
"uri": "[concat(variables('apiSettings').Uri, '/#{triggerBody()['Id']}/ScanningInProgress')]"
//"uri": "[concat(variables('apiSettings').Uri, '//#{triggerBody()[/'Id/']}//ScanningInProgress')]"
//"uri": "[concat(variables('apiSettings').Uri, '//##{triggerBody()[/'Id/']}//ScanningInProgress')]"
},
"type": "Http"
},
The "uri" section is what i'm struggling with. I've sprinkled various escape characters (\ and #) in differing patterns through out this.
I either can't get the deployment to succeed w/deployment errors like:
Unable to parse template language expression
'concat(variables('apiSettings').Uri,
'//#{triggerBody()[/'Id/']}//ScanningInProgress')': expected token
'RightParenthesis' and actual 'Identifier'. Please see
http://aka.ms/arm-template-expressions for usage details..'.
Or if I get the deployment working and then look at the code in the portal after deployment, the string concatenation doesn't seem to work properly. The variable doesn't get converted to its value.
I have validated that if I edit the Uri directly (via the portal HTML editor) using this: "uri" : "https://edited.azurewebsites.net/api/Packages/#{triggerBody()['Id']}/ScanningInProgress" the Logic App will make a patch call for each item that comes from the HTTP trigger.
What am I doing wrong?
You need to escape the inner single quotes, i.e. try
"uri": "[concat(variables('apiSettings').Uri, '/#{triggerBody()[''Id'']}/ScanningInProgress')]"
Alternatively you can use the dot notation to reference the property, i.e.
"uri": "[concat(variables('apiSettings').Uri, '/#{triggerBody().Id}/ScanningInProgress')]"
For me changing this
"uri": "[concat(parameters('APIMUrl_param'), '/sales-management/differential-reference-codes/v1/?instance=', parameters('APIDRCInstance_param'), '&filter=differentialReferenceCode%20eq%27', variables('varDRC'), '%27')]",
to this has worked
"uri": "#concat(parameters('APIMUrl_param'), '/sales-management/differential-reference-codes/v1/?instance=', parameters('APIDRCInstance_param'), '&filter=differentialReferenceCode%20eq%27', variables('varDRC'), '%27')",

Resources