Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-4528 - Allow API keys for cloud apis + allow users to specify app url #424

Merged
merged 3 commits into from
Sep 7, 2023

Conversation

cheukt
Copy link
Member

@cheukt cheukt commented Sep 6, 2023

RSDK-4528

location_id can apparently be none in app_client, so no changes needed there
allowing users to specify app url will make it easier for testing and stuff

@cheukt cheukt requested a review from a team as a code owner September 6, 2023 21:53
@cheukt cheukt requested review from clintpurser and removed request for clintpurser September 6, 2023 21:53
@cheukt cheukt changed the title Allow API keys for cloud apis + allow users to specify app url RSDK-4528 - Allow API keys for cloud apis + allow users to specify app url Sep 6, 2023
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

One q, otherwise lgtm.

if dial_options.credentials.type == "robot-location-secret":
self._location_id = dial_options.auth_entity.split(".")[1]
if app_url is None:
app_url = "https://app.viam.com"
Copy link
Member

Choose a reason for hiding this comment

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

(q) previously we were using "app.viam.com:443" as a hardcoded value, rather than "https://app.viam.com". is this change meaningful?

Copy link
Member Author

Choose a reason for hiding this comment

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

not particularly, but figured specifying https:// is slightly better than specifying the port number

Copy link
Member Author

Choose a reason for hiding this comment

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

tho neither is necessary, I could make it just app.viam.com if that's better

@@ -30,7 +30,7 @@ class Credentials:
Currently only supports robot location secret.
Copy link
Member

Choose a reason for hiding this comment

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

[minor] looks like we can remove this line. Yay!

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@@ -30,7 +30,7 @@ class Credentials:
Currently only supports robot location secret.
"""

type: Union[Literal["robot-location-secret"], Literal["robot-secret"]]
type: Union[Literal["robot-location-secret"], Literal["robot-secret"], Literal["api-key"]]
Copy link
Member

Choose a reason for hiding this comment

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

[q] Should we add validation on this field such that users would get an error if they supplied a bad literal/typo? I'm surprised I was able to supply the api-key string in the original org API key PR without hitting any errors.

Copy link
Member Author

@cheukt cheukt Sep 7, 2023

Choose a reason for hiding this comment

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

it's just a type hint right now, so no error - the idea was that users could supply other cred types as the server changes without changes in the SDK, which I think is nicer - the server can/will reject if the type is incorrect anyway. I do think we could perhaps prepopulate these types, but out of scope for now (https://viam.atlassian.net/browse/RSDK-4756 could/should handle this better)

Comment on lines +317 to +318
async def _dial_app(app_url: str) -> Channel:
return await _dial_direct(app_url)
Copy link
Member

Choose a reason for hiding this comment

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

[q] I see that above in this file we do:

    host, port = _host_port_from_url(address)
    if not port:
        port = 80 if insecure else 443
    server_hostname = host

Should we maybe have it default to 8080? Were you able to test this both with localhost:8080 as well as http://localhost? I am not sure if it would work for the latter option as-is but haven't tested. We could potentially match on the string localhost (rather than requiring the http:// prefix) and hardcode 8080 in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

localhost:8080 definitely works, so does http://localhost if I update the default to be 8080. I think we kept it as 80 because that's default insecure port

Copy link
Member

Choose a reason for hiding this comment

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

ok! I'm not sure I follow why keeping it as 80 as desirable but I'm sure I'm lacking a lot of context here. Going to hit approve. Thank you!

@cheukt cheukt requested a review from ohEmily September 7, 2023 17:49
@cheukt cheukt merged commit e5d6ca9 into viamrobotics:main Sep 7, 2023
5 checks passed
@cheukt cheukt deleted the cloud-apis-api-key branch September 7, 2023 20:55
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.

3 participants