2-факторная авторизация средствами nginx

Привет, друзья. Сегодня я хочу поведать о том, как я запилил 2-х факторную авторизацию на любое количество ресурсов. Итак, у нас есть некоторые web-ресурсы, доступ к которым должен быть ограничен списком белых IP-адресов и подсетей. Хороший пример это билд сервера или wiki. У админов не всегда есть возможность быстро обновлять ПО на серваках. Поэтому хотелось бы прикрыть к таким ресурсам доступ некой заглушкой.

Именно для этих целей мы с вами запилим динамический список “авторизованных IP-адресов” с помощью nginx. Конечно, реализовать функционал вы можете своими средствами, ухватив основную идею. Общий алгоритм для IP-адресов которые не попадают в список белых IP:

  1. nginx смотрит, что IP, с которого пытаются обратиться к “закрытому” ресурсу не входит в список авторизованных. После чего делается 302 редирект на сайт авторизации. В моем случае это authme.domain.com.
  2. После перехода открывается простая форма с предложением ввести email адрес.
  3. Проверяется что email валидный. В моем случае, я проверяю что email принадлежит зоне domain.com.
  4. Если email валидный, генерируется ключ(с привязкой к IP с которого пришел запрос), который сразу высылается ссылкой на почту.
  5. Пользователь проверяет почту и переходит по ссылке.
  6. authme.domain.com проверяет, что ключ и IP адрес валидные. После чего добавляет в конфигурационный файл nginx IP-адрес в список белых адресов. После чего делается nginx reload, что тот перепрочитал конфигурационные файлы.

Надеюсь основная идея вам ясна. Подходит это вам или нет – решать вам. По ссылке вы найдете docker контейнеры с приложением на nodejs и nginx. Ну и там же есть пример использования.

https://github.com/voiplab/docker

 

