Struct wasm_oidc_plugin::discovery::OidcDiscovery

source ·
pub struct OidcDiscovery {
    pub state: OidcRootState,
    waiting: Mutex<Vec<u32>>,
    token_id: Option<u32>,
}
Expand description

This context is responsible for getting the OIDC configuration, jwks keys and setting the http context.

Fields§

§state: OidcRootState

The state of the root context. This is an enum which has the following variants:

  • Uninitialized: The plugin is not yet configured
  • LoadingConfig: The plugin configuration is being loaded
  • LoadingJwks: The jwks configuration is being loaded
  • Ready: The plugin is ready
§waiting: Mutex<Vec<u32>>

Queue of waiting requests which are waiting for the configuration to be loaded

§token_id: Option<u32>

token_id of the HttpCalls to verify the call is correct

Implementations§

source§

impl OidcDiscovery

source

pub fn evaluate_config( plugin_config: PluginConfiguration, ) -> Result<(), PluginError>

Evaluate the plugin configuration and check if the values are valid. Type checking is done by serde, so we only need to check the values.

  • plugin_config - The plugin configuration to be evaluated Returns Ok if the configuration is valid, otherwise Err with a message.

Trait Implementations§

source§

impl Context for OidcDiscovery

The context is used to process the response from the OIDC config endpoint and the jwks endpoint. It also utilized the state enum to determine what to do with the response.

  1. If the state is Uninitialized, the plugin is not initialized and the response is ignored.
  2. If the state is LoadingConfig, the open id configuration is expected.
  3. If the state is LoadingJwks, the jwks endpoint is expected.
  4. Ready is not expected, as the root context doesn’t dispatch any calls in that state.
source§

fn on_http_call_response( &mut self, token_id: u32, _num_headers: usize, _body_size: usize, _num_trailers: usize, )

Called when the response from the http call is received. It also utilised the state enum to determine what to do with the response.

  1. If the state is Uninitialized, the plugin is not initialized and the response is ignored.
  2. If the state is LoadingConfig, the open id configuration is expected.
  3. If the state is LoadingJwks, the jwks endpoint is expected.
  4. Ready is not expected, as the root context doesn’t dispatch any calls in that state.
source§

fn get_current_time(&self) -> SystemTime

source§

fn get_property(&self, path: Vec<&str>) -> Option<Vec<u8>>

source§

fn set_property(&self, path: Vec<&str>, value: Option<&[u8]>)

source§

fn get_shared_data(&self, key: &str) -> (Option<Vec<u8>>, Option<u32>)

source§

fn set_shared_data( &self, key: &str, value: Option<&[u8]>, cas: Option<u32>, ) -> Result<(), Status>

source§

fn register_shared_queue(&self, name: &str) -> u32

source§

fn resolve_shared_queue(&self, vm_id: &str, name: &str) -> Option<u32>

source§

fn dequeue_shared_queue(&self, queue_id: u32) -> Result<Option<Vec<u8>>, Status>

source§

fn enqueue_shared_queue( &self, queue_id: u32, value: Option<&[u8]>, ) -> Result<(), Status>

source§

fn dispatch_http_call( &self, upstream: &str, headers: Vec<(&str, &str)>, body: Option<&[u8]>, trailers: Vec<(&str, &str)>, timeout: Duration, ) -> Result<u32, Status>

source§

fn get_http_call_response_headers(&self) -> Vec<(String, String)>

source§

fn get_http_call_response_headers_bytes(&self) -> Vec<(String, Vec<u8>)>

source§

fn get_http_call_response_header(&self, name: &str) -> Option<String>

source§

fn get_http_call_response_header_bytes(&self, name: &str) -> Option<Vec<u8>>

source§

fn get_http_call_response_body( &self, start: usize, max_size: usize, ) -> Option<Vec<u8>>

source§

fn get_http_call_response_trailers(&self) -> Vec<(String, String)>

source§

fn get_http_call_response_trailers_bytes(&self) -> Vec<(String, Vec<u8>)>

source§

fn get_http_call_response_trailer(&self, name: &str) -> Option<String>

source§

fn get_http_call_response_trailer_bytes(&self, name: &str) -> Option<Vec<u8>>

