Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there any design pattern for login?

There is a very simple 2 page website. first is login page where we can enter username and password, and the second page shows "welcome" after authentication..

Is there any design pattern that we can use for this?

I am not able think of a design pattern for such a simple website, but just wanted to get your thoughts.

One of my colleague asked this question to me!

like image 739
Deepak Raj Avatar asked Mar 16 '13 13:03

Deepak Raj


People also ask

What is the design pattern used in logging?

Logging is usually implemented with the Chain of responsibility pattern.

Which pattern is used to design a webpage?

4 Design Patterns You Should Know for Web Development: Observer, Singleton, Strategy, and Decorator.

What are the secure design patterns?

Secure design patterns are meant to eliminate the accidental insertion of vulnerabilities into code and to mitigate the consequences of these vulnerabilities.


1 Answers

Yes, the interceptor pattern (or intercepting filter) comes to mind: a central filter should intercept all the requests to authentication-protected pages of the application and redirect to the login page if the user is not authenticated yet.

And if the user is already authenticated, it should let the request go to its original target.

Note that it's much more user-friendly to not redirect to a welcome page after authentication, but to the originally-requested page:

  • User wants to go to /my-profile
  • Filter notices the user is not authenticated, and /my-profile requires authentication. It redirects to login page
  • user logs in
  • server redirects to /my-profile which is where the user asked to go originally.

Note that I know nothing about asp.net, so this pattern might be easy to implement or very hard: I have no idea. Java EE webapps have this notion of filters which are typically used for authentication, the way described above.

like image 191
JB Nizet Avatar answered Oct 15 '22 11:10

JB Nizet