147 комментариев к “2-факторная авторизация средствами nginx

  1. I used to be suggested this blog via my cousin. I’m no longer certain whether this
    post is written by way of him as nobody else understand such precise approximately my difficulty.

    You are amazing! Thank you!

  2. Aw, this was a really good post. Finding the time and actual effort to make a superb
    article… but what can I say… I procrastinate a whole lot and don’t
    seem to get anything done.

  3. I do not know if it’s just me or if everybody else experiencing problems with your site.

    It appears as though some of the written text in your posts are running off the screen. Can somebody else please comment and let me know if this is happening to them as well?
    This may be a issue with my internet browser because I’ve had this happen previously.

    Many thanks

  4. 656723 612885I discovered your weblog web site site on google and appearance some of your early posts. Preserve up the excellent operate. I just extra increase Feed to my MSN News Reader. Searching for toward reading far a lot more by you later on! 94152

  5. Heya! I understand this is kind of off-topic however I had to ask. Does managing a well-established website like yours take a lot of work? I’m brand new to blogging but I do write in my diary every day. I’d like to start a blog so I can easily share my personal experience and feelings online. Please let me know if you have any kind of suggestions or tips for new aspiring bloggers. Appreciate it!|

  6. Heyy there just wanted to giv you a quick heads up and let you know a few off the images
    aren’t loading properly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browers and both sshow the same
    outcome.

  7. Hi there would you mind letting me know which webhost you’re using?
    I’ve loaded your blog in 3 completely different web browsers and I must say this blog
    loads a lot quicker then most. Can you recommend a good web hosting provider at a reasonable
    price? Cheers, I appreciate it!

  8. Hey there I am so glad I found your weblog, I really found you by mistake,
    while I was looking on Askjeeve for something else, Anyhow
    I am here now and would just like to say many thanks for a incredible post and
    a all round enjoyable blog (I also love the theme/design), I don’t have time to read it all at
    the minute but I have book-marked it and also included your RSS feeds,
    so when I have time I will be back to read much more,
    Please do keep up the excellent b.

  9. Pretty portion of content. I simply stumbled upon your web
    site and in accession capital to say that I get actually
    enjoyed account your weblog posts. Any way I’ll be subscribing on your feeds or even I fulfillment
    you get right of entry to consistently fast.

  10. hello there and thank you for your information – I’ve certainly picked up anything new from right
    here. I did however expertise some technical issues using this
    web site, as I experienced to reload the web site lots of times previous to I could get it to load properly.
    I had been wondering if your web hosting is OK? Not that I’m complaining, but sluggish loading instances times will sometimes affect
    your placement in google and could damage your high-quality
    score if ads and marketing with Adwords. Anyway I am adding this RSS to my email and could look out for much more of your respective fascinating content.

    Ensure that you update this again very soon.

  11. My partner and I absolutely love your blog and find the majority of
    your post’s to be just what I’m looking for. Does
    one offer guest writers to write content to suit your needs?
    I wouldn’t mind publishing a post or elaborating
    on most of the subjects you write with regards to here.

    Again, awesome blog!

  12. I am extremely impressed with your writing skills as well as with the
    layout on your blog. Is this a paid theme or did you
    modify it yourself? Anyway keep up the excellent quality writing, it is rare to see a
    nice blog like this one nowadays.

  13. Hola! I’ve been following your website for a while now and finally got the courage to go ahead
    and give you a shout out from Humble Tx! Just wanted to tell you keep up the
    good work!

  14. I know this if off topic but I’m looking into starting
    my own blog and was curious what all is needed to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very internet savvy so I’m not 100% positive.
    Any suggestions or advice would be greatly appreciated.

    Cheers

  15. I’m very pleased to discover this page. I wanted to thank you for ones time for this fantastic read!! I definitely savored every bit of it and I have you book marked to check out new things on your web site.

  16. Awesome blog you have here but I was wanting
    to know if you knew of any community forums that cover the same topics talked about in this article?
    I’d really like to be a part of community where I can get comments from other knowledgeable people that share the same interest.
    If you have any recommendations, please let me know.
    Thanks!

  17. This is very interesting, You’re an overly professional blogger.

    I’ve joined your rss feed and look forward to in search of more of your
    great post. Also, I have shared your website in my social networks

  18. Definitely imagine that which you stated. Your favourite reason appeared
    to be on the net the simplest factor to be aware of. I say to you, I certainly get annoyed at the same time as other people think about issues that they plainly
    do not realize about. You managed to hit the nail upon the top and also defined out the whole thing with no need side-effects
    , other folks can take a signal. Will probably be back to get more.
    Thanks

  19. Please let me know if you’re looking for a article
    author for your blog. You have some really good posts and I
    believe I would be a good asset. If you ever want to take some of the load off, I’d really like to write some content for your blog in exchange for
    a link back to mine. Please shoot me an email if interested.
    Cheers!

  20. Hi! I know this is somewhat off topic but I was wondering if you knew where I could find
    a captcha plugin for my comment form? I’m using the same blog platform
    as yours and I’m having problems finding one? Thanks a lot!

  21. Fantastic goods from you, man. I’ve understand your stuff previous to and
    you’re just extremely magnificent. I really like what you have acquired here, certainly like what
    you are stating and the way in which you say it. You make it
    entertaining and you still care for to keep it smart.
    I can not wait to read far more from you. This is actually a wonderful website.

  22. Heya outstanding website! Does running a blog such
    as this require a massive amount work? I have absolutely no knowledge of programming but I had been hoping to start my
    own blog soon. Anyway, should you have any recommendations or tips
    for new blog owners please share. I know this is off subject nevertheless I
    just had to ask. Cheers!

  23. Hi there, I discovered your site by the use of Google while
    searching for a related topic, your website came up, it appears good.
    I’ve bookmarked it in my google bookmarks.
    Hello there, just was alert to your weblog via Google,
    and located that it is truly informative. I am gonna watch out for brussels.
    I will be grateful if you continue this in future.
    Numerous people might be benefited from your writing. Cheers!

  24. Excellent blog here! Additionally your site so much up
    very fast! What web host are you the use of? Can I am getting your affiliate link on your host?
    I want my site loaded up as quickly as yours lol

  25. Write more, thats all I have to say. Literally,
    it seems as though you relied on the video to make
    your point. You obviously know what youre talking about, why
    waste your intelligence on just posting videos to your blog when you could be giving us something informative
    to read?

  26. Good day! This post could not be written any better!
    Reading through this post reminds me of my good old room mate!
    He always kept chatting about this. I will forward this write-up to him.
    Fairly certain he will have a good read. Many thanks for sharing!

  27. This design is spectacular! You obviously know how to keep a reader amused.

    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Wonderful job.
    I really loved what you had to say, and more than that, how you presented
    it. Too cool!

  28. Hi, I do believe this is a great blog. I stumbledupon it 😉
    I will revisit once again since i have saved as a favorite it.

    Money and freedom is the best way to change, may you be rich and continue to help others.

  29. That is really interesting, You’re a very professional blogger.
    I have joined your rss feed and look ahead to in quest of extra of your great post.
    Additionally, I’ve shared your website in my social networks

  30. I am really enjoying the theme/design of
    your web site. Do you ever run into any web browser compatibility issues?
    A number of my blog audience have complained about my website not working correctly in Explorer but looks great in Safari.
    Do you have any advice to help fix this issue?

  31. Nice post. I was checking constantly this blog and I am impressed!
    Extremely helpful info particularly the last part :
    ) I care for such info much. I was seeking this certain info for a long time.
    Thank you and best of luck.

  32. My spouse and I absolutely love your blog and find the majority of your post’s to be just what
    I’m looking for. Do you offer guest writers to write content for
    you? I wouldn’t mind producing a post or elaborating on some of the
    subjects you write regarding here. Again, awesome web site!

  33. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet
    my newest twitter updates. I’ve been looking for a plug-in like this
    for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading
    your blog and I look forward to your new updates.

  34. Having read this I believed it was really informative.
    I appreciate you spending some time and effort to put this short article together.
    I once again find myself personally spending a significant amount of time both reading
    and leaving comments. But so what, it was still worth it!

  35. I’ve been surfing on-line more than 3 hours lately, but I
    never found any fascinating article like yours.
    It is beautiful worth sufficient for me. Personally, if all web
    owners and bloggers made good content as you probably did, the net can be a lot
    more useful than ever before.

  36. Thanks on your marvelous posting! I certainly enjoyed reading it,
    you are a great author. I will make sure to bookmark your
    blog and will often come back someday. I want to encourage you to ultimately continue your great posts, have
    a nice morning!

  37. Howdy, There’s no doubt that your site may be having web browser compatibility problems. Whenever I take a look at your site in Safari, it looks fine however, when opening in Internet Explorer, it’s got some overlapping issues. I simply wanted to give you a quick heads up! Besides that, excellent website!|

  38. Next time I read a blog, I hope that it doesn’t disappoint me just as much as this particular one. After all, I know it was my choice to read through, nonetheless I really believed you’d have something useful to say. All I hear is a bunch of moaning about something that you could fix if you were not too busy searching for attention.

  39. Excellent post. Keep posting such kind of info on your blog.
    Im really impressed by your blog.
    Hello there, You’ve performed a fantastic job.
    I will certainly digg it and personally suggest to my friends.
    I’m sure they’ll be benefited from this website.

  40. Hey there! This is my first visit to your
    blog! We are a group of volunteers and starting a new project in a community in the same niche.
    Your blog provided us useful information to work
    on. You have done a marvellous job!

  41. Thanks for the marvelous posting! I quite enjoyed reading it, you might be a great author.I will ensure that I bookmark your blog and
    will eventually come back someday. I want to encourage continue your great writing, have a
    nice day!

  42. I blog quite often and I genuinely thank you for your content.

    Your article has truly peaked my interest. I’m going to take a note of your website and keep checking for new information about
    once per week. I opted in for your RSS feed too.

  43. This design is wicked! You obviously know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job.
    I really enjoyed what you had to say, and more than that, how you
    presented it. Too cool!

  44. Oh my goodness! Incredible article dude! Thank you so much,
    However I am going through issues with your RSS. I don’t know the reason why I am
    unable to join it. Is there anybody having the same RSS issues?

    Anybody who knows the solution can you kindly respond? Thanks!!

  45. Woah! I’m really digging the template/theme of this blog. It’s simple, yet effective.
    A lot of times it’s hard to get that “perfect balance” between superb usability and visual
    appeal. I must say that you’ve done a excellent job with this.
    In addition, the blog loads extremely quick for me on Internet explorer.
    Exceptional Blog!

  46. Oh my goodness! Incredible article dude! Thanks, However I am having issues with
    your RSS. I don’t understand the reason why I am unable
    to subscribe to it. Is there anybody else having similar RSS issues?
    Anyone that knows the answer will you kindly respond?
    Thanks!!

  47. I don’t know if it’s just me or if perhaps everyone else encountering problems with your blog.
    It seems like some of the text in your posts are running
    off the screen. Can somebody else please provide
    feedback and let me know if this is happening to them as well?
    This may be a issue with my web browser because I’ve had this happen before.
    Thank you

  48. Just want to say your article is as surprising. The clearness in your post is simply
    nice and i could assume you’re an expert on this subject.
    Fine with your permission allow me to grab your RSS
    feed to keep up to date with forthcoming post. Thanks a million and please
    continue the rewarding work.

  49. Nice post. I was checking continuously this
    blog and I am impressed! Very useful info particularly the last part 🙂 I care for such info
    a lot. I was looking for this certain information for a long time.
    Thank you and good luck.

  50. This is the right website for everyone who really wants to find out about this topic. You know a whole lot its almost hard to argue with you (not that I personally will need toÖHaHa). You certainly put a brand new spin on a subject that has been written about for decades. Excellent stuff, just wonderful!

  51. I’d like to thank you for the efforts you have put in writing this blog. I’m hoping to see the same high-grade blog posts by you later on as well. In truth, your creative writing abilities has motivated me to get my own, personal site now 😉

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *