papakay

papakay

SAMLY integration not working on production. Error: malformed request, a Poison.SyntaxError exception

Please i’m having issue getting samly (GitHub - handnot2/samly: Elixir Plug library to enable SAML 2.0 SP SSO in Phoenix/Plug applications. · GitHub) to work on production everything works fine on dev but i get error 502 bad request error with distillery build.

After using curl to call the endpoint i found out that cowboy could not process the request to the error:

malformed request, a Poison.SyntaxError exception was raised with message "Unexpected token at position 1:"
<h5 class="struct">
   Plug.Parsers.ParseError
   <small>at POST</small>
   <small class="path">/sso/auth/signin/entidp</small>
</h5>
<h1 class="title">malformed request, a Poison.SyntaxError exception was raised with message "Unexpected token at position 1: "</h1>

Please how can i resolve this issue?

First Post!

NobbZ

NobbZ

As a very blind guess, I’d say Poison receives a JSON document that is BOM’d and can’t deal with it. But as you say its working from dev, I’m wondering where this BOM would have been inserted…

Can you log and inspect the JSON you want to parse? Or please check if the first bytes in the response body are one of those in this table:

If so, a function like the following should be able to strip them:

Enum.each([<<239, 187, 191>>, <<254, 255>>, <<255, 254>>, …], fn bom ->
  def strip_bom(unquote(bom) <> rest), do: rest
end)
def strip_bom(binary) when is_binary(binary), do: binary

Of course you need to complete the list…

Also, if the body is encoded in the wrong format encoding, it might of course break due to that…

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement