pub struct SecurityHeaders {
pub csp: ContentSecurityPolicy,
pub frame_options: FrameOptions,
pub referrer_policy: ReferrerPolicy,
pub permissions_policy: String,
}Expand description
Security headers for admin panel responses.
Provides a set of HTTP security headers recommended by OWASP for web application security hardening.
§Headers included
Content-Security-Policy: Restricts resource loading originsX-Content-Type-Options: Prevents MIME-type sniffingX-Frame-Options: Prevents clickjackingX-XSS-Protection: Legacy XSS protection (for older browsers)Referrer-Policy: Controls referrer informationPermissions-Policy: Restricts browser features
§Examples
use reinhardt_admin::server::security::SecurityHeaders;
let headers = SecurityHeaders::default();
let header_map = headers.to_header_map();
assert!(header_map.contains_key("Content-Security-Policy"));
assert!(header_map.contains_key("X-Content-Type-Options"));Fields§
§csp: ContentSecurityPolicyContent Security Policy directives
frame_options: FrameOptionsX-Frame-Options value
referrer_policy: ReferrerPolicyReferrer-Policy value
permissions_policy: StringPermissions-Policy header value
Implementations§
Source§impl SecurityHeaders
impl SecurityHeaders
Sourcepub fn to_header_map(&self) -> HashMap<&'static str, String>
pub fn to_header_map(&self) -> HashMap<&'static str, String>
Convert security headers to a map of header name -> value pairs.
This can be used to apply headers to HTTP responses.
§Examples
use reinhardt_admin::server::security::SecurityHeaders;
let headers = SecurityHeaders::default();
let map = headers.to_header_map();
assert_eq!(map.get("X-Content-Type-Options").unwrap(), "nosniff");
assert_eq!(map.get("X-Frame-Options").unwrap(), "DENY");Trait Implementations§
Source§impl Clone for SecurityHeaders
impl Clone for SecurityHeaders
Source§fn clone(&self) -> SecurityHeaders
fn clone(&self) -> SecurityHeaders
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecurityHeaders
impl Debug for SecurityHeaders
Auto Trait Implementations§
impl Freeze for SecurityHeaders
impl RefUnwindSafe for SecurityHeaders
impl Send for SecurityHeaders
impl Sync for SecurityHeaders
impl Unpin for SecurityHeaders
impl UnsafeUnpin for SecurityHeaders
impl UnwindSafe for SecurityHeaders
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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