-
Notifications
You must be signed in to change notification settings - Fork 83
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(jans-cedarling): create uniffi binding for cedarling with sample ios app using it #10816
Conversation
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
jans-cedarling/bindings/cedarling_native_apps/iOSApp/iOSApp/context.json
Outdated
Show resolved
Hide resolved
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.
I see the Readme, but is there an impact on the docs?
Docs Added
I'd like @NazarYavornytskyy to review this PR, as he's the most experienced iOS developer on our team. |
Actually I don't really understand name |
Also, I see a lot of |
It is supposed to be Swift application or only lib to import to real application? |
request_id: &str, | ||
tag: &str, | ||
) -> Result<Vec<String>, LogError> { | ||
let mut result = Vec::new(); |
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.
We can allocate result with defined capacity. With length from result self.inner.get_logs_by_request_id_and_tag(request_id, tag)
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.
done
/// Return log entries that match the given request_id. | ||
#[uniffi::method] | ||
pub fn get_logs_by_request_id(&self, request_id: &str) -> Result<Vec<String>, LogError> { | ||
let mut result = Vec::new(); |
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.
We can allocate result with defined capacity
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.
done
/// Tag can be `log_kind`, `log_level`. | ||
#[uniffi::method] | ||
pub fn get_logs_by_tag(&self, tag: &str) -> Result<Vec<String>, LogError> { | ||
let mut result = Vec::new(); |
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.
We can allocate result with defined capacity
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.
done
//Get all log ids | ||
#[uniffi::method] | ||
pub fn get_log_ids(&self) -> Vec<String> { | ||
let mut result = Vec::new(); |
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.
We can allocate result with defined capacity
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.
done
// Retrieves logs and serializes them as JSON strings | ||
#[uniffi::method] | ||
pub fn pop_logs(&self) -> Result<Vec<String>, LogError> { | ||
let mut result = Vec::new(); |
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.
We can allocate result with defined capacity
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.
done
crate_type = ["cdylib", "staticlib"] | ||
name = "mobile" | ||
|
||
[dependencies] |
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.
done
Signed-off-by: duttarnab <[email protected]>
c981cd5
Signed-off-by: duttarnab <[email protected]>
|
||
// Struct to hold authorization result, compatible with iOS serialization | ||
#[derive(Debug, serde::Serialize, uniffi::Record)] | ||
pub struct AuthorizeResult { |
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.
I don't see how user can get request_id
https://github.com/JanssenProject/jans/blob/main/jans-cedarling/cedarling/src/authz/authorize_result.rs#L35C9-L35C19
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.
done
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
) -> Result<Self, RequestError> { | ||
// Validate tokens: ensure all values are non-empty after trimming | ||
let mut validated_tokens = HashMap::new(); | ||
for (key, value) in tokens.iter() { |
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.
Is it possible to use tokens.into_iter()
, and avoid cloning of key
?
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.
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.
Looks OK to me.
You can use next code snippet to avoid cargo error bindings/cedarling_uniffi/src/bin/uniffi-bindgen.rs
|
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
Signed-off-by: duttarnab <[email protected]>
closes #9432
Prepare
Description
Target issue
closes #issue-number-here
Implementation Details
Test and Document the changes
Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with
docs:
to indicate documentation changes or if the below checklist is not selected.