What are all the Tritium environment variables? - moovweb

Where can I find a full list of the Tritium variables (such as $host, $path, $content_type, etc.)?

You can find all the accessible environment variables by looking at your tmp/messages/.../final-env.json file.
According to the doc:
All the environment variables available are listed in the
final-env.json file. This file can be found in the {Moovweb Project
Path}/tmp/messages/{Folder ID} directory. To use one of these
environment variables in Tritium, you need to add a dollar sign before
it: $variable.
They provide a sample final-env.json file there:
{
"0": "https://www.dropbox.com",
"1": "https://www.dropbox.com",
"2": "SAMEORIGIN",
"3": "HTTP/1.0",
"Content-Type-Charset": "UTF-8",
"__catch_all__": ".moovapp.com",
"accept_encoding": "gzip,deflate",
"asset_host": "http://localhost:3003/",
"body": "true",
"body_length": "1195",
"cache_control": "no-cache",
"canonical_found": "false",
"charset_determined": "UTF-8",
"connection": "close",
"content_type": "text/html; charset=utf-8",
"cookie": "gvc=Mjg1NjE0NTk0MjAxMDUyNjY4MTc1NjYyMDE3OTAxNjU0NDk4NTc2",
"date": "Fri, 07 Sep 2012 01:57:35 GMT",
"device_stylesheet": "main",
"found_conn": "true",
"header_hh": "Host: ",
"host": "mlocal.dropbox.com",
"host_hh": "https://mlocal.dropbox.com",
"key": "x_frame_options",
"location": "https://www.dropbox.com/",
"method": "GET",
"path": "/",
"pragma": "no-cache",
"rewriter_url": "false",
"secure": "false",
"server": "nginx/1.0.14",
"set_cookie": "flash=; Domain=dropbox.com; expires=Fri, 07-Sep-2012 01:57:35 GMT; Path=/; httponly",
"slash_path": "/",
"source_host": "www.dropbox.com",
"status": "302",
"use_global_replace_vars": "true",
"user_agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.54.16 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
"value": "SAMEORIGIN",
"x_frame_options": "SAMEORIGIN"
}

Related

I have a problem setting up a RESTAPI call in Azure Data Factory

I am trying to create a POST to an REST-API but I get this output (Caught by an Logic Apps HTTP grab):
{
"headers": {
! "Connection": "Keep-Alive",
"Accept": "application/json",
"Accept-Encoding": "gzip,deflate",
! "Host": "prod-187.westeurope.logic.azure.com:443",
"User-Agent": "azure-data-factory/2.0",
"Content-Length": "55",
! "Content-Type": "application/json",
"Content-Encoding": "UTF-8"
},
"body": {
"$content-encoding": "UTF-8",
"$content-type": "application/json",
"$content": "eyJuYW1lIjoiSmVzcGVyIEIuIEhhbnNlbiIsInNhbGFyeSI6IjEyMzQ1IiwiYWdlIjoiMzQifQ=="
}
}
I would have expected this:
{
"headers": {
"Accept": "application/json",
"Accept-Encoding": "deflate,gzip",
"Host": "prod-187.westeurope.logic.azure.com",
"User-Agent": "Mozilla/5.0,(Windows NT 10.0; Win64; x64),AppleWebKit/537.36,(KHTML, like Gecko),Chrome/103.0.5060.134,Safari/537.36,Edg/103.0.1264.71",
"X-Real-IP": "212.237.135.241",
"Content-Length": "42",
"Content-Type": "application/json"
},
"body": {
"name": "Jesper B. Hansen",
"salary": "12345",
"age": "34"
}
}
Why is the output scrambled?
I tried using a REST Service on a sink, and also tried it with an externalCall no real difference...
I must say, I am new at ADF, but I hope you have some good help for me.

Cors blocking me from GET-ing my server endpoint and redirecting

