Search This Blog

Wednesday, April 22, 2020

Fwd: Authentication to gmail fails with example app · Issue #239 · jstedfast/MailKit

vấn đề khi login vào gmail bằng OAuth2, và vài suy nghĩ về OAuth2 của tác giả MailKit (jeff)

kết quả là sẽ không có sample login dùng Google Mail 
Thử cái khác đi 

https://github.com/jstedfast/MailKit/issues/239

I guess if you trust browser controls more than email clients, then I suppose that's more "secure"... but it sounds more like the "security" strategy is to not allow passwords to be saved, which means you could just make clients not save the password and prompt every time.

In other words, OAuth2 is really just a kludge to work around the fact that many email clients offer to save the user's password for their own convenience (just like web browsers do) and some people feel that by forcing users to enter their credentials manually every time, it makes it more secure?

In my experience, that means most users just choose easier passwords to remember (meaning less secure) or they tell their browser to save it (overriding the whole purpose of the OAuth2 security strategy), or... at best, they just store it in something like 1Password or LastPass (which is what I do).

Apparently security experts don't feel it's very secure.

OAuth 2.0 doesn't support signature, encryption, channel binding, or client verification.  It relies completely on SSL for some degree of confidentiality and server authentication.    OAuth 2.0 has had numerous security flaws exposed in implementations. The protocol  itself has been described as inherently insecure by security experts and a primary  contributor to the specification stated that implementation mistakes are almost inevitable.  

The first sentence suggests to me that the purpose was to enforce the idea that passwords aren't sent over the wire in the clear, thus allowing non-SSL/STARTTLS IMAP clients to login w/o the use of a cleartext password (such as the LOGIN command or the LOGIN and/or PLAIN SASL mechanisms). The solution, here, though, is to simply not support those mechanisms on the server and to instead only offer mechanisms such as CRAM-MD5, SCRAM-SHA-1, NTLM, or one of the many other challenge-response mechanisms that do not send any form of the password across the wire at all.

The only counter-argument that I can think of for that (and I'd have to double-check to confirm) is that all of those SASL mechanisms require that the server be able to get access to the raw password string which means that it'd have to store the cleartext password somewhere (e.g. /etc/shadow) whereas in cases where the authentication protocol requires the raw password be sent, then the server could just store a hash of the password and hash the raw password that it receives across the wire and match it against what it has in its database.

But that just trades trust in the server not being compromised with a much more likely scenario of the SSL protocol being compromised or a MITM attack.

I haven't read what the security experts have said about OAuth2, but my guess is that I'm probably pretty close :-)

OAuth(2) was never designed for native apps. The problem you described "where do i put my client secret/credentials/api key" is not only a problem for a test app that is published on github. It is a real problem for all native apps, if you know how easy it is to "decompile" apps. This applies to interpreted languages like C# and Java even more. OAuth(2) was (sadly) designed for server-to-server communication, where the OAuth credentials are never shipped to a client/user and are instead some where ("safe") in your backend code/config.






Tuesday, February 5, 2019

SSH trong Windows 10

2019-02-05-ssh-trong-windows

Một trong những điều ức chế của khi làm mấy việc dạng sysadmin trong windows là ssh, đặc biệt khi bạn dùng laptop chạy windows, và manage một đống server chạy linux.
May thay, từ Win 10, đội của anh Bill đã về-với-chính-đạo khi hỗ trợ OpenSSH
Trong bài này, sẽ tóm tắt lại lịch sử vụ ssh-from-windows-with-luv này của mình.

  1. Cài OpenSSH vào windows, chi tiết tham khảo link trên, tóm tắt như sau:
    1. Download OpenSSH từ github Powershell/Win32-OpenSSH/releases
      chỗ này có điểm 2 củ chuối, 1 là code của openssh-for-windows thì nằm trong https://github.com/PowerShell/openssh-portable, nhưng release và issue của nó thì nằm đây,
      2 là trong trang docs của Microsoft có 1 đoạn hơi bị nguy hiểm, bảo là nếu không cài bằng powershell theo hướng dẫn chuẩn thì phải làm theo hướng dẫn trong cái github kia, chả hiểu các bạn Microsoft nghĩ gì 😂
    2. Chạy cái file powershell để install vào: powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
  2. Bật cmd lên, ssh -i user@ip như một vị thần

