Re: Authentication in sinatra

Surya Poojary <[email protected]> Sun, 12 Jan 2020 17:00:19 +0530
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAANzoRG-zJpaK6hHL3dPAZPGF=B93P93e07AqSeJ626eByNHYg@mail.gmail.com>
--===============0092905001==
Content-Type: multipart/alternative; boundary="000000000000b85246059befafc9"

--000000000000b85246059befafc9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Gracias ! Ketan !

Regards,
Surya.

On Sun, 12 Jan 2020, 16:55 Ketan Patel, <[email protected]> wrote:

> That would technically work but other than redirecting to a path it=E2=80=
=99s not
> doing anything that HTTP Basic Auth isn=E2=80=99t already doing, unless o=
f course
> you wanted a custom login form, in which case you would need to handle
> session cookies so users=E2=80=99 don=E2=80=99t have to login every time.=
 See
> https://learn.co/lessons/sinatra-sessions
>
> My advise is to not get too caught up in this. Since this is a personal
> web site, focus on making the notes application and use HTTP Basic Auth
> until you find it=E2=80=99s not enough.
>
> Ketan Patel
>
>
> > On 12 Jan 2020, at 11:07, Surya Poojary <[email protected]> wrote:
> >
> > Cool........thanks Ketan Bhai ..
> >
> > And also can we do like this ..
> >
> > Store the input used in username field and the password field in
> instance variables..and the use and if statement to compare it to our
> values ..if it doesn't match , redirect to "/illegal" login.
> >
> >
> > Regards,
> > Surya.
> >
> >
> > Regards,
> >
> > Surya.
> >
> > On Sun, 12 Jan 2020, 16:33 Ketan Patel, <[email protected]> wrote:
> > I assume so but different browsers may handle it differently, try the
> example in the previous link i sent you and play around with it.
> >
> >
> > Ketan Patel
> >
> >
> >
> > > On 12 Jan 2020, at 11:00, Surya Poojary <[email protected]> wrote:
> > >
> > > So if they open it again ..they have to enter the password
> again..right ?
> > >
> > >
> > > Regards,
> > >
> > > Surya.
> > >
> > > On Sun, 12 Jan 2020, 16:23 Ketan Patel, <[email protected]> wrote:
> > > Most browsers will cache the username/password so you don=E2=80=99t h=
ave to
> enter it on every page reload and will delete them when the browser is
> closed.
> > >
> > > Ketan Patel
> > >
> > >
> > >
> > > > On 12 Jan 2020, at 10:43, Surya Poojary <[email protected]> wrote:
> > > >
> > > > Will it ask for authentication everytime someone visits the URL ? o=
r
> is it if I enter correct combination once,it will not ask again .?
> > > >
> > > >
> > > > Regards,
> > > >
> > > > Surya.
> > > >
> > > > On Sun, 12 Jan 2020, 16:03 Ketan Patel, <[email protected]> wrote:
> > > > The easiest thing to start with is HTTP basic auth, have a look
> here: http://sinatrarb.com/faq.html#auth.
> > > >
> > > > Ketan Patel
> > > >
> > > >
> > > > > On 12 Jan 2020, at 10:15, Surya Poojary <[email protected]>
> wrote:
> > > > >
> > > > > Dear Rubyists,
> > > > >
> > > > > I'm a web developer newbie , learning sinatra . I'm planning to
> build my own notes web app. Since it's for my personal use , I want the
> home page to be a classic login page where I can enter my username and
> password and then it should show me all my notes otherwise it shouldn't
> show .
> > > > >
> > > > > How do I achieve this with Sinatra?
> > > > >
> > > > > Regards,
> > > > > Surya.
> > > > >
> > > > >
> > > > > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > > > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> > > >
> > > >
> > > > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> > > >
> > > > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> > >
> > >
> > > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> > >
> > > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> >
> >
> > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> >
> > Unsubscribe: <mailto:[email protected]
> ?subject=3Dunsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
>
> Unsubscribe: <mailto:[email protected]?subject=3Dunsubscrib=
e>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>

