How can I do custom authentication in python?

719 views
Skip to first unread message

Yan Yan

unread,
May 20, 2016, 8:35:58 AM5/20/16
to grpc.io
How can I do this kind of authentication for each connection?
How can I do this kind of authentication for each call?
Where do I put that if(inputUsername == dbUsername && inputPassword == dbPassword) statement? And return a boolean?
Can I do it without encryption? I understand that plain text is insecure. Thx.

- authDb.txt
user01,password01
user02,password02

Yan Yan

unread,
May 22, 2016, 3:50:43 AM5/22/16
to grpc.io
How could I use them in python and C++? Any sample code? Thx.


jboeuf commented 2 days ago

We now have APIs to do this:

  1. Client Side: create your own credentials with the credentials metadata plugin API:
    https://github.com/grpc/grpc/blob/master/include/grpc/grpc_security.h#L292

  2. Server Side interceptor: auth metadata processor:
    https://github.com/grpc/grpc/blob/master/include/grpc/grpc_security.h#L383

Nathaniel Manista

unread,
May 22, 2016, 2:01:35 PM5/22/16
to Yan Yan, grpc.io
On Fri, May 20, 2016 at 5:35 AM, Yan Yan <lamh...@gmail.com> wrote:
How can I do this kind of authentication for each connection?
How can I do this kind of authentication for each call?

What kind of authentication is "this kind of authentication"? If you're writing about an authentication protocol that is entirely your own, I suspect that metadata is the right place to put the data that it needs to be transmitted.

Where do I put that if(inputUsername == dbUsername && inputPassword == dbPassword) statement? And return a boolean?

Perhaps in a utility function called at the start of each of your servicer methods?

Can I do it without encryption?

Perhaps; it might depend on how your authentication protocol is intended to function.

I understand that plain text is insecure. Thx.

Thanks for asking.
-Nathaniel

Yan Yan

unread,
May 22, 2016, 6:20:03 PM5/22/16
to grpc.io, lamh...@gmail.com
I know that user+pass is discouraged, but I have this requirement from the client. HTTP basic auth is not supported either. I am resorting to putting user+pass as some form of metadata. Thx.

Yan Yan

unread,
May 22, 2016, 7:06:49 PM5/22/16
to grpc.io, lamh...@gmail.com


On Monday, May 23, 2016 at 2:01:35 AM UTC+8, Nathaniel Manista wrote:

digit...@gmail.com

unread,
Aug 14, 2019, 5:29:37 AM8/14/19
to grpc.io
Hi,
    Will this help if client wants to custom verify the server certificate. Is there any sample?

Client Side: create your own credentials with the credentials metadata plugin API:

Lidi Zheng

unread,
Aug 14, 2019, 1:09:30 PM8/14/19
to digit...@gmail.com, grpc.io
If you are looking for metadata extensions, can you take a look at this Python example: https://github.com/grpc/grpc/tree/master/examples/python/auth

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/cc5a118d-196b-486f-8a37-99f94f438ebc%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages