# Add StrongMind Identity to a Rails app 1. Create a fresh rails app. ex: rails new my-app --css tailwind 1. Add this to Gemfile: ```ruby gem "strongmind-platform-sdk" gem 'dotenv-rails', groups: [:development, :test] # for environment variables when running locally gem 'devise' gem 'omniauth_openid_connect' gem 'omniauth-rails_csrf_protection' ``` 1. Run `bundle install` 1. Run the generator: `rails g strong_mind_rails_identity:install` 1. Remove the first devise line with the default devise plugins from `app/models/user.rb`. You should end up with the only devise line being the following: ```ruby devise :omniauthable, omniauth_providers: [:strongmind] ``` 1. Create a client in the Identity Server and add the following to the .env file: ``` IDENTITY_CLIENT_ID= IDENTITY_CLIENT_SECRET= IDENTITY_BASE_URL= APP_BASE_URL= ``` 1. For local development, run this to enable caching: ``` rails dev:cache ``` This will create a file `tmp/caching-dev.txt` that you can delete to disable caching. 1. If you want user sessions to persist across restarts of your server in dev, and you aren't using redis in dev, add this to `config/environments/development.rb` (instead of `:memory_store`): ``` config.cache_store = :file_store, "#{Rails.root}/tmp/cache/" ``` 1. Do you want all pages to require authentication? - If yes, add this to `app/controllers/application_controller.rb` right under the class declaration: ```ruby before_action :authenticate_user! ``` - If no, remove line 2 of `app/controllers/strong_mind_auto_login_controller.rb` and add the above line only to controllers that should require authentication. 1. Execute `bin/rails db:migrate RAILS_ENV=development` 1. Start the server: `rails s`