async fn cas_authenticated(
    req: &HttpRequest,
    redir_path: String,
) -> Result<String, TelescopeError> {
    // Extract the CAS parameters from the query
    let Query(params): Query<CasAuthenticatedParameters> =
        Query::<CasAuthenticatedParameters>::extract(req)
            .await
            // Convert any errors that occur.
            .map_err(|err| {
                // Log the error
                error!(
                    "Could not extract CAS ticket from request parameters: {}",
                    err
                );

                // Display an error message to the user.
                TelescopeError::BadRequest {
                    header: "Malformed CAS request".into(),
                    message: format!(
                        "The RPI CAS endpoint did not respond with the appropriate \
                    data. Please try again. If this error persists, contact a coordinator and file \
                    an issue on Telescope's GitHub. Internal error: {}",
                        err
                    ),
                    show_status_code: true,
                }
            })?;

    // Make the query parameters to send to the CAS validation server
    let validation_params = CasIdentificationParameters {
        // Get the URL that the user made the request to without any
        // path or parameters.
        service: make_redirect_url(req, redir_path).to_string(),
        ticket: params.ticket,
    };
    // Url-encode validation query
    let validation_query: String = serde_urlencoded::to_string(validation_params)
        .expect("Could not URL-encode CAS validation parameters");
    // Build the endpoint to query for user info.
    let validation_url: String =
        format!("{}/serviceValidate?{}", RPI_CAS_ENDPOINT, validation_query);

    // Send request to CAS service and wait for response.
    let cas_xml: String = reqwest::get(validation_url.as_str())
        .await
        .map_err(TelescopeError::rpi_cas_error)?
        .text()
        .await
        .map_err(TelescopeError::rpi_cas_error)?;

    // Extract and return the RCS id.
    return extract_rcs_id(cas_xml.as_str()).ok_or(TelescopeError::RpiCasError(format!(
        "Could not extract RCS ID from RPI CAS response. Response xml: {}",
        cas_xml
    )));
}
/// After the user has authenticated with CAS it will send them back to telescope
/// with a service ticket. This function will extract the service ticket and
/// use it to access the user's information via CAS. On success, this function return's the
/// user's RCS ID as a string (in lowercase).
After the user has authenticated with CAS it will send them back to telescope
with a service ticket. This function will extract the service ticket and
use it to access the user's information via CAS. On success, this function return's the
user's RCS ID as a string (in lowercase).
After the user has authenticated with CAS it will send them back to telescope with a service ticket . This function will extract the service ticket and use it to access the user ' s information via CAS . On success this function return ' s the user ' s RCS ID as a string ( in lowercase ) .
async fn cas_authenticated(
    req: &HttpRequest,
    redir_path: String,
) -> Result<String, TelescopeError> {
    // Extract the CAS parameters from the query
    let Query(params): Query<CasAuthenticatedParameters> =
        Query::<CasAuthenticatedParameters>::extract(req)
            .await
            // Convert any errors that occur.
            .map_err(|err| {
                // Log the error
                error!(
                    "Could not extract CAS ticket from request parameters: {}",
                    err
                );
                // Display an error message to the user.
                TelescopeError::BadRequest {
                    header: "Malformed CAS request".into(),
                    message: format!(
                        "The RPI CAS endpoint did not respond with the appropriate \
                    data. Please try again. If this error persists, contact a coordinator and file \
                    an issue on Telescope's GitHub. Internal error: {}",
                        err
                    ),
                    show_status_code: true,
                }
            })?;
    // Make the query parameters to send to the CAS validation server
    let validation_params = CasIdentificationParameters {
        // Get the URL that the user made the request to without any
        // path or parameters.
        service: make_redirect_url(req, redir_path).to_string(),
        ticket: params.ticket,
    };
    // Url-encode validation query
    let validation_query: String = serde_urlencoded::to_string(validation_params)
        .expect("Could not URL-encode CAS validation parameters");
    // Build the endpoint to query for user info.
    let validation_url: String =
        format!("{}/serviceValidate?{}", RPI_CAS_ENDPOINT, validation_query);
    // Send request to CAS service and wait for response.
    let cas_xml: String = reqwest::get(validation_url.as_str())
        .await
        .map_err(TelescopeError::rpi_cas_error)?
        .text()
        .await
        .map_err(TelescopeError::rpi_cas_error)?;
    // Extract and return the RCS id.
    return extract_rcs_id(cas_xml.as_str()).ok_or(TelescopeError::RpiCasError(format!(
        "Could not extract RCS ID from RPI CAS response. Response xml: {}",
        cas_xml
    )));
}
async fn cas_authenticated ( req : & HttpRequest , redir_path : String , ) -> Result < String , TelescopeError > { // Extract the CAS parameters from the query let Query ( params ) : Query < CasAuthenticatedParameters > = Query :: < CasAuthenticatedParameters > :: extract ( req ) . await // Convert any errors that occur. . map_err ( | err | { // Log the error error ! ( " " err ) ; // Display an error message to the user. TelescopeError :: BadRequest { header : " " . into ( ) , message : format ! ( " \
 \
 " err ) , show_status_code : true , } } ) ? ; // Make the query parameters to send to the CAS validation server let validation_params = CasIdentificationParameters { // Get the URL that the user made the request to without any // path or parameters. service : make_redirect_url ( req , redir_path ) . to_string ( ) , ticket : params . ticket , } ; // Url-encode validation query let validation_query : String = serde_urlencoded :: to_string ( validation_params ) . expect ( " " ) ; // Build the endpoint to query for user info. let validation_url : String = format ! ( " " RPI_CAS_ENDPOINT validation_query ) ; // Send request to CAS service and wait for response. let cas_xml : String = reqwest :: get ( validation_url . as_str ( ) ) . await . map_err ( TelescopeError :: rpi_cas_error ) ? . text ( ) . await . map_err ( TelescopeError :: rpi_cas_error ) ? ; // Extract and return the RCS id. return extract_rcs_id ( cas_xml . as_str ( ) ) . ok_or ( TelescopeError :: RpiCasError ( format ! ( " " cas_xml ) ) ) ; }
After the user has authenticated with CAS it will send them back to telescope
with a service ticket.
After the user has authenticated with CAS it will send them back to telescope with a service ticket .
req
&HttpRequest
redir_path
String
req
&HttpRequest
redir_path
String