Git Product home page Git Product logo

omniauth-dnsimple's Introduction

Omniauth::Dnsimple

DNSimple strategy for OmniAuth.

Installation

Add this line to your application's Gemfile:

gem 'omniauth-dnsimple'

And then execute:

$ bundle

Or install it yourself as:

$ gem install omniauth-dnsimple

Usage

You need to create a DNSimple application. The application has a client id and client secret.

Use DNSimple strategy with OmniAuth::Builder in your Rack middleware stack.

use OmniAuth::Builder do
  provider :dnsimple, ENV['DNSIMPLE_CLIENT_ID'], ENV['DNSIMPLE_CLIENT_SECRET']
end

Sandbox

If we pass sandbox: true, the strategy will use the DNSimple sandbox environment.

use OmniAuth::Builder do
  provider :dnsimple, ENV['DNSIMPLE_CLIENT_ID'], ENV['DNSIMPLE_CLIENT_SECRET'],
           sandbox: ENV['DNSIMPLE_SANDBOX']
end

Testing

If you want to test DNSimple authentication with RSpec, here's how you can do it:

require "omniauth/dnsimple/rspec"

RSpec.feature "Login" do
  scenario "with success" do
    #
    # This method is provided by omniauth-dnsimple.
    # It mocks OmniAuth and it provides a successful signup
    #
    data = omniauth_successful_signup 

    puts data.class
      # => OmniAuth::AuthHash

    puts data.dig('credentials', 'token')
      # => "421bb40ff4656c7077ecf9a6ac441f30b62b9749f6bce190013df201e61125f8"
    puts data.dig('info', 'email')
      # => "[email protected]"
    puts data.dig('info', 'plan_identifier')
      # => "dnsimple-professional"
    puts data.dig('info', 'type')
      # => "account"

    puts data.dig('provider')
      # => "dnsimple"
    puts data.dig('uid') # DNSimple Account ID
      # => 2882493

    visit "/auth/dnsimple"

    # ...
  end

  scenario "without success" do
    #
    # This method is provided by omniauth-dnsimple.
    # It mocks OmniAuth and it provides a failing signup
    #
    omniauth_failing_signup

    visit "/auth/dnsimple"

    # ...
  end
end

Development

Clone the repository and install the dependencies:

git clone https://github.com/dnsimple/omniauth-dnsimple.git
cd omniauth-dnsimple
bundle

Run the tests with:

bundle exec rake

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dnsimple/omniauth-dnsimple.

omniauth-dnsimple's People

Contributors

jodosha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.