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

[HERMES-5354] Add userScopes to ISlackManifestShared #189

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

srajiang
Copy link
Member

@srajiang srajiang commented Jul 10, 2023

Summary

Adds the userScopes property to the ISlackManifestShared interface.
Ask from BE folks to enable authoring app manifest that use built-ins with user-delegated auth.

Context thread

Changes:

  • Moves userScopes property to the ISlackManifestShared interface and sets the value on Manifest if not empty
  • Normally Run on Slack apps have token_management_enabled defaulted to false on behalf of the developer. But in the case where user scopes are requested, the backend requires token_management_enabled to be set to true. So I have modified the SDK behavior to default to setting the value to true only when there's at least one user scope defined.

Requirements (place an x in each [ ])

@srajiang srajiang requested a review from a team as a code owner July 10, 2023 05:32
@srajiang srajiang self-assigned this Jul 10, 2023
@@ -60,26 +60,26 @@ export interface ISlackManifestRemote extends ISlackManifestShared {
socketModeEnabled?: boolean;
tokenRotationEnabled?: boolean;
appDirectory?: ManifestAppDirectorySchema;
userScopes?: Array<string>;
Copy link
Member Author

Choose a reason for hiding this comment

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

No longer needed here since we're moving it up to the shared interface.

Copy link
Contributor

@filmaj filmaj 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 couple of questions.

src/manifest/mod.ts Outdated Show resolved Hide resolved
src/manifest/mod.ts Show resolved Hide resolved
Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

Good changes 💯 just had one query

true,
);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this file defines botScopes: [] in many tests 🤔
Should we also define userScopes:[] in those tests as well @filmaj ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like for the tests to use definition variables that reflect how end-users would craft their own manifest definitions. In my own experience creating manifest definitions, I would omit the property altogether if I'm not using it. However, devs do the darndest things! I think we should guard against common JS-y/TS-y pitfalls such as what counts as truthy vs. falsy, like empty arrays and empty strings. Therefore, I would recommend the Manifest() constructor clean user-provided definitions up into a state that the Slack manifest APIs expect as a baseline.

@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Merging #189 (8eda211) into main (abd4e33) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #189   +/-   ##
=======================================
  Coverage   99.23%   99.23%           
=======================================
  Files          55       55           
  Lines        2084     2084           
  Branches      115      115           
=======================================
  Hits         2068     2068           
  Misses         15       15           
  Partials        1        1           
Impacted Files Coverage Δ
src/manifest/mod.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

manifest.oauth_config.token_management_enabled = false;
// Oauth Config
// Run On Slack manage their own tokens
// if and only if at least one user scope is included in the manifest
Copy link

@jpbrabec jpbrabec Jul 10, 2023

Choose a reason for hiding this comment

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

I'm not sure I understand this-- Adding scopes in the manifest should not require apps to use token management, right? In general I don't think any ROSI apps needs token management, right? Having token management enabled would mean the app needs to provide an oauth token server, which ROSI apps cannot do. Is there an issue we're trying to solve with this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jpbrabec - This was also something I'm also unsure about, so thanks for weighing in.

Adding scopes in the manifest should not require apps to use token management.

I get this error when adding user scopes to the manifest and leaving token_management_enabled: false:
Screenshot 2023-07-09 at 10 04 52 PM

Is this error expected?

Copy link

@jpbrabec jpbrabec Jul 10, 2023

Choose a reason for hiding this comment

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

Ah, that's for user scopes specifically (not bot scopes). Hermes apps do not support user scopes at all right now, so this error is basically here to say "You can't be a hermes ROSI app and use user scopes at the same time". We can chat in slack about future plans for this area.

Choose a reason for hiding this comment

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

@jpbrabec are you open to me changing the error to be able to bypass it if Hermes User Delegated Auth Houston FF is in place

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.

None yet

5 participants