Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsumners/cors-filter
A Java servlet CORS filter written against Java 8
https://github.com/jsumners/cors-filter
Last synced: about 1 month ago
JSON representation
A Java servlet CORS filter written against Java 8
- Host: GitHub
- URL: https://github.com/jsumners/cors-filter
- Owner: jsumners
- Created: 2015-05-12T19:06:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-12T19:06:55.000Z (over 9 years ago)
- Last Synced: 2024-10-14T21:57:53.463Z (about 1 month ago)
- Language: Java
- Size: 133 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# CORS Filter
Provides a Java Servlet filter to manage CORS requests. This filter can be
configured via JavaConfig or via a web.xml.Requires Java 8.
## But why?
Yes, there are already several of these filters out there. None of them support
JavaConfig. And the one bundled with Tomcat was giving me issues on a project.
So I wrote this simple implementation.## Install
This library is available as a Maven artifact. Simply add the
dependency:```xml
jitpack.io
https://jitpack.io
com.github.jsumners
cors-filter
0.1.0
```
## web.xml config
* `cors.allowed.origins`: a comma separated list of origins,
e.g. "http://example.com". Default: "*"
* `cors.allowed.methods`: a comma separated list of HTTP methods
that are allowed to be used for CORS requests. Default: "GET,POST,HEAD,OPTIONS"
* `cors.allowed.headers`: a comma separated list of allowed
headers in a CORS request (they will be converted to all lower case).
Default: "origin,accept,x-requested-with,content-type,access-control-request-method,access-control-request-headers"
* `cors.exposed.headers`: a comma separated list of headers
to expose via CORS requests. Default: ""
* `cors.preflight.maxage`: number of seconds to allow clients
to cache CORS preflight requests. Set to -1 to prevent the header
from being sent. Default: 1800
* `cors.support.credentials`: boolean indicating if the servlet
supports CORS requests with credentials. Default: "true"## JavaConfig
See the JavaDoc for the `CorsFilterConfig` class (it's brain dead simple).
# Licence
[http://jsumners.mit-license.org/](http://jsumners.mit-license.org/)