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
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…
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








