-
Notifications
You must be signed in to change notification settings - Fork 8
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(admin-api): enable auth headers for admin api routes #354
Conversation
WalkthroughThe changes encompass restructuring route logic in the Changes
Poem
Note Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://coderabbit.ai TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
a3df7c1
to
8a63ec3
Compare
948cceb
to
22a9d53
Compare
813c7fe
to
76330b9
Compare
@MatejVukosav are we ok with this? |
@@ -118,6 +118,7 @@ export function LoginWithMetamask({ | |||
walletSignature: signData, | |||
payload: walletSignatureData?.payload, | |||
walletMetadata: walletMetadata, | |||
contextId: applicationId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, when I think more about it, I think it will not work. We don't know the context id during login. We only know the application id... and multiple contexts can use the same application
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will work when context id replaces application id. When this happens we can just put context id in envs of application e.g. only peers client.
Right now this works when you pass application id as context id and apart from checking if the header exists there are no other tests with context_id. This new field is only used in context details > client keys so it does not break anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you don't know context upfront
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what do you propose should be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets wait for Mira to deploy context and then we can check it. I think we will need to remove client keys from context and bring them to level of root keys, independent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @miraclx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the admin ui and it works
@xilosada not yet |
@@ -47,27 +49,18 @@ pub(crate) fn setup( | |||
let session_layer = SessionManagerLayer::new(session_store).with_secure(false); | |||
|
|||
let shared_state = Arc::new(AdminState { | |||
store, | |||
store: store.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if this will work across multiple calls. We had some issues with cloning store before but can't recall exactly what was it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just test it all together
🚀 |
feat(admin-api): enable auth headers for admin api routes
Summary
In this PR admin API routes were split into two different routers.
One router is protected routes which should be always protected, and unprotected routes which should not be protected when there are no root keys saved in the DID.
Unprotected routes:
Once the DID has saved root_key, auth layer is also applied to unprotected routes.
Requires adding auth headers to calimero sdk and admin dashboard
Summary by CodeRabbit
New Features
APP_URL
and functions for managing application endpoints instorage.ts
.auth/headers.ts
.package.json
.Refactor
admin/service.rs
with new routers and function imports.nodeApi.ts
to include acontextId
field.admin/service.rs
.Documentation
package.json
and other files.