--000000000000b85246059befafc9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Gracias ! Ketan !<div dir=3D"auto"><br></div><div dir=3D"=
auto">Regards,</div><div dir=3D"auto">Surya.</div></div><br><div class=3D"g=
mail_quote"><div dir=3D"ltr">On Sun, 12 Jan 2020, 16:55 Ketan Patel, &lt;<a=
 href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">That would technically work but other than r=
edirecting to a path it=E2=80=99s not doing anything that HTTP Basic Auth i=
sn=E2=80=99t already doing, unless of course you wanted a custom login form=
, in which case you would need to handle session cookies so users=E2=80=99 =
don=E2=80=99t have to login every time. See <a href=3D"https://learn.co/les=
sons/sinatra-sessions" rel=3D"noreferrer noreferrer" target=3D"_blank">http=
s://learn.co/lessons/sinatra-sessions</a> <br>
<br>
My advise is to not get too caught up in this. Since this is a personal web=
 site, focus on making the notes application and use HTTP Basic Auth until =
you find it=E2=80=99s not enough.<br>
<br>
Ketan Patel<br>
<br>
<br>
&gt; On 12 Jan 2020, at 11:07, Surya Poojary &lt;<a href=3D"mailto:suryapjr=
@gmail.com" target=3D"_blank" rel=3D"noreferrer">[email protected]</a>&gt;=
 wrote:<br>
&gt; <br>
&gt; Cool........thanks Ketan Bhai ..<br>
&gt; <br>
&gt; And also can we do like this ..<br>
&gt; <br>
&gt; Store the input used in username field and the password field in insta=
nce variables..and the use and if statement to compare it to our values ..i=
f it doesn&#39;t match , redirect to &quot;/illegal&quot; login.<br>
&gt; <br>
&gt; <br>
&gt; Regards,<br>
&gt; Surya.<br>
&gt; <br>
&gt; <br>
&gt; Regards,<br>
&gt; <br>
&gt; Surya.<br>
&gt; <br>
&gt; On Sun, 12 Jan 2020, 16:33 Ketan Patel, &lt;<a href=3D"mailto:ketpat@g=
mail.com" target=3D"_blank" rel=3D"noreferrer">[email protected]</a>&gt; wro=
te:<br>
&gt; I assume so but different browsers may handle it differently, try the =
example in the previous link i sent you and play around with it.<br>
&gt; <br>
&gt; <br>
&gt; Ketan Patel<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &gt; On 12 Jan 2020, at 11:00, Surya Poojary &lt;<a href=3D"mailto:sur=
[email protected]" target=3D"_blank" rel=3D"noreferrer">[email protected]</a=
>&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt; So if they open it again ..they have to enter the password again.=
.right ?<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Regards,<br>
&gt; &gt; <br>
&gt; &gt; Surya.<br>
&gt; &gt; <br>
&gt; &gt; On Sun, 12 Jan 2020, 16:23 Ketan Patel, &lt;<a href=3D"mailto:ket=
[email protected]" target=3D"_blank" rel=3D"noreferrer">[email protected]</a>&gt=
; wrote:<br>
&gt; &gt; Most browsers will cache the username/password so you don=E2=80=
=99t have to enter it on every page reload and will delete them when the br=
owser is closed.<br>
&gt; &gt; <br>
&gt; &gt; Ketan Patel<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; &gt; On 12 Jan 2020, at 10:43, Surya Poojary &lt;<a href=3D"mailt=
o:[email protected]" target=3D"_blank" rel=3D"noreferrer">[email protected]=
om</a>&gt; wrote:<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Will it ask for authentication everytime someone visits the =
URL ? or is it if I enter correct combination once,it will not ask again .?=
<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Regards,<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Surya.<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; On Sun, 12 Jan 2020, 16:03 Ketan Patel, &lt;<a href=3D"mailt=
o:[email protected]" target=3D"_blank" rel=3D"noreferrer">[email protected]</=
a>&gt; wrote:<br>
&gt; &gt; &gt; The easiest thing to start with is HTTP basic auth, have a l=
ook here: <a href=3D"http://sinatrarb.com/faq.html#auth" rel=3D"noreferrer =
noreferrer" target=3D"_blank">http://sinatrarb.com/faq.html#auth</a>.<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Ketan Patel<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; On 12 Jan 2020, at 10:15, Surya Poojary &lt;<a href=3D"=
mailto:[email protected]" target=3D"_blank" rel=3D"noreferrer">suryapjr@gm=
ail.com</a>&gt; wrote:<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Dear Rubyists,<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; I&#39;m a web developer newbie , learning sinatra . I&#=
39;m planning to build my own notes web app. Since it&#39;s for my personal=
 use , I want the home page to be a classic login page where I can enter my=
 username and password and then it should show me all my notes otherwise it=
 shouldn&#39;t show . <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; How do I achieve this with Sinatra?<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Regards,<br>
