feat(core): dynamic runtime capability#9036
Merged
lucasfernog merged 4 commits intodevfrom Mar 1, 2024
Merged
Conversation
amrbashir
requested changes
Feb 29, 2024
| let identifier = permission | ||
| .clone() | ||
| .try_into() | ||
| .unwrap_or_else(|_| panic!("invalid permission identifier '{permission}'")); |
Member
There was a problem hiding this comment.
I would try to avoid panicking and return a result instead
core/tauri/src/ipc/authority.rs
Outdated
| .into_iter() | ||
| .map(|a| { | ||
| serde_json::to_value(a) | ||
| .expect("failed to serialize scope") |
core/tauri/src/ipc/authority.rs
Outdated
| .into_iter() | ||
| .map(|a| { | ||
| serde_json::to_value(a) | ||
| .expect("failed to serialize scope") |
Member
Author
|
@amrbashir it's quite rare for those functions to panic (most identifiers are valid, and it's also almost impossible for serde_json::to_value to fail) and I don't really like the pattern of returning Result in a builder |
Member
|
That's fair I guess |
amrbashir
approved these changes
Feb 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some capabilities must be dynamic (e.g. allow a dynamically started localhost server, runtime-defined remote URLs, fine-grained permissions that depend on user configuration like access token scopes..). This can be done already by creating a string at runtime and leaking it so it becomes a &'static str, but it's not ideal so we now support both runtime strings and added a new capability builder aswell so you can either
include_str!()a static capability file or create/modify one at runtime.