Giter Club home page Giter Club logo

iron-cors-rs's Introduction

CORS Middleware for Iron

Travis CI Crates.io Rust

A CORS Middleware for Iron with preflight support.

See https://www.html5rocks.com/static/images/cors_server_flowchart.png for reference.

Docs: https://docs.rs/iron-cors/

This library requires Rust 1.21+.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

iron-cors-rs's People

Contributors

davidbm avatar dbrgn avatar matklad avatar mdaffin avatar untitaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

iron-cors-rs's Issues

Compatibility with authentication BeforeMiddleware

Hello,

I have a small project with a BeforeMiddleware handling authentication, as advocated by https://docs.rs/iron/0.6.0/iron/middleware/index.html#middleware.

I need my API to be CORS friendly, so I used this library.

As CorsMiddleWare is implemented as an AroundMiddleWare, the problem is that my routes are failing authentication before having a chance to reach CorsMiddleware.

I plan to adapt the codebase to switch CorsMiddleware to a BeforeMiddleware.

If I'm doing something wrong or you have questions please tell me in this thread.

If you're interested in a pull request, I'll gladly make it. (If I continue with this idea)

Provide Access-Control-Allow-Credentials support

Hello,
I have a web application in angular that access multiple apis using cookies as credentials
The Browser refuses to send cookies if Access-Control-Allow-Credentials isn't setted.

Do you intent offer this support in this library?
If yes, I'll open a pull request.

Cors headers are not set when an error is returned from the handler

If the wrapped handler returns an error the cors headers are not set at all, leading to the ui being unable to obtain the reason for the failure if one was set in the body. This makes it impossible to use after middleware to handle error messages gracefully without having to worry about the cors headers.

I would expect the headers to be set on every request in spite of any errors encountered. This way the headers are set and ready for remaining middleware to respond to the client correctly.

Clarify allow any flag

Docs:

The boolean flag specifies whether requests without an Origin header should be rejected or not.

That's a bit confusing.

with_whitelist should have an option for accepting request without origin header

When the domain is the same as the webpage was loaded, the browser doesn't send the origin header.

For example, when I launch a server in localhost and with cors like ["localhost:3000"] the middleware doesn't allow the request because the browser is not sending the cors.

That will apply to if I have a webpage that is using some subroute as api endpoint (can be done with nginx).

Anyway, that should be configurable for be able to express "My domain and this other domains".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.