Skip to content

Instantly share code, notes, and snippets.

View nov's full-sized avatar

Nov Matake nov

View GitHub Profile
@nov
nov / authorization_request_sample.rb
Created March 9, 2011 15:30
Rack::OAuth2::Client Sample - Authorization Request
require 'rubygems'
require 'rack/oauth2'
client = Rack::OAuth2::Client.new(
:identifier => YOUR_CLIENT_ID,
:secret => YOUR_CLIENT_SECRET,
:redirect_uri => YOUR_REDIRECT_URI, # only required for grant_type = :code
:host => 'rack-oauth2-sample.heroku.com'
)
@nov
nov / globalsign_root_cert_latest.rb
Last active October 16, 2023 23:47
GlobalSign Root Certificate (latest)
require 'openssl'
root_cert = <<-CERT
-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
require 'apple_id'
# NOTE: in debugging mode, you can see all HTTPS request & response in the log.
# AppleID.debug!
pem = <<-PEM
-----BEGIN PRIVATE KEY-----
:
:
-----END PRIVATE KEY-----
@nov
nov / resource_request_sample.rb
Created March 23, 2011 17:49
Rack::OAuth2::Client Sample - Resource Request (Bearer)
require 'rubygems'
require 'rack/oauth2'
def url_for(path)
File.join("http://rack-oauth2-sample.heroku.com", path)
end
resource_of = :user
case resource_of
fs = require 'fs'
util = require 'util'
url = require 'url'
ws = require 'ws'
redis = require 'redis'
Sequelize = require 'sequelize'
restler = require 'restler'
# Config
@nov
nov / mtls-policy.xml
Last active November 23, 2020 10:42
Azure API Management Policy for MTLS
<policies>
<inbound>
<base />
<!-- TODO: limit by client_id, not token itself -->
<rate-limit-by-key calls="30" renewal-period="10" counter-key="@(context.Request.Headers.GetValueOrDefault("Authorization",""))" />
<choose>
<when condition="@(context.Request.Certificate != null && context.Request.Certificate.NotAfter > DateTime.Now)">
<set-header name="Client-Certificate" exists-action="override">
<value>@(context.Request.Certificate.GetRawCertDataString())</value>
</set-header>
@nov
nov / docomo_kouza_kyc.rb
Last active September 30, 2020 02:53
ドコモ口座 KYC is..
identity_x = proof_identity(entity_x)
proofed_bank_identity = identity_x
proofed_payment_identity = bank_identity
if assume_entity(proofed_payment_identity) == assume_entity(proofed_bank_identity)
:OK
else
:NG
@nov
nov / ENExposureConfiguration.json
Last active July 2, 2020 16:18
Covid-19Radar/Covid19Radar の ENExposureConfiguration (2020.06.21)
{
"MinimumRiskScore": 1,
"AttenuationWeight": 50,
"TransmissionWeight": 50,
"DurationWeight": 50,
"DaysSinceLastExposureWeight": 50,
"TransmissionRiskScores": [1, 2, 3, 4, 5, 6, 7, 8],
"AttenuationScores": [1, 2, 3, 4, 5, 6, 7, 8],
"DurationScores": [1, 2, 3, 4, 5, 6, 7, 8],
"DaysSinceLastExposureScores": [1, 2, 3, 4, 5, 6, 7, 8],

Choice of DynReg, PKCE and/or DPoP

Code Access Token Refresh Token Choice
Bearer Bearer Bearer Nothing to use
Bearer Bearer Sender-Constrained DPoP (in bearer access token mode)
Bearer Sender-Constrained Bearer Impossible
Bearer Sender-Constrained Sender-Constrained DPoP
Sender-Constrained Bearer Bearer PKCE only
Sender-Constrained Sender-Constrained Bearer Impossible
require 'rack/oauth2'
Rack::OAuth2.debug!
client = Rack::OAuth2::Client.new(
identifier: 'YOUR_CLIENT_ID',
secret: 'YOUR_CLIENT_SECRET',
redirect_uri: 'YOUR_REDIRECT_URI',
authorization_endpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
token_endpoint: 'https://oauth2.googleapis.com/token'