README.md in gds-sso-9.3.0 vs README.md in gds-sso-9.4.0

- old
+ new

@@ -15,11 +15,11 @@ To use gds-sso you will need an oauth client ID and secret for signonotron2 or a compatible system. These can be provided by one of the team with admin access to signonotron2. Then include the gem in your Gemfile: - gem 'gds-sso', :git => 'https://github.com/alphagov/gds-sso.git' + gem 'gds-sso', '<version>' Create a `config/initializers/gds-sso.rb` that looks like: GDS::SSO.config do |config| config.user_model = 'User' @@ -30,28 +30,37 @@ # optional config for location of signonotron2 config.oauth_root_url = "http://localhost:3001" end -The user model must include the GDS::SSO::User module. +The user model must include the `GDS::SSO::User` module. It should have the following fields: string "name" string "email" string "uid" string "organisation_slug" array "permissions" boolean "remotely_signed_out", :default => false -You also need to include `GDS::SSO::ControllerMethods` in your ApplicationController +You also need to include `GDS::SSO::ControllerMethods` in your ApplicationController. For ActiveRecord, you probably want to declare permissions as "serialized" like this: serialize :permissions, Array +If your app is using `rspec`, there is a [shared examples spec](/lib/gds-sso/lint/user_spec.rb) that can be used to verify that your `User` model implements the necessary methods for `gds-sso` to work correctly. To use it: +```ruby +require 'gds-sso/lint/user_spec' + +describe User do + it_behaves_like "a gds-sso user class" +end +``` + ## Use in development mode In development, you generally want to be able to run an application without needing to run your own SSO server to be running as well. GDS-SSO facilitates this by using a 'mock' mode in development. Mock mode loads an arbitrary user from the local application's user tables: GDS::SSO.test_user || GDS::SSO::Config.user_klass.first @@ -60,7 +69,6 @@ bundle exec ./script/make_oauth_work_in_dev Once that's done, set an environment variable when you run your app. e.g.: - GDS_SSO_STRATEGY=real bundle exec rails s - + GDS_SSO_STRATEGY=real bundle exec rails s