Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:33:03+00:00 2026-05-26T16:33:03+00:00

I am trying to split my current Ruby on Rails 3 web-application and it’s

  • 0

I am trying to split my current Ruby on Rails 3 web-application and it’s web-services (API). My web-application is running on Heroku and implements API as a namespaced route within my application. For example /events returns a HTML page and /api/v1/events returns a JSON data.

According to some best practices, I want to split those into two different applications. I have chosen Sinatra to implement the API application. It works now for simple requests where authentication is not required.

My Ruby on Rails 3 application is using Devise to authenticate users. There’s also ability to login with Facebook account. Now what I want to achieve, is HTTP Basic Authentication of users (including registration) through my Sinatra-based API by using Warden.

What is the best way to do that? Or maybe I can use something different then Warden?

Keep in mind that I am not very familiar with Rack 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:33:04+00:00Added an answer on May 26, 2026 at 4:33 pm

    I was able to get it working. There were a few main aspects:

    • Get Devise working with Rails (Devise is a Rails app, won’t work
      without it)
    • Setup the mapping (route) on Rack level to support both Rails and Sinatra
    • Share the sessions between Rails and Sinatra
    • Setup Warden and make it available to Sinatra

    Here is most relevant part of code from /config.ru:

        #
    
        # ...
    
        # Rest with Rails
        map "/" do
          run MyApp::Application
        end
    
        # Anything urls starting with /slim will go to Sinatra
        map "/slim" do
    
          # make sure :key and :secret be in-sync with initializers/secret_store.rb initializers/secret_token.rb
          use Rack::Session::Cookie, :key => '<< see, initializers/secret_store.rb >>', :secret => '<< copy from initializers/secret_token.rb >>'
    
          # Point Warden to the Sinatra App
          use Warden::Manager do |manager|
            manager.failure_app = AppMain
            manager.default_scope = Devise.default_scope
          end
    
          # Borrowed from https://gist.github.com/217362
          Warden::Manager.before_failure do |env, opts|
            env['REQUEST_METHOD'] = "POST"
          end
    
          run AppMain
        end
    

    See, http://labnote.beedesk.com/sinatra-warden-rails-devise for a complete solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to split up a web site into two sections. One which should
Using Ruby I'm trying to split the following text with a Regex ~foo\~\=bar =cheese~monkey
I'm trying to make an experimental web application which minimises redundant data. I have
I'm trying to implement a RESTful API in Perl. My current idea is to
Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I'm trying to split a string up into words and punctuation, adding the punctuation
I'm trying to split an app.config file into multiple files to make it easier
I'm trying to split a string on its punctuation, but the string may contain
I am trying to split a string in Javascript using a Regular Expression. My
I'm trying to split a string into a int list for further processing. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.