source§

fn dispatch_grpc_call( &self, upstream_name: &str, service_name: &str, method_name: &str, initial_metadata: Vec<(&str, &[u8])>, message: Option<&[u8]>, timeout: Duration, ) -> Result<u32, Status>

source§

fn on_grpc_call_response( &mut self, _token_id: u32, _status_code: u32, _response_size: usize, )

source§

fn get_grpc_call_response_body( &self, start: usize, max_size: usize, ) -> Option<Vec<u8>>

source§

fn cancel_grpc_call(&self, token_id: u32)

source§

fn open_grpc_stream( &self, cluster_name: &str, service_name: &str, method_name: &str, initial_metadata: Vec<(&str, &[u8])>, ) -> Result<u32, Status>

source§

fn on_grpc_stream_initial_metadata( &mut self, _token_id: u32, _num_elements: u32, )

source§

fn get_grpc_stream_initial_metadata(&self) -> Vec<(String, Vec<u8>)>

source§

fn get_grpc_stream_initial_metadata_value(&self, name: &str) -> Option<Vec<u8>>

source§

fn send_grpc_stream_message( &self, token_id: u32, message: Option<&[u8]>, end_stream: bool, )

source§

fn on_grpc_stream_message(&mut self, _token_id: u32, _message_size: usize)

source§

fn get_grpc_stream_message( &mut self, start: usize, max_size: usize, ) -> Option<Vec<u8>>

source§

fn on_grpc_stream_trailing_metadata( &mut self, _token_id: u32, _num_elements: u32, )

source§

fn get_grpc_stream_trailing_metadata(&self) -> Vec<(String, Vec<u8>)>

source§

fn get_grpc_stream_trailing_metadata_value(&self, name: &str) -> Option<Vec<u8>>

source§

fn cancel_grpc_stream(&self, token_id: u32)

source§

fn close_grpc_stream(&self, token_id: u32)

source§

fn on_grpc_stream_close(&mut self, _token_id: u32, _status_code: u32)

source§

fn get_grpc_status(&self) -> (u32, Option<String>)

source§

fn call_foreign_function( &self, function_name: &str, arguments: Option<&[u8]>, ) -> Result<Option<Vec<u8>>, Status>

source§

fn on_done(&mut self) -> bool

source§

fn done(&self)

source§

impl RootContext for OidcDiscovery

The root context is used to create new HTTP contexts and load configuration from the open id discovery endpoint and the jwks endpoint. When on_configure is called, the plugin configuration is loaded and the state is set to LoadingConfig. The filter is then ticked immediately to load the configuration. When on_http_call_response is called, the Open ID response is parsed and the state is set to LoadingJwks. On the next tick, the jwks endpoint is called and the state is set to Ready once the jwks response is received and successfully parsed.

source§

fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool

Called when proxy is being configured. This is where the plugin configuration is loaded and the next state is set.

source§

fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>>

Creates the http context with the information from the open_id_config and the plugin configuration. This is called whenever a new http context is created by the proxy. When the plugin is not yet ready, the http context is created in Unconfigured state and the context id is added to the waiting queue to be processed later.

source§

fn on_tick(&mut self)

The root context is ticking every 400 millis as long as the configuration is not loaded yet. On every tick, the state is checked and the corresponding action is taken.

  1. If the state is Uninitialized, the configuration is loaded from the plugin configuration.
  2. If the state is LoadingConfig, the configuration is loaded from the openid configuration endpoint.
  3. If the state is LoadingJwks, the public key is loaded from the jwks endpoint.
  4. If the state is Ready, the configuration is reloaded.
source§

fn get_type(&self) -> Option<ContextType>

This is one of those functions that need to be there for some reason but we are not sure why. It just doesn’t work without it.

source§

fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool

source§

fn get_vm_configuration(&self) -> Option<Vec<u8>>

source§

fn get_plugin_configuration(&self) -> Option<Vec<u8>>

source§

fn set_tick_period(&self, period: Duration)

source§

fn on_queue_ready(&mut self, _queue_id: u32)

source§

fn on_log(&mut self)

source§

fn create_stream_context( &self, _context_id: u32, ) -> Option<Box<dyn StreamContext>>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V