I'm trying to build an Oauth2 flow. Cors keeps blocking my GET request to my own server.
localhost:3000 is the browser.
localhost:3001 is the server.
I have cors setup in NestJS below and it works for every other non-redirecting endpoint:
// main.ts
import { corsConfig } from '#common/config/index';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: [
/^https?:\/\/localhost:3000/,
],
methods: ['GET', 'POST'],
credentials: true,
});
await app.listen(process.env.PORT || 3001);
}
bootstrap();
When requesting to my server endpoint... these are the request.headers
{
"host": "localhost:3001",
"connection": "keep-alive",
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\"",
"accept": "application/json, text/plain, */*",
"sec-ch-ua-mobile": "?0",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) SomeStuff",
"sec-ch-ua-platform": "\"Windows\"",
"origin": "http://localhost:3000",
"sec-fetch-site": "same-site",
"sec-fetch-mode": "cors",
"sec-fetch-dest": "empty",
"referer": "http://localhost:3000/",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.9,fr;q=0.8,es;q=0.7,de;q=0.6",
"cookie": "Authentication=someStuff"
}
When responding from my server, these are the response.headers
{
"cross-origin-opener-policy": "same-origin",
"cross-origin-resource-policy": "same-origin",
"x-dns-prefetch-control": "off",
"expect-ct": "max-age=0",
"x-frame-options": "SAMEORIGIN",
"strict-transport-security": "max-age=15552000; includeSubDomains",
"x-download-options": "noopen",
"x-content-type-options": "nosniff",
"origin-agent-cluster": "?1",
"x-permitted-cross-domain-policies": "none",
"referrer-policy": "no-referrer",
"x-xss-protection": "0",
"access-control-allow-origin": "http://localhost:3000",
"vary": "Origin",
"access-control-allow-credentials": "true",
"x-ratelimit-limit": "30",
"x-ratelimit-remaining": "28",
"x-ratelimit-reset": "60"
}
And this is the Cors error in my browser console
Access to XMLHttpRequest at 'https://example.com/' (redirected from
'http://localhost:3001/test') from origin 'http://localhost:3000'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource.
What do I need to change to allow a GET request to be redirected in the browser? Or is this not possible and it requires simply visiting the site with window.location?
I know this is not the ideal solution, but for my personal projects in a local environment, I used the "Moesif Origin & CORS Changer" browser extension to combat this annoying issue.
Google Chrome: https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbc
Firefox: https://addons.mozilla.org/en-US/firefox/addon/moesif-origin-cors-changer1/

Oauth2-Proxy do not pass X-Auth-Request-Groups header

I'm using Azure B2C for authenticate my users. For authentication piece I have oauth2-proxy running in kubernetes cluster. Oauth2-Proxy is running behind ingress-nginx and it's passing most of required headers but I do not get X-Auth-Request-Groups header in my upstream service that is behind oauth2-proxy.
Here is my token that I get from B2C:
{
"typ": "JWT",
"alg": "RS256",
"kid": "kid_value"
}.{
"exp": 1604420825,
"nbf": 1604417225,
"ver": "1.0",
"iss": "iss_value",
"sub": "sub_value",
"aud": "aud_value",
"acr": "acr_name",
"nonce": "defaultNonce",
"iat": 1604417225,
"auth_time": 1604417225,
"groups": [
"group1"
],
"identityProviders": [
"email.com"
],
"firstname": "First Name",
"surname": "Last Name",
"idp": "IDP_VALUE",
"email": "username#email.com",
"preferred_username": "User Name"
}.[Signature]
And here are headers that I get in my upstream service after successful authentication:
{
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
Accept-Encoding: "gzip, deflate, br",
Accept-Language: "en-US,en;q=0.9",
Content-Length: "0",
Cookie: "COOKIE",
Sec-Fetch-Dest: "document",
Sec-Fetch-Mode: "navigate",
Sec-Fetch-Site: "none",
Sec-Fetch-User: "?1",
Upgrade-Insecure-Requests: "1",
User-Agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
X-Auth-Request-Access-Token: "ACCESS_TOKEN",
X-Auth-Request-Email: "username#email.com",
X-Auth-Request-Preferred-Username: "User Name",
X-Auth-Request-User: "UserID",
X-B3-Parentspanid: "Parentspanid",
X-B3-Sampled: "0",
X-B3-Spanid: "Spanid",
X-B3-Traceid: "Traceid",
X-Envoy-Attempt-Count: "1",
X-Forwarded-Client-Cert: "CEERT",
X-Forwarded-For: "Forwarded-For",
X-Forwarded-Host: "Forwarded-Host",
X-Forwarded-Port: "443",
X-Forwarded-Proto: "https",
X-Real-Ip: "Real-Ip",
X-Request-Id: "Request-Id",
X-Scheme: "https"
}
all X-Auth-Request-* headers are coming but not the one with Groups. I'm using docker image quay.io/oauth2-proxy/oauth2-proxy:v6.1.1 and I saw in config https://oauth2-proxy.github.io/oauth2-proxy/configuration option "--oidc-groups-claim" but when I try to use it container won't start because this option isn't available in this version.
Any ideas what I'm missing?
It seems that the problem is image that I'm using quay.io/oauth2-proxy/oauth2-proxy:v6.1.1, when I built own image from latest master (3rd of November 2020) everything seems to be working fine and X-Auth-Request-Groups header is passed to upstream service.

Getting invalid_payment response from uber with 400 status code;using rest API

