Giter Site home page Giter Site logo

Authorizations about akka-http-session HOT 7 OPEN

softwaremill avatar softwaremill commented on July 18, 2024
Authorizations

from akka-http-session.

Comments (7)

adamw avatar adamw commented on July 18, 2024

I'm not really familiar with Shiro, but if there would be an integration point, then sure! As I see it provides session management - would it be in any way possible to integrate the two session concepts?

from akka-http-session.

briantopping avatar briantopping commented on July 18, 2024

Shiro is kind of a Java standard for authentication. Looks like some others have copied it in Scala, which is nice. Check out https://github.com/eikek/porter. I think this is a much better candidate to integrate or merge.

from akka-http-session.

adamw avatar adamw commented on July 18, 2024

Though it has only 1 star :) But sure, ideally that would be a module separate from both projects (integrating them)

from akka-http-session.

briantopping avatar briantopping commented on July 18, 2024

haha, yah. I don't think people doing Scala are doing a lot of apps with traditional enterprise features. Project like this isn't needed.

I'll look at the JWT module and see how the integration works..

from akka-http-session.

briantopping avatar briantopping commented on July 18, 2024

Some notes since I am uploading this to Bountysource:

In general terms, I'd like to add permissions checks for users. https://shiro.apache.org/authorization-features.html has a good overview of the things most people wonder about when they are first exposed to authorizations.

The core api an application needs is the ability to check if a user has a permission to do something, just a binary check of the permission key, i.e. a string such as "AddUsers" that is hardcoded into a specific piece of functionality. If they have a permission, the UI for adding a user could be presented. As one can imagine in a distributed app, the server also needs to perform this check if a new user is actually submitted, just to make sure the app wasn't hacked or someone put rogue commands on the wire.

In an app with hundreds of functions, there would be hundreds of permissions, so the check has to be lightweight or cacheable. In a naive implementation, one could just put all these permissions in a map with the keys as strings and the values as sets. A permission check would involve dereferencing the map and returning a boolean corresponding to whether the requesting user was in the set stored for that key of the map.

There are two big improvements required to this base case:

  • Administering hundreds of discrete permissions like this is error prone. If one has 10,000 users with 100 permissions, there's a million potential permissions. Most apps are much larger.
  • Apps filter data and offer behaviors depending on the user. As a manager, I may be able to add a user to groups I manage, but not to groups managed by others.

The first problem is solved by roles. Roles are basically parent groupings of permissions or other roles. A role called "Manager" might have the ability to add and remove users from groups. Now, instead of manually adding all these permissions to a new manager, the "Manager" role is given to the new manager and he has all the permissions other managers have. Even better, if a new permission is created for managers, it is simply added to the role, and all managers get the permission.

The dynamic problem could probably be built as time goes on. Generally, it's about creating a combinator that takes a discriminator function, there's a bazillion ways to skin that cat.

https://github.com/eikek/porter goes in to how some of this is done in the README.md, but it doesn't do anything with Akka HTTP Directives. As can be seen, doing them really really well takes a lot of investment and getting it wrong is a big liability. I've looked briefly at Porter and it seems to be 90% of what needs to be there. It seems to be patterned off Shiro, which is very robust. More importantly, much of that work is in place with unit tests. That's a few weeks just to get started.

from akka-http-session.

veotax avatar veotax commented on July 18, 2024

jCasbin is an authorization library that supports models like ACL, RBAC, ABAC.

Related to RBAC, casbin has several advantages:

  1. roles can be cascaded, aka roles can have roles.
  2. support resource roles, so users have their roles and resource have their roles too. role = group here.
  3. the permission assignments (or policy in casbin's language) can be persisted in files or database.
  4. multiple models like ACL, BLP, RBAC, ABAC, RESTful are supported.

And you can even customize your own access control model, for example, mix RBAC and ABAC together by using roles and attributes at the same time. It's very flexible.

I saw there's an authorization need here, and I think jCasbin is a good choice. What do you think? Thanks.

from akka-http-session.

adamw avatar adamw commented on July 18, 2024

@veotax do you have any specific idea on how would jcasbin integrate with akka-http? I suppose you could use any kind of authorization library and store the result in the session data.

from akka-http-session.

Related Issues (20)

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.