Skip to content

WIP POP improvements#2070

Closed
trwalke wants to merge 1 commit into
masterfrom
trwalke/PopPart2
Closed

WIP POP improvements#2070
trwalke wants to merge 1 commit into
masterfrom
trwalke/PopPart2

Conversation

@trwalke

@trwalke trwalke commented Sep 30, 2020

Copy link
Copy Markdown
Member

for #2013

Exposing ICrypto provider to allow users to pass in their own
@trwalke trwalke changed the title POP improvements WIP POP improvements Sep 30, 2020
@trwalke trwalke requested a review from bgavrilMS September 30, 2020 23:57
/// </summary>
/// <param name="uri">Protected resource URL.</param>
/// <returns></returns>
public T WithProofOfPosessionUri(Uri uri)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this strategy of piling on options on the AcquireToken* method because it "polutes" . There will be at least 4 params on SHR -> 4 methods on each AcqurieToken* entry point.

Instead, you can add a simple config object, similar to

public AcquireTokenInteractiveParameterBuilder WithSystemWebViewOptions(SystemWebViewOptions options)

So we could have a single method:

WithPoP(PoPOptions options = null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main question here is - what should the default be here? I would argue for a secure default, where POP takes into account the method (GET / POST) and the url ...

{
if (CommonParameters.PopUri == null )
{
throw new MsalClientException(MsalError.PopUriCannotBeNull, "Proof of possesion endpoint is null.");

@bgavrilMS bgavrilMS Oct 1, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uri is not mandatory as far as I understand. Please check with Brian / George.
So the user has the ability to say "don't bind the uri to the pop token"

throw new MsalClientException(MsalError.PopUriCannotBeNull, "Proof of possesion endpoint is null.");
}

HttpRequestMessage message = new HttpRequestMessage(CommonParameters.PopMethod != null ? CommonParameters.PopMethod : HttpMethod.Get,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this isn't how it's supposed to work. The user has the ability to say "don't bind the method to the pop token".

/// </summary>
/// <param name="popCryptoProvider"> Proof of posession cryptography provider</param>
/// <returns></returns>
public T WithPopCryptoProvider(IPoPCryptoProvider popCryptoProvider)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are trying to tackle 2 stories at the same time, which makes it difficult to implement and review:

  1. Expose the crypto details to the user
  2. Make the method and uri optional

I don't think you should tackle #2 right now, nobody asked for it and it will complicate things.

/// </summary>
/// <param name="popCryptoProvider"> Proof of posession cryptography provider</param>
/// <returns></returns>
public T WithPopCryptoProvider(IPoPCryptoProvider popCryptoProvider)

@bgavrilMS bgavrilMS Oct 1, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think IPoPCryptoProvider is too low level and a higher level abstraction should be exposed to the user.

To help figure out the best solution, I would recommend you try to create 2 implementations that will help our users:

  1. An implementation of this interface that uses an X509Certificate2
  2. An implementation of this interfaces that uses ECD encyrption instead of RSA

Also, I believe that this public API should be discussed with Brian and George as well.

@bgavrilMS bgavrilMS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"bring your own encryption" public API needs more work.

@trwalke trwalke closed this Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants