I hereby claim:
- I am AndrewDryga on github.
- I am andrewdryga (https://keybase.io/andrewdryga) on keybase.
- I have a public key whose fingerprint is A3B3 6F4D 56EC DF44 70A2 1C11 73B7 DDE1 A8AC 23B9
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
defmodule OpenIDConnect do | |
@moduledoc """ | |
Handles a majority of the life-cycle concerns with [OpenID Connect](http://openid.net/connect/) | |
""" | |
alias OpenIDConnect.Document | |
@typedoc """ | |
URL to a [OpenID Discovery Document](https://openid.net/specs/openid-connect-discovery-1_0.html) endpoint. | |
""" | |
@type discovery_document_uri :: String.t() |
defmodule Firezone.OpenAPIDocsWriter do | |
@keep_req_headers [] | |
@keep_resp_headers ["content-type", "location"] | |
def write(conns, path) do | |
file = File.open!(path, [:write, :utf8]) | |
open_api_spec = %{ | |
openapi: "3.0.0", | |
info: %{ |
defmodule MyApp.Config do | |
@moduledoc """ | |
This module provides set of helper functions that are useful when reading application runtime configuration overrides | |
in test environment. | |
""" | |
if Mix.env() != :test do | |
def maybe_put_env_override(_key, _value), do: :ok | |
def fetch_env!(app, key), do: Application.fetch_env!(app, key) | |
else |
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Dial> | |
<Number>+15671112233</Number> | |
<Number>+15671112234</Number> | |
</Dial> | |
</Response> |
defmodule DynamicChangeset do | |
@moduledoc """ | |
This module provides helper functions to extend `Ecto.Changeset` to support | |
dynamic embeds. | |
""" | |
alias Ecto.Changeset | |
@doc """ | |
Casts the given embed with the embedded changeset and field which is used to define it's type. |
app_secret = Keyword.fetch!(config, :app_secret) | |
with [encoded_signature, encoded_payload] <- String.split(signed_request, "."), | |
{:ok, signature} <- Base.url_decode64(encoded_signature, padding: false), | |
{:ok, payload} <- Base.url_decode64(encoded_payload, padding: false), | |
{:ok, payload} <- Jason.decode(payload), | |
%{"algorithm" => "HMAC-SHA256"} <- payload, | |
payload_signature = :crypto.hmac(:sha256, app_secret, encoded_payload), | |
true <- Plug.Crypto.secure_compare(signature, payload_signature) do | |
{:ok, payload} | |
else |
def book_trip(attrs) do | |
with {:ok, exchange_rates} <- BillingAPI.fetch_currency_exchange_rates(attrs), | |
{:ok, card_authorization} <- BillingAPI.authorize_card(exchange_rates, attrs), | |
{:hotel_booking, {:ok, hotel_booking}, _} <- {:hotel_booking, HotelsBookingAPI.book_hotel(attrs), []}, | |
{:car_booking, {:ok, car_booking}, _} <- {:car_booking, CarsBookingAPI.book_hotel(attrs), [hotel_booking]}, | |
{:flight_booking, {:ok, flight_booking}, _} <- {:flight_booking, FlightsBookingAPI.book_hotel(attrs), [hotel_booking, car_booking]}, | |
:ok <- Mailer.send_email_confirmation(card_authorization, hotel_booking, attrs), | |
{:charge, {:ok, charge}, _} <- {:charge, BillingAPI.charge_card(card_authorization), [...]} do | |
{:ok, %{charge: charge, bookings: [hotel_booking, car_booking, flight_booking]}} | |
else |
def book_trip(attrs) do | |
with {:ok, exchange_rates} <- BillingAPI.fetch_currency_exchange_rates(attrs), | |
{:ok, card_authorization} <- BillingAPI.authorize_card(exchange_rates, attrs), | |
{:booking, {:ok, hotel_booking}, _} <- {:booking, HotelsBookingAPI.book_hotel(attrs), []}, | |
{:booking, {:ok, car_booking}, _} <- {:booking, CarsBookingAPI.book_hotel(attrs), [hotel_booking]}, | |
{:booking, {:ok, flight_booking}, _} <- {:booking, FlightsBookingAPI.book_hotel(attrs), [hotel_booking, car_booking]}, | |
:ok <- Mailer.send_email_confirmation(card_authorization, hotel_booking, attrs), | |
{:charge, {:ok, charge}, _} <- {:charge, BillingAPI.charge_card(card_authorization), [...]} do | |
{:ok, %{charge: charge, bookings: [hotel_booking, car_booking, flight_booking]}} | |
else |
def book_trip(attrs) do | |
with {:ok, exchange_rates} <- BillingAPI.fetch_currency_exchange_rates(attrs), | |
{:ok, card_authorization} <- BillingAPI.authorize_card(exchange_rates, attrs), | |
{:ok, hotel_booking} <- HotelsBookingAPI.book_hotel(attrs), | |
:ok <- Mailer.send_email_confirmation(card_authorization, hotel_booking, attrs), | |
{:charge, {:ok, charge}, _} <- {:charge, BillingAPI.charge_card(card_authorization), [hotel_booking]} do | |
{:ok, %{charge: charge, bookings: [hotel_booking]}} | |
else | |
{:charge, {:error, reason], [hotel_booking]} -> | |
:ok = send_excuse_email(authorization) |