Questions tagged [warden]

Warden is a Rack-based middleware, designed to provide a mechanism for authentication in Ruby web applications. It is a common mechanism that fits into the Rack Machinery to offer powerful options for authentication. Warden is designed to be lazy. That is, if you don’t use it, it doesn’t do anything, but when you do use it, it will spring into action and provide an underlying mechanism to allow authentication in any Rack-based application.

Warden is a Rack-based middleware, designed to provide a mechanism for authentication in Ruby web applications. It is a common mechanism that fits into the Rack Machinery to offer powerful options for authentication.

Warden is designed to be lazy. That is, if you don’t use it, it doesn’t do anything, but when you do use it, it will spring into action and provide an underlying mechanism to allow authentication in any Rack-based application.

248 questions
52
votes
3 answers

Why is my RSpec not loading Devise::Test::ControllerHelpers?

I'm using Rails 5, and Devise 3.5.1. Going through a nice (older) book about creating/testing an API, which uses Devise authentication. It was written before Rails 5, so I chose not to use the new api-only version. Here's my…
dwilbank
  • 2,470
  • 2
  • 26
  • 37
38
votes
5 answers

How do I login a user with devise?

I have my rails application and I am running into a major issue with devise. I have a controller: class Users::SessionsController < Devise::SessionsController prepend_before_filter :require_no_authentication, :only => [ :new, :create ] include…
Matt Elhotiby
  • 43,028
  • 85
  • 218
  • 321
30
votes
5 answers

Redirect to log in page if user is not authenticated with Devise

I'm using Devise with Ruby on Rails. What is the recommended way to redirect unauthenticated users to the sessions#new page if they attempt to access a page that requires authentication? Right now I get an error that says no route matches the one…
Gdeglin
  • 12,432
  • 5
  • 49
  • 65
29
votes
1 answer

What is the warden data in a Rails/Devise session composed of?

The "data" in a Rails session looks like this: {"warden.user.user.key" => [[1], "long-random-string"]} 1 is the user id. What is the long random string? Is this something handled/used by Rails, or Devise?
John Bachir
  • 22,495
  • 29
  • 154
  • 227
23
votes
2 answers

uncaught throw :warden in Devise Testing

I have just begun with testing Devise. I am unable to understand of why i am getting this error :: Failure/Error: subject.current_user.should_not be_nil ArgumentError: uncaught throw :warden This is the code in my spec :: require…
Kaushik Thirthappa
  • 1,041
  • 2
  • 9
  • 21
22
votes
1 answer

Where should warden callbacks be placed in a rails app?

I'm relatively new to rails. I have Devise set up, and want to run some callback code after users sign in. Looking at the Warden wiki page, I can use the "after_set_user" callback to perform this logic, for example: Warden::Manager.after_set_user do…
Adrian Macneil
  • 13,017
  • 5
  • 57
  • 70
21
votes
2 answers

Configuring Warden for use in RSpec controller specs

I was able to use Devise's sign_in method to log in a user in my controller specs. But now that I'm removing Devise from my application, I'm not quite sure how to get similar functionality working with just Warden on its own. How should I go about…
Chris Peters
  • 17,918
  • 6
  • 49
  • 65
13
votes
2 answers

What is last_sign_in_at used for in Devise?

A standard User column in Devise is last_sign_in_at, which holds the previous value of current_sign_in_at when current_sign_in_at is updated. Does last_sign_in_at have any utility for Devise's core functionality or Module functionality, or is it…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
13
votes
4 answers

Ruby on Rails Devise code after login

I have an RoR app using Devise for logins. There is some code that is executed when a new User record is created, by being put in the user.rb file as an after_create call/macro/whatever. I need to make this code run after each login, instead of…
whognu
  • 439
  • 1
  • 5
  • 15
13
votes
2 answers

RSpec, authenticating Devise user in request specs

I'm trying to write RSpec request specs in order to test my service API and for that I need the user to be authenticated. I found some examples on the net but nothing works, for the moment I'm stuck with this: require "spec_helper" include…
a.s.t.r.o
  • 3,261
  • 5
  • 34
  • 41
12
votes
1 answer

Devise - Sign In with Ajax

Is here any possibility to modify devise SessionsController for ajax communication? Edit I found the solution, and posted it into answers, thanks
jmeinlschmidt
  • 1,446
  • 2
  • 14
  • 33
12
votes
4 answers

Prevent session creation on rails 3.2.2 for RESTful api

How can i prevent the session store from creating a session on JSON/XML calls ? My problem is that i save sessions in a database and it gets flooded on multiple api calls. I'm using Rails 3.2.2 and Devise for authentication.
refaelos
  • 7,927
  • 7
  • 36
  • 55
11
votes
4 answers

Active Admin authentication conflicting with User authentication

Active Admin is a gem used for having an admin dashboard in your application. It uses Devise for logging in users and creates a separate admin_user model for the admins. My application already uses devise and has its users as the user model. Ever…
alik
  • 3,820
  • 9
  • 41
  • 55
11
votes
2 answers

Allow unconfirmed users to access certain pages which require authentication

I use the Rails Stack with devise warden confirmable Now I have a certain requirement related to email confirmation and access provision to unverified users. Let's say there are 3 categories of pages: case 1 - requires no authentication. case 2 -…
10
votes
5 answers

Devise: rememberable means that last_sign_in_at is not updated by trackable

I have being using Devise, and relying on last_sign_in_at of the user model to work out if my customers have not returned within X days. However, I recently discovered that last_sign_in_at is only updated when an actual form log in event occurs, as…
Matthew O'Riordan
  • 7,981
  • 4
  • 45
  • 59
1
2 3
16 17