This gem provides a wrapper around omniauth and omniauth-openid-connect for handling authentication against NFG's OpenID identity server.
gem nfg_openidbundle- Mount the engine in your routes:
mount SsoOpenid::Engine => "/"
- Add a
self.from_omniauth(omniauth_data, subdomain, ip_address)method to to handle user lookup and/or creation. - Optionally, you can add an instance method called
#restrict_access?to encapsulate any necessary role-based evaluation. - If the admin record has a 'status' field, authentication will fail if it is set to anything other than 'active'.
- The gem will expect the admins table to have a 'uid' field. The uid from the identity server should be stored in this field.
- Make sure you include
SsoOpenid::ApplicationHelper. - Add a method called
sso_openid_after_sign_in_path. This method should return the path to which signed in users should be redirected. - Add a method called
sso_openid_after_sign_out_path. This method should return the path to which users should be redirected after signing out. - Add a method called
sso_openid_failure_path. This is the path to where the user will be redirected upon any failure. - Add
before_filter authenticate_admin!. Be sure to exclude this filter where necessary, such as in controller that handle the display of error messages to non-logged in users.
#authenticate_admin!should run before each request to verify that a logged in admin exists. Otherwise, it will redirect to the auth path.#current_adminreturns the logged in admin.#sign_in(admin)will sign in an admin by creating the admin_uid cookie.#sign_outwill remove the cookie and redirect to the root path.#stored_locationwill return any path that the admin attempts to access before signing in.