I am using REST API to book and uber ride using: https://api.uber.com/v1.2/requests .
It's not working with payment methods other than Cash.
I am getting 400 with code:invalid_payment
Can someone please help me out;
I am able to make payment using cash & Paytm for Indian locations.
I am not able to make payment using cash for US locations.
I am not able to make payment using the card for Indian & US locations.
When I add a new card via the Uber app and try to book a cab in the uber using the card it works; When I try to use the same card using my app it shows error. After this when I try to book a cab using the uber app; it doesn't work.
This the the response I am getting from Uber:
{
"data": {
"meta": {},
"errors": [
{
"status": 400,
"code": "invalid_payment",
"title": "The rider's payment method is invalid and they must update their billing info."
}
]
},
"status": 400,
"headers": {
"server": "nginx",
"strict-transport-security": "max-age=604800",
"x-frame-options": "SAMEORIGIN",
"content-type": "application/json",
"content-geo-system": "wgs-84",
"date": "Fri, 05 Apr 2019 06:28:50 GMT",
"x-content-type-options": "nosniff",
"content-length": "151",
"cache-control": "max-age=0",
"connection": "keep-alive",
"x-xss-protection": "1; mode=block"
},
"config": {
"transformRequest": {},
"transformResponse": {},
"timeout": 180000,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"headers": {
"Accept": "application/json, text/plain, /*",
"Content-Type": "application/json",
"authorization": "Bearer JA.ZWU",
"Accept-Language": "en_US"
},
"method": "post",
"url": "https://api.uber.com/v1.2/requests",
"data": "{\"start_latitude\":40.8037381,\"start_longitude\":-73.9577813,\"end_latitude\":40.68780810000001,\"end_longitude\":-73.8057292,\"fare_id\":\"7636a3afa24d7648656aabbcc695bf094d4eed6d9323f3b10a5a5868a47c\",\"product_id\":\"b64-5de2-4539-a35a-986d6e58f186\",\"payment_method_id\":\"0xxxx-90ce-4c1d-a8c4-af7b1a00c3cf\"}"
},
"request": {
"UNSENT": 0,
"OPENED": 1,
"HEADERS_RECEIVED": 2,
"LOADING": 3,
"DONE": 4,
"readyState": 4,
"status": 400,
"timeout": 180000,
"withCredentials": true,
"upload": {},
"_aborted": false,
"_hasError": false,
"_method": "POST",
"_response": "{\"meta\":{},\"errors\":[{\"status\":400,\"code\":\"invalid_payment\",\"title\":\"The rider's payment method is invalid and they must update their billing info.\"}]}",
"_url": "https://api.uber.com/v1.2/requests",
"_timedOut": false,
"_trackingName": "unknown",
"_incrementalEvents": false,
"responseHeaders": {
"Server": "nginx",
"Strict-Transport-Security": "max-age=604800",
"X-Frame-Options": "SAMEORIGIN",
"Content-Type": "application/json",
"Content-Geo-System": "wgs-84",
"Date": "Fri, 05 Apr 2019 06:28:50 GMT",
"X-Content-Type-Options": "nosniff",
"Content-Length": "151",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"X-XSS-Protection": "1; mode=block"
},
"_requestId": null,
"_headers": {
"accept": "application/json, text/plain, /*",
"content-type": "application/json",
"authorization": "Bearer JA.VUNU",
"accept-language": "en_US"
},
"_responseType": "",
"_sent": true,
"_lowerCaseResponseHeaders": {
"server": "nginx",
"strict-transport-security": "max-age=604800",
"x-frame-options": "SAMEORIGIN",
"content-type": "application/json",
"content-geo-system": "wgs-84",
"date": "Fri, 05 Apr 2019 06:28:50 GMT",
"x-content-type-options": "nosniff",
"content-length": "151",
"cache-control": "max-age=0",
"connection": "keep-alive",
"x-xss-protection": "1; mode=block"
},
"_subscriptions": [],
"responseURL": "https://api.uber.com/v1.2/requests"
}
}
Actual result should be ride request accepted.

curl command in Matlab

