python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

Support for Certificate based Authentication

Open metalshanked opened this issue 3 years ago • 18 comments

Hi, Is there a plan for supporting certification based auth as well?

Here is a link for an example implementation https://github.com/Azure-Samples/ms-identity-python-daemon/blob/master/2-Call-MsGraph-WithCertificate/confidential_client_certificate_sample.py

Seems like many folks are moving to cert based auth for the GRAPH API

Thanks!!

metalshanked avatar Feb 02 '21 15:02 metalshanked

There are no plan to develop this... unless somebody adds this as a PR,

alejcas avatar Feb 02 '21 16:02 alejcas

Hey @janscas , I think certificate based auth is an awesome way to help rid the world of wandering API keys and increase the trust of using this library. I would love to see this as part of the package :)

Thanks!

AlonSh avatar Feb 22 '21 08:02 AlonSh

I have no time to add this right now. PR are very welcome tho!

Thanks

alejcas avatar Feb 22 '21 20:02 alejcas

Hi, I am exploring adding this feature. @janscas , what do you think of adding msal as a dependency and using it for authentication?

kwollaston avatar Feb 23 '21 05:02 kwollaston

@kwollaston Hi, any updates about the certificate based authentication feature? Thanks.

korengrip avatar Apr 21 '21 15:04 korengrip

Hi, I am exploring adding this feature. @janscas , what do you think of adding msal as a dependency and using it for authentication?

I'm not against it.

Do you think it could be added without much changes?

alejcas avatar Apr 21 '21 23:04 alejcas

@janscas I have gotten it working and with relatively minimal changes. The thing I was on last was adjusting the token backend to work with MSAL. I just had a new baby, so I don't have much time at the moment. I will try to get it on my fork and notify you all here.

Maybe you or someone else will be able to run with it if I can't find some time soon.


From: Alejandro Casanovas @.***> Sent: Wednesday, April 21, 2021, 4:24 PM To: O365/python-o365 Cc: Kyle Wollaston; Mention Subject: Re: [O365/python-o365] Support for Certificate based Authentication (#570)

Hi, I am exploring adding this feature. @janscashttps://github.com/janscas , what do you think of adding msalhttps://github.com/AzureAD/microsoft-authentication-library-for-python as a dependency and using it for authentication?

I'm not against it.

Do you think it could be added without much changes?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/O365/python-o365/issues/570#issuecomment-824428439, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHQODZRQRWRNTOFJAIPSXTTJ5NEFANCNFSM4W63H53Q.

kwollaston avatar Apr 21 '21 23:04 kwollaston

@janscas Should we create a MSAL branch?

Sent from my T-Mobile 4G LTE Device Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Kyle Wollaston @.> Sent: Wednesday, April 21, 2021 4:30:41 PM To: O365/python-o365 @.>; O365/python-o365 @.> Cc: Mention @.> Subject: Re: [O365/python-o365] Support for Certificate based Authentication (#570)

@janscas I have gotten it working and with relatively minimal changes. The thing I was on last was adjusting the token backend to work with MSAL. I just had a new baby, so I don't have much time at the moment. I will try to get it on my fork and notify you all here.

Maybe you or someone else will be able to run with it if I can't find some time soon.


From: Alejandro Casanovas @.***> Sent: Wednesday, April 21, 2021, 4:24 PM To: O365/python-o365 Cc: Kyle Wollaston; Mention Subject: Re: [O365/python-o365] Support for Certificate based Authentication (#570)

Hi, I am exploring adding this feature. @janscashttps://github.com/janscas , what do you think of adding msalhttps://github.com/AzureAD/microsoft-authentication-library-for-python as a dependency and using it for authentication?

I'm not against it.

Do you think it could be added without much changes?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/O365/python-o365/issues/570#issuecomment-824428439, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHQODZRQRWRNTOFJAIPSXTTJ5NEFANCNFSM4W63H53Q.

kwollaston avatar Apr 21 '21 23:04 kwollaston

I don't have the time now to work on this but any help will be appreciated

alejcas avatar Apr 23 '21 11:04 alejcas

@kwollaston I can help with the PR, did you create a branch for MSAL?

DaniEzzeddine avatar May 18 '21 19:05 DaniEzzeddine

@DaniEzzeddine Please look at the commit here, I just dumped what I have in there. The branch is behind though https://github.com/kwollaston/python-o365/tree/msal

kwollaston avatar May 18 '21 20:05 kwollaston

Hi, are there any updates on this subject? Thanks

shellybendor avatar Jun 30 '21 15:06 shellybendor

@kwollaston @DaniEzzeddine - thanks for taking this up. Can you share the usage instructions for the msal version that @kwollaston started? Thanks!

metalshanked avatar Jan 13 '22 15:01 metalshanked

Hi @metalshanked, I will try to follow up this weekend!

-------- Original message -------- From: metalshanked @.> Date: 1/13/22 7:19 AM (GMT-08:00) To: O365/python-o365 @.> Cc: Kyle Wollaston @.>, Mention @.> Subject: Re: [O365/python-o365] Support for Certificate based Authentication (#570)

@kwollastonhttps://github.com/kwollaston @DaniEzzeddinehttps://github.com/DaniEzzeddine - thanks for taking this up? Can you share the usage instructions for the msal version that @kwollastonhttps://github.com/kwollaston started? Thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/O365/python-o365/issues/570#issuecomment-1012234098, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHQODYH5HCEQLK3L7KJG7LUV3UPXANCNFSM4W63H53Q. You are receiving this because you were mentioned.Message ID: @.***>

kwollaston avatar Jan 13 '22 15:01 kwollaston

Thanks @kwollaston ! appreciate it

metalshanked avatar Jan 13 '22 16:01 metalshanked

@metalshanked - Take a look at the diff for an idea, it wasn't a huge change although as mentioned we need to alter the token backend. MSAL uses it's own token cache

I was able to get it to work in the current state. Basically you set auth_flow_type to "certificate" and set credentials to a dict with keys "thumbprint", "private_key", and "client_id"

See here for more info.

kwollaston avatar Jan 17 '22 05:01 kwollaston

Thanks @kwollaston ! Will check it out. What would be the implications of the token backend not working?
Would we would need to add some logic to check expiry and refresh the token manually? (I am using Filesystem token backend)

metalshanked avatar Jan 17 '22 16:01 metalshanked

Any news here, possibly without requiring msal? Microsoft code just always feels so un-pythonic.

alfonsrv avatar Sep 30 '23 12:09 alfonsrv