User Security and CORS
Products: FastReport Cloud, FastReport Corporate Server, FastReport Publisher
FastReport Cloud, FastReport Corporate Server, FastReport Publisher takes user security seriously and implements a strict CORS (Cross-Origin Resource Sharing) policy to protect data and prevent potential attacks. This article details how CORS and Origin work in the context of FastReport Cloud and explains browser security principles.
What is CORS and why is it important?
CORS (Cross-Origin Resource Sharing) is a browser security mechanism that determines whether a web page can request resources from a different domain. Without CORS, browsers block cross-domain requests by default according to the Same-Origin Policy.
Same-Origin Policy
A browser considers two URLs to belong to the same origin if they match:
- Protocol (https/http)
- Domain name
- Port
For example:
https://app.fastreport.cloudandhttps://api.fastreport.cloudare different originshttps://example.comandhttps://subdomain.example.comare different origins
CORS Policy in FastReport Cloud, FastReport Corporate Server, FastReport Publisher
FastReport Cloud, FastReport Corporate Server, FastReport Publisher implements a differentiated approach to CORS depending on the user's authorization state:
Unauthorized Requests
For unauthorized users, the CORS policy is the most lenient:
- Cross-domain requests to the cluster are allowed
- The Origin header is not required
- This allows the use of public APIs and functions without restrictions
Authorized Requests with Origin
Strict rules apply to authorized users:
- Basic Authentication (
Authorization: Basic ...) - Bearer Token (
Authorization: Bearer ...) - The Origin header must be specified to receive permission from the browser
Cookie-based Authorization
To enhance security, the use of cookies in cross-domain requests (including when loading content into an iframe from a different origin) is restricted. This prevents automatic sending of session cookies in potentially unwanted requests. To embed reports via iframe, it is recommended to use an ApiKey, which allows bypassing these restrictions.
Browser Security Mechanisms
FastReport Cloud, FastReport Corporate Server, FastReport Publisher correctly handles requests and returns the appropriate CORS headers.
CORS Headers
The server returns the following headers:
Access-Control-Allow-Origin: https://your-domain.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
Setup and Usage
Origin Configuration
To ensure the system works correctly, you need to:
Specify the list of allowed Origins (Domains) in the workspace
- Maximum of 10 domains
- Only the domain needs to be specified (e.g.,
your-domain.com). FastReport Cloud, FastReport Corporate Server, FastReport Publisher will automatically match the incomingOriginheader against this list. Wildcards (e.g.,*.example.com) are not supported; specific domains must be listed. - The protocol (https) does not need to be specified, as the protocol will also be determined automatically.
Using the Origins (Domains) list
- The list of allowed domain names is configured by the administrator.
- When a request is received from an authorized user, the cluster checks the request's
Originheader against this list and, if there is a match, returns the appropriate CORS headers.
Configuration Examples
For web applications:
Origin: https://your-app.com
For stand-alone applications and integrations:
Only pass the header if you implement standard browser security.
For API requests with authorization:
// The request is sent from your domain (e.g., https://your-app.com)
// The browser automatically adds the Origin header: Origin: https://your-app.com
fetch('https://fastreport.cloud/{path}', {
method: 'GET',
headers: {
'Authorization': 'Bearer your-token'
// 'Origin': 'https://your-app.com' // This header is added automatically by the browser
}
});
Practical Recommendations
For Developers
- Always specify the Origin header for authorized requests (actually, the browser does this automatically for cross-domain requests)
- Check the list of allowed Origins in the workspace settings
- Use HTTPS for all domains in the Origins list
- Test CORS requests in the browser, not just via command-line tools
For Administrators
- Regularly review the Origins (Domains) list
- Remove unused domains
- Monitor for domain name changes
- Update Origins (Domains) when migrating applications
Protection Against Common Attacks
CSRF (Cross-Site Request Forgery)
The CORS policy prevents malicious requests from being executed on behalf of an authorized user from other sites.
XSS (Cross-Site Scripting)
Limiting Origins reduces the risk of using XSS vulnerabilities to steal data via cross-domain requests.
Clickjacking
Using proper X-Frame-Options and CORS headers helps prevent clickjacking attacks.
Conclusion
The CORS policy in FastReport Cloud, FastReport Corporate Server, FastReport Publisher provides a balanced solution that ensures:
- Maximum security for authorized users
- Ease of use for unauthorized requests
- Flexible configuration for various usage scenarios
- Compatibility with modern browsers and their security mechanisms
Proper configuration of Origins and adherence to CORS rules allows FastReport Cloud, FastReport Corporate Server, FastReport Publisher to be securely integrated into any web application, ensuring user data protection and compliance with modern web application security standards.