GithubHelp home page GithubHelp logo

todddickerson / clickfunnels_auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from etison/clickfunnels_auth

0.0 0.0 0.0 88 KB

A small Ruby gem that allows a Rails app to become an OAuth client of the Clickfunnels mothership

License: MIT License

Ruby 85.89% Gherkin 0.89% JavaScript 1.33% CSS 1.21% HTML 10.67%

clickfunnels_auth's Introduction

ClickfunnelsAuth

A Rails engine that makes it easy to delegate authentication for a Rails site to Clickfunnels Login. See the test app for an example of using this gem.

This is based on the SoAuth projects. See http://www.octolabs.com/so-auth for more details.

Usage

Add clickfunnels_auth to the Gemfile

gem 'clickfunnels_auth'

Generate an initializer

Run this command

rails generate clickfunnels_auth:install

This will create the following files

config/initializers/omniauth.rb

Create a new application in your main Clickfunnels mothership instance

Go to the /oauth/applications endpoint on the Clickfunnels installation that you want to integrate with. For development this will probably be http://localhost:5000/oauth/applications.

Create a new application, and set the callback URL to http://localhost:3001/auth/clickfunnels/callback. Change the port if you plan to run your client app on a different port. (See the optional section below.)

After creating the app make note of the Application Id and the Secret.

Set some environment variables for your client

In your new client project (where you installed this gem), you should set some environment variables. Using something like foreman is probably the best so that you can just set them in a .env file.

AUTH_PROVIDER_URL=http://localhost:5000
AUTH_PROVIDER_APPLICATION_ID=1234
AUTH_PROVIDER_SECRET=5678
AUTH_PROVIDER_ME_URL=/api/me.json

Be sure to use the Application Id you got in the last step as AUTH_PROVIDER_APPLICATION_ID and the Secret as AUTH_PROVIDER_SECRET.

Create a User model

If you haven't already done it, you should create a User model

rails generate model user email:string

Then be sure to run migrations.

rake db:migrate; rake db:test:prepare

Modify your User model

Add this line:

include ClickfunnelsAuth::UserHelper

Generate migrations from this addon

rails clickfunnels_auth_engine:install:migrations

Then run migrations.

rake db:migrate; rake db:test:prepare

Protect some stuff in a controller

Include the helper and then use a before_action to protect some controller actions.

include ClickfunnelsAuth::ControllerHelper
before_action :login_required

OPTIONAL : Change the default port of your new project

Since we're relying on clickfunnels_auth_provider to provide authentication, we need to run our new project on a different port in development. Open up config/boot.rb and add this to the bottom of the file. If you want to use a port other than 3001 just change the port as appropriate.

# Setting default port to 3001
require 'rails/commands/server'
module Rails
  class Server
    alias :default_options_alias :default_options
    def default_options
      default_options_alias.merge!(:Port => 3001)
    end
  end
end

Or you could just run your development server on a different port:

rails s -p 3001

or

unicorn -p 3001 -c ./config/unicorn.rb

or whatever.

This project rocks and uses MIT-LICENSE.

clickfunnels_auth's People

Contributors

jagthedrummer avatar ngpestelos avatar todddickerson 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.