All Projects → github → darrrr

github / darrrr

Licence: MIT license
An SDK for the delegated recovery specfication

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to darrrr

serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (+34.88%)
Mutual labels:  sinatra, ruby-on-rails
Koala
A lightweight Facebook library supporting the Graph, Marketing, and Atlas APIs, realtime updates, test users, and OAuth.
Stars: ✭ 3,506 (+8053.49%)
Mutual labels:  facebook, ruby-on-rails
FrameBot
An open source template to kickstart your own facebook framebot!
Stars: ✭ 89 (+106.98%)
Mutual labels:  facebook
cchecksapi
CRAN checks API
Stars: ✭ 34 (-20.93%)
Mutual labels:  sinatra
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+100%)
Mutual labels:  ruby-on-rails
FacebookTrackingRemoval
Browser extension that removes ads and the user interaction tracking from content on Facebook
Stars: ✭ 88 (+104.65%)
Mutual labels:  facebook
facebook-messenger
Go (GoLang) package for Facebook Messenger API and Chat bot
Stars: ✭ 62 (+44.19%)
Mutual labels:  facebook
facebook-bot-autoresponder
Facebook bot that automatically responds to the comments of a certain post
Stars: ✭ 90 (+109.3%)
Mutual labels:  facebook
hashtag.io
Hashtag.io is a PHP based social networking website, which supports exclusive multimedia content, sharing and private or group messaging service.
Stars: ✭ 64 (+48.84%)
Mutual labels:  facebook
logd.me
Your personal and friendly life log!
Stars: ✭ 16 (-62.79%)
Mutual labels:  facebook
Facebook-Auto-Liker
Simple, hacky python script which uses pyautogui to like images on FB.
Stars: ✭ 26 (-39.53%)
Mutual labels:  facebook
fb-messenger-bot-api
NodeJS Facebook Messenger API for bots to send messages and setup events to Facebook.
Stars: ✭ 29 (-32.56%)
Mutual labels:  facebook
facebook-video-downloader
Facebook Video Downloader Website Script written in PHP
Stars: ✭ 22 (-48.84%)
Mutual labels:  facebook
Instagram2Fedi
Python script for crossposting from Instagram to Mastodon or Pixelfed
Stars: ✭ 45 (+4.65%)
Mutual labels:  federation
AIRFacebook-ANE
Native extension for Adobe AIR providing cross-platform API to Facebook SDK 4
Stars: ✭ 19 (-55.81%)
Mutual labels:  facebook
bramble
The Movio GraphQL Gateway
Stars: ✭ 423 (+883.72%)
Mutual labels:  federation
chatter
Build a twitter clone in 10 mins with Rails, CableReady, and StimulusReflex
Stars: ✭ 50 (+16.28%)
Mutual labels:  ruby-on-rails
Skeleton
Skeleton is a Social Engineering tool attack switcher
Stars: ✭ 44 (+2.33%)
Mutual labels:  facebook
preact-rpc
React Pre-Rendering via RPC
Stars: ✭ 28 (-34.88%)
Mutual labels:  ruby-on-rails
new ckeditor
Ruby on Rails + CKEditor 5
Stars: ✭ 27 (-37.21%)
Mutual labels:  ruby-on-rails

Code Climate Build + Test

The Delegated Account Recovery Rigid Reusable Ruby (aka D.a.r.r.r.r. or "Darrrr") library is meant to be used as the fully-complete plumbing in your Rack application when implementing the Delegated Account Recovery specification. This library is currently used for the implementation at GitHub.

Along with a fully featured library, a proof of concept application is provided in this repo.

Configuration

An account provider (e.g. GitHub) is someone who stores a token with someone else (a recovery provider e.g. Facebook) in order to grant access to an account.

In config/initializers or any location that is run during application setup, add a file. NOTE: procs are valid values for countersign_pubkeys_secp256r1 and tokensign_pubkeys_secp256r1

Darrrr.authority = "http://localhost:9292"
Darrrr.privacy_policy = "#{Darrrr.authority}/articles/github-privacy-statement/"
Darrrr.icon_152px = "#{Darrrr.authority}/icon.png"

# See script/setup for instructions on how to generate keys
Darrrr::AccountProvider.configure do |config|
  config.signing_private_key = ENV["ACCOUNT_PROVIDER_PRIVATE_KEY"]
  config.symmetric_key = ENV["TOKEN_DATA_AES_KEY"]
  config.tokensign_pubkeys_secp256r1 = [ENV["ACCOUNT_PROVIDER_PUBLIC_KEY"]] || lambda { |provider, context| "you wouldn't do this in real life but procs are supported for this value" }
  config.save_token_return = "#{Darrrr.authority}/account-provider/save-token-return"
  config.recover_account_return = "#{Darrrr.authority}/account-provider/recover-account-return"
end

