{"id":23449569,"url":"https://github.com/apartmenttherapy/siftsciex_plug","last_synced_at":"2025-10-30T19:31:40.376Z","repository":{"id":57548027,"uuid":"139877982","full_name":"apartmenttherapy/siftsciex_plug","owner":"apartmenttherapy","description":"A Plug for processing Sift Science Web Hooks","archived":false,"fork":false,"pushed_at":"2018-08-21T16:33:21.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-23T23:29:59.188Z","etag":null,"topics":["elixir","elixir-plug","sift-science"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apartmenttherapy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-05T16:57:09.000Z","updated_at":"2018-08-21T16:33:18.000Z","dependencies_parsed_at":"2022-09-26T18:41:08.178Z","dependency_job_id":null,"html_url":"https://github.com/apartmenttherapy/siftsciex_plug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apartmenttherapy%2Fsiftsciex_plug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apartmenttherapy%2Fsiftsciex_plug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apartmenttherapy%2Fsiftsciex_plug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apartmenttherapy%2Fsiftsciex_plug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apartmenttherapy","download_url":"https://codeload.github.com/apartmenttherapy/siftsciex_plug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239041081,"owners_count":19572085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","elixir-plug","sift-science"],"created_at":"2024-12-23T23:27:52.136Z","updated_at":"2025-10-30T19:31:35.047Z","avatar_url":"https://github.com/apartmenttherapy.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Siftsciex Plug\n\nThe Siftsciex Plug provides a very small API and logic for helping process Sift Science Decisions.  If you need to handle a Decision Web Hook from Sift Science then you may find this useful.\n\nThe Decision Plug really does three things:\n\n1. Checks for the Sift Science Signature in the request\n2. Processes the body and transforms it into a `Siftsciex.Decision.t` struct\n3. Maps specific endpoints to specific handlers\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/siftsciex_plug), the package can be installed\nby adding `siftsciex_plug` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:siftsciex_plug, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Example\n\nThe first thing you need to do is configure the expected Signature key from Sift Science, as well as the header where the signature should be found:\n\n```elixir\n  config :siftsciex_plug,\n    hook_key: \u003csift_science_signature\u003e,\n    sig_header: \"x-sift-science-signature\"\n```\n\nThen you can configure the `Plug` to process and route specific paths for you.\n\n```elixir\n  alias Siftsciex.DecisionPlug\n\n  forward \"/sift_science\", DecisionPlug, %{\n    \"bad_user\" =\u003e {User, :sift_ban},\n    \"bad_listing\" =\u003e {Listing, :sift_delete}\n  }\n```\n\n## Note\n\nIf you are using any `Plug.Parsers` then you will need to make sure that `siftsciex_plug` checks the body before the parser consumes it.  To do this simply add the following to your Parser opts:\n\n```\n  body_reader: {Siftsciex.HookValidator, :validate, []}\n```\n\nIn the case of a `JSON` parser the full config would look something like this:\n\n```\nplug Plug.Parsers,\n    parsers: [:urlencoded, :multipart, :json],\n    pass: [\"*/*\"],\n    body_reader: {Siftsciex.HookValidator, :validate, []},\n    json_decoder: Poison\n```\n\nDoing this allows `siftsciex_plug` to calculate the signature against the raw body.\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/siftsciex_plug](https://hexdocs.pm/siftsciex_plug).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapartmenttherapy%2Fsiftsciex_plug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapartmenttherapy%2Fsiftsciex_plug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapartmenttherapy%2Fsiftsciex_plug/lists"}