Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Add explicit MSI#70

Merged
lmazuel merged 7 commits intomasterfrom
explicit_msi
Dec 14, 2017
Merged

Add explicit MSI#70
lmazuel merged 7 commits intomasterfrom
explicit_msi

Conversation

@lmazuel
Copy link
Copy Markdown
Member

@lmazuel lmazuel commented Dec 13, 2017

@lmazuel lmazuel requested a review from yugangw-msft December 13, 2017 23:19


def get_msi_token(resource, port=50342):
def get_msi_token(resource, port=50342, client_id=None):
Copy link
Copy Markdown
Contributor

@yugangw-msft yugangw-msft Dec 13, 2017

Choose a reason for hiding this comment

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

FYI, msi's resource id and identity's service principal's object id are also supported

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I saw your email about this naming. Will wait for official suggestion before merging.

Copy link
Copy Markdown
Contributor

@yugangw-msft yugangw-msft left a comment

Choose a reason for hiding this comment

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

Left a few questions, LGTM otherwise


def _is_app_service():
# Might be discussed if we think it's not robust enough
return 'APPSETTING_WEBSITE_SITE_NAME' in os.environ
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not familiar with this env variable, but I know we have MSI_ENDPOINT and MSI_SECRET to leverage

Copy link
Copy Markdown
Member Author

@lmazuel lmazuel Dec 14, 2017

Choose a reason for hiding this comment

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

When I did the MSI sample of app service, I realized that I need first to detect if I'm on a WebApp. For that, MSI_ENDPOINT is not good (if MSI is not activated).
APPSETTING_WEBSITE_SITE_NAME is always there, it's a WebApp requirement. This makes possible to detect: if it's a WebApp, MSI_ENDPOINT is not there, tell the customer.

Copy link
Copy Markdown
Contributor

@yugangw-msft yugangw-msft Dec 14, 2017

Choose a reason for hiding this comment

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

Got it. I don't know whether APPSETTING_WEBSITE_SITE_NAME is reliable moving forward for both Linux and Windows. //CC: @panchagnula
My opinion was it is the client applications' responsibility to ensure the webapp was enabled with MSI before execute the code, so it is fine for our libraries to make such assumption on the existence of env varaibles

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lmazuel, verify in both linux and windows webapp, APPSETTING_WEBSITE_SITE_NAME does exist in both


:param str resource: The resource where the token would be use.
:param int port: The port is not the default 50342 is used.
:param dict[str, str] msi_conf: msi_conf if User Assigned (if not specified, assume System Assigned)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest wording of if to request a token through a user assigned identity. But up to you

super(MSIAuthentication, self).__init__(None)

self.port = port
self.msi_conf = {k:v for k,v in kwargs.items() if k in ["client_id", "object_id", "msi_res_id"]}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

still debating a bit, but to get interface clear, we should throw when user assigned identity info is supplied for a webapp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's do that for now, but I won't be surprised if this comes to WebApp at some point...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done (see last commit)

Copy link
Copy Markdown
Contributor

@yugangw-msft yugangw-msft left a comment

Choose a reason for hiding this comment

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

I cc'd Sisira for the right env variable we can depend on.


def _is_app_service():
# Might be discussed if we think it's not robust enough
return 'APPSETTING_WEBSITE_SITE_NAME' in os.environ
Copy link
Copy Markdown
Contributor

@yugangw-msft yugangw-msft Dec 14, 2017

Choose a reason for hiding this comment

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

Got it. I don't know whether APPSETTING_WEBSITE_SITE_NAME is reliable moving forward for both Linux and Windows. //CC: @panchagnula
My opinion was it is the client applications' responsibility to ensure the webapp was enabled with MSI before execute the code, so it is fine for our libraries to make such assumption on the existence of env varaibles

@panchagnula
Copy link
Copy Markdown

CC:@ahmedelnably can you comment on the 'APPSETTING_WEBSITE_SITE_NAME' setting if that is a reliable setting we can use.

@ahmedelnably
Copy link
Copy Markdown

@panchagnula App Service always set the 'APPSETTING_WEBSITE_SITE_NAME' we should be able to reliably use it

@lmazuel
Copy link
Copy Markdown
Member Author

lmazuel commented Dec 14, 2017

Thanks for your confirmation @ahmedelnably @panchagnula !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants