Giter VIP home page Giter VIP logo

sealr's Introduction

sealr

Build Status codecov

The goal of sealr is to provide multiple authentication and authorization strategies for plumber by using filters. In doing so, we hope to make best practices in authentication easy to implement for the R community. The package is inspired by the amazing passport.js library for Node.js. The sealr website can be found at https://jandix.github.io/sealr/.

Disclaimer

⚠️ We are currently looking for security experts to help us develop this project / review our code. That being said, while we try to thouroughly understand the concepts behind a strategy before we implement it in sealr, we are not experts in security. Please make sure you understand the risks and possible attack vectors when using sealr - especially in production environments. ⚠️

Installation

Currently, the package is under development. Please feel free to contribute to the package. You can install and use the package using devtools.

devtools::install_github("jandix/sealr")

Documentation and Examples

We provide more information and some simple sample implementations for different strategies and use cases on the project website: https://jandix.github.io/sealr/ (click on the headers in the navigation bar on the left to unfold the subsites / example sites). The site is a work in progress and we add content continuously.

Contribute

We are still at the very beginning of the package and we welcome any support and contribution. Below you find a list with possible authentication strategies that you could implement. The list is not complete and can be expanded with your suggestions.

Possible Strategies

  • Bearer Token
  • Sessions
  • Twitter OAuth
  • Facebook OAuth
  • Google OAuth

Testing

You can use curl for testing purposes. Unfortunately, curl quickly gets quite complicated if you want to add a body, parameters and unique headers. Therefore, we recommend to use Postman for larger, more complicated projects.

Warranity Notice

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sealr's People

Contributors

jandix avatar mayeulk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sealr's Issues

Twitter - evaluate application only auth (OAuth 2)

evaluate whether we should implement application-only authentication:

"

Twitter offers applications the ability to issue authenticated requests on behalf of the application itself (as opposed to on behalf of a specific user). Twitter’s implementation is based on the Client Credentials Grant flow of the OAuth 2 specification. Note that OAuth 1.0a is still required to issue requests on behalf of users.

Application-only authentication doesn't include any user contet. This means that you can only make requests to a Twitter API that doesn't require an authenticated user.

With application-only authentication, you can perform the following:

Pull user timelines;
Access friends and followers of any account;
Access lists resources;
Search in Tweets;
Retrieve any user information, excluding the user's email address;"

see https://developer.twitter.com/en/docs/basics/authentication/overview/application-only#issuing-application-only-requests

JWT - more than 2 filters example

maybe we can do mulitple filters to allow for more granular authorization?
idea:

  • in authenticate route, add a "scope" to claims
  • one filter for general scope
  • one filter for "admin" scope

Using serializer

I'm currently trying to implement the unboxed serializer for jsonlite::toJSON.

Is this possible with sealr?

I tried

pr$handle(
  "GET",
  "/secret",
  function (req, res) {return("Access to route requiring authentication was successful.")},
  serializer = "unboxedJSON"
)

which results in status 500, message [1] "ERROR: Serializers must be closures: 'unboxedJSON'" when trying to call this with httr

Refactoring: change interface of functions to return TRUE/FALSE

we could return TRUE / FALSE instead of forwarding within the function itself.

This would leave more possibilities to the user.

e.g. currently it is only possible to preempt one filter which makes more granular authorization (e.g. per endpoint) impossible. If the function only returned TRUE / FALSE the user could also use it inside endpoints (couldn't they?).
alternatively we could try to cut the functions so that there is always a function that does the check that returns TRUE / FALSE and a corresponding filter function that forwards..

@jandix : what do you think?

create examples folder

for each authentication strategy, i want at least one accompanying working example (mainly to show how to implement the /authenticate route.

JWT - example

move example from readme to examples folder. add "database" .

Google - anti-forgery state token (CSRF)

https://developers.google.com/identity/protocols/OpenIDConnect#createxsrftoken

"You must protect the security of your users by preventing request forgery attacks. The first step is creating a unique session token that holds state between your app and the user's client. You later match this unique session token with the authentication response returned by the Google OAuth Login service to verify that the user is making the request and not a malicious attacker. These tokens are often referred to as cross-site request forgery (CSRF) tokens."

Include WWW-Authenticate header in 401 response

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate

as per RFC 2616, we should include a WWW-Authenticate header in the 401 response.

" The request requires user authentication. The response MUST include a
WWW-Authenticate header field (section 14.47) containing a challenge
applicable to the requested resource. "

IANA describes the authentication schemes: http://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml

create github page

as an end user of the package, I can visit the github page of the package where example implementations (from examples folder) are presented / put into context.

JWT - check if token is expired

as per #9 , jose decode does not fail automatically if the token is expired.

hence, we should check the exp claim ourselves (if it is there).

Open question:
what to do with that information? Return 401?
how can the user know that the token expired?
can we redirect to a refresh endpoint? 🤔
@jandix: your opinion?

Allow also key for signing jwt

Currently, we rely only on jwt_decode_hmac, but we should also support jwt_decode_sig if the user provides a valid public key object.

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.