I am trying to replicate a curl command which works fine on a unix machine:
curl -X POST --insecure <ENDPOINT> -H "Content-Type: application/json" -H "<OTHER HEADERS>" -d #<PATH TO JSON FILE>
What Matlab command can I use to replicate this command on a Windows machine? I'm struggling to find a way to add the --insecure option
Many thanks
Let's use an example, I'm using resclient for emacs, but do no get scary for that
My goal is to amke this call with matlab:
#
# Request
#
:auth-token = abcd1234
:number := (+ 1 2 3 4)
:text := (concat "This is " ":num" "ber")
#
# Multiline variable referencing another variable
#
:common-headers = <<
Authentication: :auth-token
User-Agent: MyApp/1.0
Content-type: application/json
#
# ...and another one
:common-body = <<
{ "number": :number, "text": ":text" }
#
# Now, use them both in request
#
POST http://httpbin.org/post?q=1
:common-headers
:common-body
which result is:
{
"args": {
"q": "1"
},
"data": "{ \"number\": 10, \"text\": \"This is 10\" }",
"files": null,
"form": null,
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8;q=1, gb2312;q=0.5, iso-8859-1;q=0.5, big5;q=0.5, iso-2022-jp;q=0.5, shift_jis;q=0.5, euc-tw;q=0.5, euc-jp;q=0.5, euc-jis-2004;q=0.5, euc-kr;q=0.5, us-ascii;q=0.5, utf-7;q=0.5, hz-gb-2312;q=0.5, big5-hkscs;q=0.5, gbk;q=0.5, gb18030;q=0.5, iso-8859-5;q=0.5, koi8-r;q=0.5, koi8-u;q=0.5, cp866;q=0.5, koi8-t;q=0.5, windows-1251;q=0.5, cp855;q=0.5, iso-8859-2;q=0.5, iso-8859-3;q=0.5, iso-8859-4;q=0.5, iso-8859-9;q=0.5, iso-8859-10;q=0.5, iso-8859-13;q=0.5, iso-8859-14;q=0.5, iso-8859-15;q=0.5, windows-1250;q=0.5, windows-1252;q=0.5, windows-1254;q=0.5, windows-1257;q=0.5, cp775;q=0.5, cp850;q=0.5, cp852;q=0.5, cp857;q=0.5, cp858;q=0.5, cp860;q=0.5, cp861;q=0.5, cp863;q=0.5, cp865;q=0.5, cp437;q=0.5, macintosh;q=0.5, next;q=0.5, hp-roman8;q=0.5, adobe-standard-encoding;q=0.5, iso-8859-16;q=0.5, iso-8859-7;q=0.5, windows-1253;q=0.5, cp737;q=0.5, cp851;q=0.5, cp869;q=0.5, iso-8859-8;q=0.5, windows-1255;q=0.5, cp862;q=0.5, iso-2022-jp-2004;q=0.5, cp874;q=0.5, iso-8859-11;q=0.5, viscii;q=0.5, windows-1258;q=0.5, iso-8859-6;q=0.5, windows-1256;q=0.5, iso-2022-cn;q=0.5, iso-2022-cn-ext;q=0.5, iso-2022-jp-2;q=0.5, iso-2022-kr;q=0.5, utf-16le;q=0.5, utf-16be;q=0.5, utf-16;q=0.5, x-ctext;q=0.5",
"Authentication": "abcd1234",
"Content-Length": "38",
"Content-Type": "application/json",
"Extension": "Security/Digest Security/SSL",
"Host": "httpbin.org",
"Mime-Version": "1.0",
"User-Agent": "MyApp/1.0"
},
"json": {
"number": 10,
"text": "This is 10"
},
"origin": "46.222.44.201",
"url": "http://httpbin.org/post?q=1"
}
// POST http://httpbin.org/post?q=1
// HTTP/1.1 200 OK
// Server: nginx
// Date: Mon, 13 Feb 2017 10:29:40 GMT
// Content-Type: application/json
// Content-Length: 1768
// Connection: keep-alive
// Access-Control-Allow-Origin: *
// Access-Control-Allow-Credentials: true
// Request duration: 0.613051s
Let's transform it to a curl:
curl -i -H 'Content-type: application/json' -H 'User-Agent: MyApp/1.0' -H 'Authentication: abcd1234' -XPOST 'http://httpbin.org/post?q=1' -d '{ "number": 10, "text": "This is 10" }'
and finally translate it to matlab I recommend you to use urlread2 this is a matlab program from matlab fileexchange you only to register and you can dowload it. it was made by Jim Hokason, for recent matlab versions (2016) you can try this
So with urlread2 from here
the above request could be this:
>> %% Create the headers
>> hct = http_createHeader('Content-Type','application/json');
>> hua = http_createHeader('User-Agent','matlab');
>> ha = http_createHeader('Authentication','abcd1234');
>> %% method
>> method = 'POST';
>> body = '{"number":10, "text: "this is 10"}';
>> x = urlread2('http://httpbin.org/post?q=', method, body, [hct hua ha])
x =
{
"args": {
"q": ""
},
"data": "{\"number\":10, \"text: \"this is 10\"}",
"files": {},
"form": {},
"headers": {
"Accept": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
"Authentication": "abcd1234",
"Content-Length": "34",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "matlab"
},
"json": null,
"origin": "46.222.44.201",
"url": "http://httpbin.org/post?q="
}
For the insecure option, I do not think that this verify ssl certifiactes