Score:0

Nginx headers parsing

cn flag
nvp

For example, I have nginx and incoming JSON header:

{
  "orgs" : {
    "first_org_roles": ["role_a_r", "role_b_r", "role_c_r"],
    "second_org_roles": ["role_d_r", "role_e_r", "role_f_r"]
  }
}

Is it possible to parse it into an array:

["role_a_r", "role_b_r", "role_c_r", "role_d_r", "role_e_r", "role_f_r"]

and set it as a header in nginx?

in flag
This is not a header, it's JSON data. And it has nothing to do with nginx.
in flag
If course it can be parsed that way. But to say how people need to know what you want to use to do it. What scripting/programming language/tool you want to use.
nvp avatar
cn flag
nvp
No, it's exactly header looks like json. My authentication service generates this header and sends me. And I should parse it and forward it further, to my services.
in flag
Yeah, sorry, I just read it again and realized I missed some parts. Some details are still missing though. are these headers that you get by a client and want to send it to some backend you are proxying for? Or the other way around?
nvp avatar
cn flag
nvp
Yes, my component has authentication by headers, but incoming header from my authentication service sends me this json with roles and it's incompatible. I wanna try to parse it with nginx.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.