Git Product home page Git Product logo

aerogear-security's Introduction

aerogear-security - very lean security API

AeroGear Security already comes with AeroGear Controller support.

how to create a new project

basic use case

  1. add the maven dependency

     <dependency>
         <groupId>org.jboss.aerogear</groupId>
         <artifactId>aerogear-security</artifactId>
         <version>1.1.1</version>
         <scope>compile</scope>
     </dependency>
    
  2. AeroGear Security doesn't reinvent the wheel and make use of the existing security providers. For now only PicketLink is supported:

     <dependency>
          <groupId>org.jboss.aerogear</groupId>
          <artifactId>aerogear-security-picketlink</artifactId>
          <version>1.0.2</version>
          <scope>compile</scope>
     </dependency>
    
  3. add the maven dependency from AeroGear Controller

     <dependency>
          <groupId>org.jboss.aerogear</groupId>
          <artifactId>aerogear-controller</artifactId>
          <version>1.0.1</version>
          <scope>compile</scope>
     </dependency>
    

Getting started

For more information about how to create a simple project with AeroGear Controller, please see the documentation.

Authentication

  1. create a pojo controller and inject AuthenticationManager.

     @Stateless
     public class Login {
    
         @Inject
         private AuthenticationManager authenticationManager;
    
         public User login(SimpleUser user) {
    
             authenticationManager.login(user);
    
             return user;
         }
    
         public void logout() {
             authenticationManager.logout();
         }
     }
    

Registration

  1. create a pojo controller and inject IdentityManagement.

     @Stateless
     public class Register {
    
         //For example purposes only
         public static final String DEFAULT_ROLE = "admin";
    
         @Inject
         private IdentityManagement configuration;
    
         public User register(SimpleUser user) {
    
             configuration.grant(DEFAULT_ROLE).to(user);
             return user;
         }
     }
    

Authorization

  1. AeroGear Security make use of the AbstractRoutingModule to configure role-based authorization support on Controller.

     public class Routes extends AbstractRoutingModule {
    
        /**
         * Entry point for configuring the routes mapping http requests to the pojo controllers
         */
         @Override
         public void configuration() {
             route()
                 .from("/delorean").roles("admin", "developer")
                 .on(RequestMethod.GET)
                 .to(Home.class).anotherPage();
         }
     } 
    

Credits


you can find a slightly better example at https://github.com/aerogear/aerogear-controller-demo

aerogear-security's People

Contributors

abstractj avatar danbev avatar matzew avatar qmx avatar sebastienblanc avatar

Watchers

 avatar  avatar  avatar

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.