Authentication in sinatra

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.

The easiest thing to start with is HTTP basic auth, have a look here: Sinatra: Frequently Asked Questions.

Ketan Patel

···

On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&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 .?

Regards,

Surya.

···

On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:

The easiest thing to start with is HTTP basic auth, have a look here:
Sinatra: Frequently Asked Questions.

Ketan Patel

> On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Most browsers will cache the username/password so you don’t have 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 <suryapjr@gmail.com> wrote:

Will it ask for authentication everytime someone visits the URL ? or is it if I enter correct combination once,it will not ask again .?

Regards,

Surya.

On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:
The easiest thing to start with is HTTP basic auth, have a look here: Sinatra: Frequently Asked Questions.

Ketan Patel

> On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

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, <ketpat@gmail.com> wrote:

Most browsers will cache the username/password so you don’t have 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 <suryapjr@gmail.com> wrote:
>
> Will it ask for authentication everytime someone visits the URL ? or is
it if I enter correct combination once,it will not ask again .?
>
>
> Regards,
>
> Surya.
>
> On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:
> The easiest thing to start with is HTTP basic auth, have a look here:
Sinatra: Frequently Asked Questions.
>
> Ketan Patel
>
>
> > On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&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.

Ketan Patel

···

On 12 Jan 2020, at 11:00, Surya Poojary <suryapjr@gmail.com> 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, <ketpat@gmail.com> wrote:
Most browsers will cache the username/password so you don’t have 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 <suryapjr@gmail.com> wrote:
>
> Will it ask for authentication everytime someone visits the URL ? or is it if I enter correct combination once,it will not ask again .?
>
>
> Regards,
>
> Surya.
>
> On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:
> The easiest thing to start with is HTTP basic auth, have a look here: Sinatra: Frequently Asked Questions.
>
> Ketan Patel
>
>
> > On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

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, <ketpat@gmail.com> 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 <suryapjr@gmail.com> 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, <ketpat@gmail.com> wrote:
> Most browsers will cache the username/password so you don’t have 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 <suryapjr@gmail.com> wrote:
> >
> > Will it ask for authentication everytime someone visits the URL ? or
is it if I enter correct combination once,it will not ask again .?
> >
> >
> > Regards,
> >
> > Surya.
> >
> > On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:
> > The easiest thing to start with is HTTP basic auth, have a look here:
Sinatra: Frequently Asked Questions.
> >
> > Ketan Patel
> >
> >
> > > On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> >
> >
> > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> >
> > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

That would technically work but other than redirecting to a path it’s not doing anything that HTTP Basic Auth isn’t already doing, unless of course you wanted a custom login form, in which case you would need to handle session cookies so users’ don’t have to login every time. See Free Bootcamp Prep | Flatiron School

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’s not enough.

Ketan Patel

···

On 12 Jan 2020, at 11:07, Surya Poojary <suryapjr@gmail.com> 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, <ketpat@gmail.com> 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 <suryapjr@gmail.com> 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, <ketpat@gmail.com> wrote:
> Most browsers will cache the username/password so you don’t have 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 <suryapjr@gmail.com> wrote:
> >
> > Will it ask for authentication everytime someone visits the URL ? or is it if I enter correct combination once,it will not ask again .?
> >
> >
> > Regards,
> >
> > Surya.
> >
> > On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:
> > The easiest thing to start with is HTTP basic auth, have a look here: Sinatra: Frequently Asked Questions.
> >
> > Ketan Patel
> >
> >
> > > On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> >
> >
> > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> >
> > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Gracias ! Ketan !

Regards,
Surya.

···

On Sun, 12 Jan 2020, 16:55 Ketan Patel, <ketpat@gmail.com> wrote:

That would technically work but other than redirecting to a path it’s not
doing anything that HTTP Basic Auth isn’t already doing, unless of course
you wanted a custom login form, in which case you would need to handle
session cookies so users’ don’t have to login every time. See
Free Bootcamp Prep | Flatiron School

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’s not enough.

Ketan Patel

> On 12 Jan 2020, at 11:07, Surya Poojary <suryapjr@gmail.com> 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, <ketpat@gmail.com> 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 <suryapjr@gmail.com> 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, <ketpat@gmail.com> wrote:
> > Most browsers will cache the username/password so you don’t have 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 <suryapjr@gmail.com> wrote:
> > >
> > > Will it ask for authentication everytime someone visits the URL ? or
is it if I enter correct combination once,it will not ask again .?
> > >
> > >
> > > Regards,
> > >
> > > Surya.
> > >
> > > On Sun, 12 Jan 2020, 16:03 Ketan Patel, <ketpat@gmail.com> wrote:
> > > The easiest thing to start with is HTTP basic auth, have a look
here: Sinatra: Frequently Asked Questions.
> > >
> > > Ketan Patel
> > >
> > >
> > > > On 12 Jan 2020, at 10:15, Surya Poojary <suryapjr@gmail.com> > 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:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> > >
> > >
> > > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> > >
> > > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> >
> >
> > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
> >
> > Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;
>
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Hi,

Just pick up a book called "Jump Start Sinatra" (around 100 pages).
It will teach you all that you want, if you know some knowledge on web
application programming.
You can finish off the book in 2 hours and start building it after that.

Regards,

Jeyaraj D

···

On Sun, Jan 12, 2020 at 3:46 PM Surya Poojary <suryapjr@gmail.com> 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:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

I liked "Sinatra: Up and running". Cheaper, too!

You might also want to look at some of the classes on Coursera, or EdX. You can usually audit them for free, and it may help your web skills. They have some Ruby on Rails (ugh), but a lot of web stuff that will help your Ruby skills. For example:

   https://www.coursera.org/specializations/web-design

Leam

···

On 1/13/20 9:41 PM, Jeyaraj Durairaj wrote:

Hi,

Just pick up a book called "Jump Start Sinatra" (around 100 pages).
It will teach you all that you want, if you know some knowledge on web application programming.
You can finish off the book in 2 hours and start building it after that.

Regards,

Jeyaraj D

On Sun, Jan 12, 2020 at 3:46 PM Surya Poojary <suryapjr@gmail.com > <mailto:suryapjr@gmail.com>> 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:ruby-talk-request@ruby-lang.org
    <mailto:ruby-talk-request@ruby-lang.org>?subject=unsubscribe>
    <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;