diff --git a/articles/server-apis/rails.md b/articles/server-apis/rails.md index 49ecaf47c3..a42eb51a0a 100644 --- a/articles/server-apis/rails.md +++ b/articles/server-apis/rails.md @@ -45,12 +45,14 @@ Add this line to your application's Gemfile: ${snippet(meta.snippets.dependencies)} And then execute: - - $ bundle install +``` +bundle install +``` Finally, run the install generator: - - $ rails generate knock:install +``` +rails generate knock:install +``` It will create the following initializer `config/initializers/knock.rb`. This file contains all the informations about the existing configuration options. @@ -117,9 +119,21 @@ config.token_audience = -> { Rails.application.secrets.auth0_client_id } ``` ```ruby -config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret } +require 'base64' + +# extracted from original [method](http://www.rubydoc.info/github/jwt/ruby-jwt/JWT.base64url_decode) +config.token_secret_signature_key = -> { + secret = Rails.application.secrets.auth0_client_secret + secret += '=' * (4 - secret.length.modulo(4)) + Base64.decode64(secret.tr('-_', '+/')) + } ``` ### 4. You're done! Now you have both your FrontEnd and Backend configured to use Auth0. Congrats, you're awesome! + +### Optional Steps +#### Configure CORS + +In order to configure CORS, install [rack-cors](https://github.com/cyu/rack-cors) gem and follow [this](https://github.com/cyu/rack-cors#rails) instructions. \ No newline at end of file diff --git a/snippets/server-apis/rails/dependencies.md b/snippets/server-apis/rails/dependencies.md index 6233f40a66..ba3d2f24e6 100644 --- a/snippets/server-apis/rails/dependencies.md +++ b/snippets/server-apis/rails/dependencies.md @@ -1,3 +1,3 @@ ```ruby -gem 'knock', '~> 1.2' +gem 'knock', '~> 1.4.2' ``` diff --git a/snippets/server-apis/rails/setup.md b/snippets/server-apis/rails/setup.md index 64b1fffe37..b7e7591c9a 100644 --- a/snippets/server-apis/rails/setup.md +++ b/snippets/server-apis/rails/setup.md @@ -1,5 +1,5 @@ ```ruby -class ApplicationController < ActionController::API +class ApplicationController < ActionController::Base include Knock::Authenticable end ```