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

[feat] conditionally add capabilities #8798

Closed
lucasfernog opened this issue Feb 6, 2024 · 0 comments
Closed

[feat] conditionally add capabilities #8798

lucasfernog opened this issue Feb 6, 2024 · 0 comments

Comments

@lucasfernog
Copy link
Member

lucasfernog commented Feb 6, 2024

Describe the problem

The current capability design automatically pulls every capability file and resolves to the app runtime authority. While this is a good approach for developer experience, it is static and does not support more dynamic applications such as:

  • nightly releases including new features
  • feature-flag based multi application mode (for instance an admin vs user shared app that uses Cargo features to toggle what is compiled)
  • debug-only plugins (like developer productivity tools)

Describe the solution you'd like

we should add an option to define capabilities in Rust code. Ideally this should still be done at compile time. Since the current capabilities resolution is done in the Context generation, we could extend it to allow defining capabilities conditionally:

tauri::generate_context!(
  capabilities = [
	  #[cfg(debug_assertions)]
	  "./capabilities/debug.json",
	  #[cfg(feature = "admin")]
	  "./capabilities/admin.json",
  ]
)

#8797 implements the first step for this feature, without that change users need to define conditionally added capabilities in a separate folder otherwise they would be enabled automatically.

Alternatives considered

We could also allow defining the capability at runtime instead, but I'll open a separate issue for that one.

Additional context

No response

lucasfernog added a commit that referenced this issue Feb 19, 2024
* refactor(core): capabilities must be referenced on the Tauri config file

* add all capabilities by default

* feat(codegen): allow defining additional capabilities, closes #8798

* undo example

* lint

* move add_capability to runtime authority

* feat(core): add Manager::add_capability, closes #8799

* add change file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant