-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make non-json isAuthorized and validate public, rework wasm interfaces
Signed-off-by: Nick Szegheo <nicholas.szegheo@gmail.com>
- Loading branch information
Showing
11 changed files
with
125 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
//! This module contains the entry point to the wasm isAuthorized functionality. | ||
use cedar_policy::frontend::{is_authorized::json_is_authorized, utils::InterfaceResult}; | ||
|
||
use cedar_policy::frontend::is_authorized::{ | ||
is_authorized, AuthorizationAnswer, AuthorizationCall, InterfaceResponse, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use tsify::Tsify; | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen(js_name = isAuthorized)] | ||
pub fn wasm_is_authorized(input: &str) -> InterfaceResult { | ||
json_is_authorized(input) | ||
#[derive(Tsify, Debug, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
#[tsify(into_wasm_abi, from_wasm_abi)] | ||
pub enum AuthorizationResult { | ||
Success { response: InterfaceResponse }, | ||
Error { errors: Vec<String> }, | ||
} | ||
|
||
#[wasm_bindgen(js_name = "isAuthorized")] | ||
pub fn wasm_is_authorized(call: AuthorizationCall) -> AuthorizationResult { | ||
match is_authorized(call) { | ||
AuthorizationAnswer::Success { response } => AuthorizationResult::Success { response }, | ||
AuthorizationAnswer::Failure { errors } => AuthorizationResult::Error { errors }, | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.