How to add simple http authentication in Ruby on Rails
Aug 26, 25 / 87 comments
/
#Ruby on Rails
Sometimes you don't need a fancy authentication for your website, here's how to can implement that.
Instead of implementing something like Devise, or your own authentication, you can just use simple http authentication from Ruby on Rails.
Maybe you just need to hide a simple admin section, not ready to show the website to the world, etc. When that's the case, this simple solution is really great.
class Admin::PostsController < ApplicationController
http_basic_authenticate_with name: "codewithstein", password: "rubyonrails"
def index
@posts = Post.order(created_at: :desc)
end
end
So with this one line, you will now need a username and password to access this controller. Note that saving passwords like this in clear text is not so called best practice, so keep that in mind.
Comments
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
-1 OR 2+443-443-1=0+0+0+1 --
EFSArCBy | Jul 02, 26 07:29
-1 OR 2+583-583-1=0+0+0+1
EFSArCBy | Jul 02, 26 07:29
-1' OR 2+900-900-1=0+0+0+1 --
EFSArCBy | Jul 02, 26 07:29
-1' OR 2+998-998-1=0+0+0+1 or 'LsKxz10o'='
EFSArCBy | Jul 02, 26 07:29
-1" OR 2+646-646-1=0+0+0+1 --
EFSArCBy | Jul 02, 26 07:29
555*if(now()=sysdate(),sleep(15),0)
EFSArCBy | Jul 02, 26 07:29
5550'XOR(555*if(now()=sysdate(),sleep(15),0))XOR'Z
EFSArCBy | Jul 02, 26 07:29
5550"XOR(555*if(now()=sysdate(),sleep(15),0))XOR"Z
EFSArCBy | Jul 02, 26 07:29
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
EFSArCBy | Jul 02, 26 07:29
555-1; waitfor delay '0:0:15' --
EFSArCBy | Jul 02, 26 07:29
555-1); waitfor delay '0:0:15' --
EFSArCBy | Jul 02, 26 07:29
555-1 waitfor delay '0:0:15' --
EFSArCBy | Jul 02, 26 07:29
555Dr7Gb1lk'; waitfor delay '0:0:15' --
EFSArCBy | Jul 02, 26 07:29
555-1 OR 156=(SELECT 156 FROM PG_SLEEP(15))--
EFSArCBy | Jul 02, 26 07:29
555-1) OR 921=(SELECT 921 FROM PG_SLEEP(15))--
EFSArCBy | Jul 02, 26 07:29
555-1)) OR 629=(SELECT 629 FROM PG_SLEEP(15))--
EFSArCBy | Jul 02, 26 07:29
555k1fTXApn' OR 230=(SELECT 230 FROM PG_SLEEP(15))--
EFSArCBy | Jul 02, 26 07:29
555VcvzLaRY') OR 620=(SELECT 620 FROM PG_SLEEP(15))--
EFSArCBy | Jul 02, 26 07:29
555UhWj1W3E')) OR 717=(SELECT 717 FROM PG_SLEEP(15))--
EFSArCBy | Jul 02, 26 07:29
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
EFSArCBy | Jul 02, 26 07:29
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555'"
EFSArCBy | Jul 02, 26 07:29
@@2mY5l
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
-1 OR 2+947-947-1=0+0+0+1 -- | Jul 02, 26 07:29
555
-1 OR 2+76-76-1=0+0+0+1 | Jul 02, 26 07:29
555
-1' OR 2+736-736-1=0+0+0+1 -- | Jul 02, 26 07:29
555
-1' OR 2+160-160-1=0+0+0+1 or 'TNyl1Hys'=' | Jul 02, 26 07:29
555
-1" OR 2+255-255-1=0+0+0+1 -- | Jul 02, 26 07:29
555
if(now()=sysdate(),sleep(15),0) | Jul 02, 26 07:29
555
EFSArCBy0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z | Jul 02, 26 07:29
555
EFSArCBy0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z | Jul 02, 26 07:29
555
EFSArCBy-1 waitfor delay '0:0:15' -- | Jul 02, 26 07:29
555
EFSArCByFPCComuf'; waitfor delay '0:0:15' -- | Jul 02, 26 07:29
555
EFSArCByA7zwywwg' OR 289=(SELECT 289 FROM PG_SLEEP(15))-- | Jul 02, 26 07:29
555
EFSArCByQl2ECsSI') OR 292=(SELECT 292 FROM PG_SLEEP(15))-- | Jul 02, 26 07:29
555
EFSArCByQTATPE3w')) OR 535=(SELECT 535 FROM PG_SLEEP(15))-- | Jul 02, 26 07:29
555
EFSArCBy'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||' | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy'" | Jul 02, 26 07:29
555
@@0D1sd | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
EFSArCBy | Jul 02, 26 07:29
555
Add comment
Please log in to comment!