Add check for security context so that layout is usable in 404 error.