Darrrr::RecoveryProvider.configure do |config|
  config.signing_private_key = ENV["RECOVERY_PROVIDER_PRIVATE_KEY"]
  config.countersign_pubkeys_secp256r1 = [ENV["RECOVERY_PROVIDER_PUBLIC_KEY"]] || lambda { |provider, context| "you wouldn't do this in real life but procs are supported for this value" }
  config.token_max_size = 8192
  config.save_token = "#{Darrrr.authority}/recovery-provider/save-token"
  config.recover_account = "#{Darrrr.authority}/recovery-provider/recover-account"
end

The delegated recovery spec depends on publicly available endpoints serving standard configs. These responses can be cached but are not by default. To configure your cache store, provide the reference:

Darrrr.cache = Dalli::Client.new('localhost:11211', options)

The spec disallows http URIs for basic security, but sometimes we don't have this setup locally.

Darrrr.allow_unsafe_urls = true

Provider registration

In order to allow a site to act as a provider, it must be "registered" on boot to prevent unauthorized providers from managing tokens.

# Only configure this if you are acting as a recovery provider
Darrrr.register_account_provider("https://github.com")

# Only configure this if you are acting as an account provider
Darrrr.register_recovery_provider("https://www.facebook.com")

Custom crypto

Create a module that responds to Module.sign, Module.verify, Module.decrypt, and Module.encrypt. You can use the template below. I recommend leaving the #verify method as is unless you have a compelling reason to override it.

Global config

Set Darrrr.this_account_provider.custom_encryptor = MyCustomEncryptor Set Darrrr.this_recovery_provider.custom_encryptor = MyCustomEncryptor

On-demand

Darrrr.with_encryptor(MyCustomEncryptor) do
  # perform DAR actions using MyCustomEncryptor as the crypto provider
  recovery_token, sealed_token = Darrrr.this_account_provider.generate_recovery_token(data: "foo", audience: recovery_provider, context: { user: current_user })
end
module MyCustomEncryptor
  class << self
    # Encrypts the data in an opaque way
    #
    # data: the secret to be encrypted
    #
    # returns a byte array representation of the data
    def encrypt(data)

    end

    # Decrypts the data
    #
    # ciphertext: the byte array to be decrypted
    #
    # returns a string
    def decrypt(ciphertext)

    end

    # payload: binary serialized recovery token (to_binary_s).
    #
    # key: the private EC key used to sign the token
    #
    # returns signature in ASN.1 DER r + s sequence
    def sign(payload, key)

    end

    # payload: token in binary form
    # signature: signature of the binary token
    # key: the EC public key used to verify the signature
    #
    # returns true if signature validates the payload
    def verify(payload, signature, key)
      # typically, the default verify function should be used to ensure compatibility
      Darrrr::DefaultEncryptor.verify(payload, signature, key)
    end
  end
end

Example implementation

I strongly suggest you read the specification, specifically section 3.1 (save-token) and 3.5 (recover account) as they contain the most dangerous operations.

NOTE: this is NOT meant to be a complete implementation, it is just the starting point. Crucial aspects such as authentication, audit logging, out of band notifications, and account provider persistence are not implemented.

Specifically, the gem exposes the following APIs for manipulating tokens.

Development

Local development assumes a Mac OS environment with homebrew available. Postgres and phantom JS will be installed.

Run ./script/bootstrap then run ./script/server

  • Visit http://localhost:9292/account-provider
  • You'll see some debug information on the page.
    • Click "setup recovery".
  • If recovery setup was successful, click "Recovery Setup Successful"
  • Click the "recover now?" link
  • You'll see an intermediate page, where more debug information is presented. Click "recover token"
  • You should be sent back to your host
    • And see something like Recovered data: <the secret from step 1>

Tests

Run ./script/test to run all tests.

Deploying to heroku

Use heroku config:set to set the environment variables listed in script/setup. Additionally, run:

heroku config:set HOST_URL=$(heroku info -s | grep web_url | cut -d= -f2)

Push your app to heroku:

git push heroku <branch-name>:master

Migrate the database:

heroku run rake db:migrate

Use the app!

heroku restart
heroku open

Roadmap

  • Add support for token-status endpoints as defined by the spec
  • Add async API as defined by the spec
  • Implement token binding as part of the async API

Don't want to run ./script entries?

See script/setup for the environment variables that need to be set.

Contributions

See CONTRIBUTING.md

License

darrrr is licensed under the MIT license.

The MIT license grant is not for GitHub's trademarks, which include the logo designs. GitHub reserves all trademark and copyright rights in and to all GitHub trademarks. GitHub's logos include, for instance, the stylized designs that include "logo" in the file title in the following folder: logos.

GitHub® and its stylized versions and the Invertocat mark are GitHub's Trademarks or registered Trademarks. When using GitHub's logos, be sure to follow the GitHub logo guidelines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].