Skip to main content

CasAuthPlugin

Struct CasAuthPlugin 

Source
pub struct CasAuthPlugin {
    idp_uri: String,
    service: Option<String>,
    ticket_param: String,
    ssl_verify: bool,
    timeout: Duration,
    sealer: Option<CookieSealer>,
    cookie_name: String,
    cookie_path: String,
    cookie_lifetime: u64,
    logout_path: Option<String>,
    client: Arc<OutboundClient>,
}
Expand description

Validates CAS service tickets and, in interactive mode, runs the SSO flow.

Fields§

§idp_uri: String

CAS server base URI (e.g. https://cas.example.org/cas).

§service: Option<String>

Service URL sent to /serviceValidate; when unset it is derived from the request (scheme://host/path). Must match the service the ticket was issued for, so an explicit value is strongly recommended.

§ticket_param: String

Query parameter the ticket is read from (default ticket).

§ssl_verify: bool

Whether the CAS server’s TLS certificate is verified.

§timeout: Duration

Whole-call deadline for the validation callout.

§sealer: Option<CookieSealer>

When set, interactive SSO login is enabled and this seals/opens the session cookie. None keeps the stateless ticket-validator behavior.

§cookie_name: String

Name of the session cookie (interactive mode).

§cookie_path: String

Path attribute of the session cookie (interactive mode). Scope it to a subpath (e.g. /app_a) so nodes on distinct subpaths keep independent sessions. Defaults to /.

§cookie_lifetime: u64

Session cookie lifetime in seconds (interactive mode).

§logout_path: Option<String>

Optional logout path; a request to it clears the session cookie.

§client: Arc<OutboundClient>

Implementations§

Source§

impl CasAuthPlugin

Source

pub fn from_config( config: &HashMap<String, Value>, resources: &Arc<PluginResources>, ) -> Result<Self, String>

Builds the plugin from node config.

Accepted keys:

  • idp_uri (string, required): CAS server base URI. The validation request goes to <idp_uri>/serviceValidate.
  • service (string, optional): service URL passed to /serviceValidate. When omitted it is derived from the request scheme/host/path; because CAS requires the validated service to match the login service, set this explicitly whenever the gateway sits behind a proxy.
  • ticket_param (string, default "ticket"): query parameter carrying the CAS service ticket.
  • ssl_verify (bool, default true): verify the CAS server TLS cert.
  • timeout_ms (u64, default 3000): callout deadline.

Interactive-mode keys (present ⇒ interactive login is enabled):

  • session_secret (string) or session.secret (string): signing/encryption secret for the session cookie. Setting it turns on the SSO flow.
  • session.cookie.name (string, default "cas_session"): session cookie name.
  • session.cookie.path (string, default "/"): session cookie Path; scope to a subpath (e.g. /app_a) for independent per-app sessions.
  • session.cookie.lifetime (u64 seconds, default 3600): cookie lifetime.
  • logout_path (string, optional): request path that clears the session cookie and redirects to /.
type: cas-auth
config:
  idp_uri: https://cas.example.org/cas
  service: https://app.example.org/
  ssl_verify: true
  session:
    secret: ${CAS_SESSION_SECRET}
    cookie: { name: cas_session, lifetime: 3600 }
Source

fn reject( &self, ctx: Context, message: &str, ) -> Result<PluginOutput, PluginExecutionError>

Builds a 401 rejection routed through the node’s error port.

Source

fn redirect( &self, ctx: Context, location: String, set_cookies: Vec<String>, ) -> Result<PluginOutput, PluginExecutionError>

Builds a 302 early-exit carrying the prepared response. Wire the node’s error edge to client.in so this reaches the browser.

Source

fn service_url(&self, ctx: &Context) -> String

The service URL sent to /serviceValidate: the configured value, or one derived from the request (scheme://host/path, without the query so the ticket is dropped).

Source

fn session_attrs(&self, ctx: &Context) -> CookieAttrs<'_>

Cookie attributes for the session cookie: HttpOnly, SameSite=Lax, and Secure only over HTTPS (so plain-HTTP dev works).

Source

fn attach_user(&self, ctx: &mut Context, user: &str)

Attaches the authenticated user to the request/context.

Source

fn read_session(&self, ctx: &Context) -> Option<String>

Reads and opens the session cookie, returning the authenticated user.

Source

async fn cas_validate( &self, ctx: &Context, ticket: &str, ) -> Result<String, String>

Validates a CAS ticket against /serviceValidate, returning the user.

Source

async fn execute_interactive( &self, ctx: Context, ) -> Result<PluginOutput, PluginExecutionError>

Interactive SSO flow: session cookie → callback → begin login.

Source

async fn execute_stateless( &self, ctx: Context, ) -> Result<PluginOutput, PluginExecutionError>

Stateless ticket validation (the default, pre-interactive behavior).

Trait Implementations§

Source§

impl Plugin for CasAuthPlugin

Source§

fn plugin_type(&self) -> &str

Unique identifier for the plugin type (e.g., “proxy-rewrite”, “upstream”).
Source§

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, ctx: Context, _named_inputs: &'life1 HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Executes the plugin logic against the request/response context. Read more

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> MaybeSend for T