&gt; &gt; &gt; &gt; Surya.<br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; <br>
&gt; &gt; &gt; &gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-req=
[email protected]" target=3D"_blank" rel=3D"noreferrer">ruby-talk-request@=
ruby-lang.org</a>?subject=3Dunsubscribe&gt;<br>
&gt; &gt; &gt; &gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailm=
an/options/ruby-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http:=
//lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-request@=
ruby-lang.org" target=3D"_blank" rel=3D"noreferrer">ruby-talk-request@ruby-=
lang.org</a>?subject=3Dunsubscribe&gt;<br>
&gt; &gt; &gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/op=
tions/ruby-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lis=
ts.ruby-lang.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
&gt; &gt; &gt; <br>
&gt; &gt; &gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-request@=
ruby-lang.org" target=3D"_blank" rel=3D"noreferrer">ruby-talk-request@ruby-=
lang.org</a>?subject=3Dunsubscribe&gt;<br>
&gt; &gt; &gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/op=
tions/ruby-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lis=
ts.ruby-lang.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-request@ruby-=
lang.org" target=3D"_blank" rel=3D"noreferrer">ruby-talk-request@ruby-lang.=
org</a>?subject=3Dunsubscribe&gt;<br>
&gt; &gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options=
/ruby-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lists.ru=
by-lang.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
&gt; &gt; <br>
&gt; &gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-request@ruby-=
lang.org" target=3D"_blank" rel=3D"noreferrer">ruby-talk-request@ruby-lang.=
org</a>?subject=3Dunsubscribe&gt;<br>
&gt; &gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options=
/ruby-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lists.ru=
by-lang.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
&gt; <br>
&gt; <br>
&gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-request@ruby-lang.=
org" target=3D"_blank" rel=3D"noreferrer">[email protected]</=
a>?subject=3Dunsubscribe&gt;<br>
&gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby=
-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lists.ruby-la=
ng.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
&gt; <br>
&gt; Unsubscribe: &lt;mailto:<a href=3D"mailto:ruby-talk-request@ruby-lang.=
org" target=3D"_blank" rel=3D"noreferrer">[email protected]</=
a>?subject=3Dunsubscribe&gt;<br>
&gt; &lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby=
-talk" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lists.ruby-la=
ng.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
<br>
<br>
Unsubscribe: &lt;mailto:<a href=3D"mailto:[email protected]" =
target=3D"_blank" rel=3D"noreferrer">[email protected]</a>?su=
bject=3Dunsubscribe&gt;<br>
&lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk=
" rel=3D"noreferrer noreferrer" target=3D"_blank">http://lists.ruby-lang.or=
g/cgi-bin/mailman/options/ruby-talk</a>&gt;<br>
</blockquote></div>

--000000000000b85246059befafc9--

--===============0092905001==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--===============0092905001==--