[1] https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Written with StackEdit.

Monday, January 21, 2019

Tạo symlink trong windows

symlink-in-windows

Tạo symlink trong Windows

Mở CMD để chạy command mklink.

mklink /d Link Target
Trong đó:
Link: Đường dẫn của file alias
Target: Đường dẫn đến file gốc

Lưu ý CMD phải Run as administrator thì mới chạy được lệnh này.

Sunday, November 18, 2018

Dual-boot Windows - Ubuntu - Manjaro

không có j để nói nhiều, làm theo 2 cái guide này:
1. thêm Ubuntu vào cạnh windows
https://askubuntu.com/questions/484434/install-ubuntu-without-cd-and-usb-how
2. thêm manjaro vào vị trí "người thứ ba"
https://forum.manjaro.org/t/manjaro-install-over-ubuntu-dual-boot-configuration/9155

Saturday, October 6, 2018

Vấn đề khi reference project vào Asp.net Web Application

Bài toán:
Có 1 cái solution gồm 2 project:

  • project 1: Class Library (target on .NET 4.6.1) 
  • project 2: Web Application (not Core, target on .NET 4.6.1) 
Nếu dùng chức năng Reference giữa các project trong cùng solution --> failed. 
Phải build cái project 1 ra thành DLL, xong rồi add reference bằng cách trỏ vào cái DLL đó. 


Tuesday, June 19, 2018

Class method and instance method trong C#

Class method and instance method trong C#

Vì đọc bài này nên tự nhiên nghĩ đến static method (class method) & normal method (instance method) trong C#. Vậy nên viết cái này
Không giống Ruby, trong C# thì class method và instance method không đa hình, nghĩa là nếu viết như này:

    public class Animal
    {
        public static void Hello()
        {
        }
        public void Hello()
        {
        }
    }

Các bạn sẽ bị lỗi:

CS0111 Type ‘Animal’ already defines a member called ‘Hello’ with the same parameter types

Còn khi gọi, thì cũng giống Ruby, static method không thể được gọi từ 1 instance mà phải gọi từ class

class Program
    {
        static void Main(string[] args)
        {
            Animal a = new Animal();
            Animal.Hello();
            a.Hello();  //Error: CS0176 
            a.HelloHuman();
        }
    }

CS0176 Member ‘Animal.Hello()’ cannot be accessed with an instance reference; qualify it with a type name instead

Written with StackEdit.

Wednesday, June 13, 2018

Willing to learn

Hôm nay group review một cái tài liệu về version control với mấy đồng nghiệp, bạn Huê bảo:

Cái đó có gì đâu mà ông viết có vẻ khó khăn vậy, người ta xài đầy!

“Cái đó” là cái này :)
git workflow

Tự nhiên suy nghĩ, hình như hồi xưa mình open up ra ngoài cũng y như Huê vậy, nhiệt huyết và tích cực "cái đó có gì đâu, thế giới xài đầy, nhưng đến một hồi thì không như thế nữa, giờ khi nghĩ về vấn đề gì đó, mình hay lấy cái “người việt nam” làm cơ sở phán đoán.

Cho nên phản biện của mình cho Huê là

Tất nhiên, là không có gì ghê gớm cả, khi cần thì ai cũng có thể học được, quan trọng là member của bạn có willing để học hay không mà thôi. Nếu bạn có một nhóm member giống như Huê, nhiệt huyết, tích cực, willing to learn, thì không sao hết, nhưng nếu như nhóm của bạn có những member *** thì nên chọn cái mô hình có workflow đơn giản hơn, để dễ quản lý.

Và cái mình đang chọn để quản lý version trong dự án của mình là cái này.

svn worlfow

Written with StackEdit.

PHÂN BIỆT QUẢN TRỊ VÀ QUẢN LÝ

PHÂN BIỆT QUẢN TRỊ VÀ QUẢN LÝ Hội đồng quản trị, tiếng Anh là BOD (Board Of Directors). Còn Ban giám đốc hay Ban quản lý tiếng Anh là BOM (B...