Easy User Authorization for Web Applications
Join the DZone community and get the full member experience.Join For Free
authorization is one of the primary common features of all software systems. while developing an authorization system for our erp software, i felt that i was re-inventing the wheel since so may have written this type of code again and again in many types of software like oss, dbmss, http servers, file systems etc. they have different flavors of authorization capabilities. re-inventing is not limited with different types of systems, as it is re-implemented again and again in every enterprise web applications.
one of the missing or weak features of web frameworks is easy authorization support. in the java ee standard, jaas is used for authentication and authorization. i assume framework writers don’t want to re-implement this service that is already defined in java ee stack. however, it would not be easy to use jaas in web applications. in my opinion, jaas is much more appropriate for desktop-based applications and component level services. in web applications, we need a new abstraction for authorization that is a url-based authorization mechanism.
by saying “easy authorization”, i mean following:
it can be used both by power users and administrators from a management module. if you have numerous users and companies using your system, you have to give the task of managing user accounts and rights to some power users.
it should not force us to declare permissions in configuration files every time a new user or role is created. system administrators can alter these files but power users can’t access and understand these files.
user access permissions should be grouped within role definitions (role-based authorization). in this way, we define an access schema only once, and easily assign it to new users many times. this is a magnificent feature. otherwise, every time we create a user, we have to define same access rights again and again by leading to duplicate definitions which are open to errors.
authorization should be a transparent service for the developers. authorization definitions shouldn’t be embedded in code. by transparent authorization, a developer doesn’t have to think the authorization aspect of the program since it is a built-in feature. in some edge conditions, the developer should also have the chance to override and change authorization behavior.
url-based authorization should be easily mapped to the part of the application thus removing the task of defining an authorization grant (url) every time a new web application is written. for example, when a user has access rights for a module, a new sub-module added to this module is automatically granted to access for its users. to achieve this, you have to divide your application into sub-modules (logical parts). in our applications, we defined 3 levels: suite (a bunch of web applications), module (a web application), sub-module (a logical part of a web application). for example, “human resources” is a suite and “payroll” is a module and “advance payment” is a sub-module.
- record and field-based authorization should be defined within the same screen with module (url) access permissions. if you are using different frameworks for persistence and web flow, afaik that would be impossible for now. single point of access makes it easy to define all authorization rights
architecture for authorization service
web application authorization: authorization control is carried out by an authorization service at the front of servlets. each user request is evaluated according to its user, url and command. if user has the authority to run this command at this url, then command is delegated to the business layer for further execution. if user doesn’t have the permissions for the command, then a proper “access denied” message is returned.
record authorization: authorization is also executed behind the persistence layer for record-based authorization. if user is not authorized to fetch some kind of rows, then these records are filtered out. or a user is not authorized to edit some rows, if an update is tried on this row, then it is denied.
Opinions expressed by DZone contributors are their own.