Skip to content

Instantly share code, notes, and snippets.

View scratcher.md
  1. HTTP Client module
  defmodule Your.HttpClient do
    @behaviour Scratcher.HttpClient
    def request(method, url, body, headers, http_opts) do

      # use hackney, httpoison, httpotion...

 {:ok, %{status_code: 200, body: "..."}}
View HTTPClient_summary.md
iex(1)> Application.ensure_all_started(:hackney)
{:ok,
 [:unicode_util_compat, :idna, :mimerl, :certifi, :syntax_tools, :parse_trans,
  :ssl_verify_fun, :metrics, :hackney]}
  
iex(2)> :hackney.request(:get, "https://example.com", [], "", [:with_body])
{:ok, 200,
 [
   {"Accept-Ranges", "bytes"},
View elixir_jose_generarte_keys.md
iex(1)> JOSE.crypto_fallback(true)
:ok
iex(2)> JOSE.JWK.generate_key({:okp, :Ed25519})
%JOSE.JWK{
  fields: %{},
  keys: :undefined,
  kty: {:jose_jwk_kty_okp_ed25519,
   <<162, 30, 40, 233, 122, 159, 105, 49, 218, 101, 29, 205, 178, 236, 20, 132,
     14, 29, 119, 147, 44, 162, 49, 141, 96, 128, 117, 109, 21, 56, 64, 160, 4,
View same-site-cookie-tester.md
View how_to_use_state_parameter_for_oauth2.md

Application State

{
  "next_url":"/account/settings",
  ...
  "foo":"bar"
}
View chrome75_pin.md

ChromeのFIDO CTAP2 PIN support動作確認メモ

Chrome 75 Beta: low latency canvas contexts, sharing files, and numeric separators

Web Authentication API: FIDO CTAP2 PIN support
This feature extends Chrome's implementation of the Web Authentication API to support local user authorization of security key operations via a user-defined PIN for keys that implement the FIDO CTAP2 protocol. Web sites using web authentication can request or require such authorization via the API's user verification mechanisms.

Registration

@ritou
ritou / WebAuthnKit_vs_WebAuthnLite.md
Created Nov 24, 2018
Interop result with WebAuthnKit and WebAuthnLite
View WebAuthnKit_vs_WebAuthnLite.md

Interop result with WebAuthnKit and WebAuthnLite. parameters is from https://github.com/lyokato/WebAuthnKit/blob/develop/utils/interop/go_koesie10_webauthn/main.go

iex(1)> origin = "https://example.org"
"https://example.org"
iex(2)> challenge = "rtnHiVQ7"
"rtnHiVQ7"
iex(3)> encoded_registration_client_data_json = "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoicnRuSGlWUTciLCJvcmlnaW4iOiJodHRwczpcL1wvZXhhbXBsZS5vcmcifQ"
"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoicnRuSGlWUTciLCJvcmlnaW4iOiJodHRwczpcL1wvZXhhbXBsZS5vcmcifQ"
View jose_key_handling.md
# JOSE.JWK を用いて鍵を作成
iex(1)> jwk = JOSE.JWK.generate_key(:secp256r1)
%JOSE.JWK{
  fields: %{},
  keys: :undefined,
  kty: {:jose_jwk_kty_ec,
   {:ECPrivateKey, 1,
    <<37, 161, 110, 23, 211, 111, 64, 142, 98, 207, 153, 90, 139, 91, 212, 33,
@ritou
ritou / crypt_jwt_sample_jws_exXXX.pl
Created Nov 16, 2015
Crypt::JWTを用いてESXXXなJSON Web Signatureをごにょごにょするサンプル
View crypt_jwt_sample_jws_exXXX.pl
use Crypt::JWT qw(encode_jwt decode_jwt);
use Crypt::PK::ECC;
use MIME::Base64 qw(decode_base64url);
use Data::Dumper;
warn "=== Example JWS Using ECDSA P-256 SHA-256 ===\n";
warn "see https://tools.ietf.org/html/rfc7515#appendix-A.3\n";
warn "=== Private Key ===\n";
my $ec_jwk_data = {