New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

omniauth-practicefusion

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

omniauth-practicefusion

  • 2.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Omniauth::PracticeFusion

OAuth 2 strategy for Practice Fusion. Redundant description :\

Installation

Add this line to your application's Gemfile:

source 'http://gems.hq.practicefusion.com'
gem 'omniauth-practicefusion' 

And then execute:

$ bundle

Usage

This works with Devise and Omniauth. Get an App ID and Secret from Ken. Give him your callback URL (/users/auth/practicefusion/callback).

Configuration

Rails.application.config.middleware.use OmniAuth::Builder do
  provider OmniAuth::Strategies::PracticeFusion, ENV['PF_OAUTH_CLIENT_ID'], ENV['PF_OAUTH_CLIENT_SECRET'], {
      scope: ENV['PF_OAUTH_SCOPE'],
      path_prefix: '/providers/auth',
      client_options: {
        site: ENV['PF_OAUTH_SITE_URL'],
      }
  }
end

Sample Hash

{
       "provider" => "practicefusion",
            "uid" => "3cbbbd62-159d-4c40-be4c-2cdf784d6c7d",
           "info" => {
                "title" => "Dr",
           "first_name" => "Sam",
            "last_name" => "Withnoname",
        "practice_guid" => "9571286c-c379-4053-9fa3-04caeb62fb69",
                "email" => "sam@dev.practicefusion.com"
    },
    "credentials" => {
                "token" => "3hvHj7PyVFH9TGyDFXaq",
        "refresh_token" => "VqycQpxuBS5tjP_Kaab-",
           "expires_at" => 1412279343,
              "expires" => true
    },
          "extra" => {
        "raw_info" => {
                        "title" => "Dr",
                    "firstName" => "Sam",
                     "lastName" => "Withnoname",
                 "practiceGuid" => "9571286c-c379-4053-9fa3-04caeb62fb69",
                  "ehrUserGuid" => "3cbbbd62-159d-4c40-be4c-2cdf784d6c7d",
            "loginEmailAddress" => "sam@dev.practicefusion.com"
        }
    }
}

Devise

First define your application id and secret in "config/initializers/devise.rb" your scope maybe different. TODO add all available scopes.

config.omniauth :practicefusion, ENV['PF_APP_ID'], ENV['PF_APP_SECRET'], {
                                                                                      scope: 'user:r_basic',
                                                                                      response_type: 'code'
                                                                                  }

Then add the following to 'config/routes.rb' so the callback routes are defined.

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

f Devise default callback URL is '/users/auth/practicefusion/callback' with the above route.

Make sure your model is omniauthable. Generally this is "/app/models/user.rb"

devise :omniauthable, :omniauth_providers => [:practicefusion]

Then make sure your callbacks controller is setup.

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def practicefusion
        @user = User.find_for_practicefusion(request.env['omniauth.auth'], current_user)
    
        if @user.persisted?
          sign_in_and_redirect @user, event: :authentication
        else
          redirect_to new_user_registration_url
        end     
  end
end

and bind to or create the user

def self.find_for_practicefusion(access_token, signed_in_resource = nil)
    user = User.where(ehr_user_guid: access_token['uid']).first
      unless user
        user = User.create(name: access_token['info']['first_name'] + ' ' + access_token['info']['last_name'], ehr_user_guid: access_token['uid'], email: access_token['info']['email'], password: Devise.friendly_token[0,20])
      end
    user
end

For your views you can login using:

<%= link_to "Sign in with Practice Fusion", user_omniauth_authorize_path(:practicefusion) %>

Contributing

YES PLEASE LIKE SPECS

FAQs

Package last updated on 29 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc