Giter Club home page Giter Club logo

carbon-security's Introduction

This repository is no longer maintained.

Issue reports and pull requests will not be attended.

Carbon Security


Branch Build Status
master Build Status

Carbon Security project provides authentication and authorization implementation for carbon products based on JAAS.

Features:

  • JAAS based authentication.
  • JAAS based authorization.
  • Built in login modules
    • Username Password login module
    • JWT login module
  • Mechanism to plug-in custom Login modules, callback handlers in an OSGi environment.

Getting Started

Authentication

Following are the steps to authenticate a user with an in-built login module.

Add following entry to the bin/carbon.sh file to enable JAAS based authentication,

    -Djava.security.auth.login.config="$CARBON_HOME/conf/security/carbon-jaas.config"\

Configure carbon-jaas.config file at conf/security to specify the login module to be used for authentication. For example if you wish to use the Username Password login module, carbon-jaas.config should look like below.

CarbonSecurityConfig {
   org.wso2.carbon.security.jaas.modules.UsernamePasswordLoginModule required;
};

Similarly for JWT login module, the following fully qualified class name can be used.

  • org.wso2.carbon.security.jaas.modules.JWTLoginModule

The following code snippet shows how to perfrom a login using JAAS.

CallbackHandler callbackHandler = new CarbonCallbackHandler(httpRequest);
LoginContext loginContext;
try {
    loginContext = new LoginContext("CarbonSecurityConfig", callbackHandler);
} catch (LoginException e) {
    //logic if initializing login context fails.
}
try {
    loginContext.login();
} catch (LoginException e) {
    //logic if login fails.
}

Authorization

Following are the steps to authorize a principle from carbon authorization store.

Add following entries to the bin/carbon.sh file to enable JAAS based authentication,

    -Djava.security.manager \
    -Djava.security.policy="$CARBON_HOME/conf/security/security.policy" \

The following code snippet shows how to perform a authorization.

    private boolean isAuthorized(Subject subject, final CarbonPermission requiredPermission) {

        final SecurityManager securityManager;

        if (System.getSecurityManager() == null) {
            securityManager = new SecurityManager();
        } else {
            securityManager = System.getSecurityManager();
        }

        try {
            Subject.doAsPrivileged(subject, (PrivilegedExceptionAction) () -> {
                securityManager.checkPermission(requiredPermission);
                return null;
            }, null);
            return true;
        } catch (AccessControlException ace) {
            return false;
        } catch (PrivilegedActionException pae) {
            return false;
        }
    }

Download

Use Maven snippet:

<dependency>
    <groupId>org.wso2.carbon.security</groupId>
    <artifactId>org.wso2.carbon.security</artifactId>
    <version>${carbon.security.version}</version>
</dependency>

Snapshot Releases

Use following Maven repository for snapshot versions of Carbon Security.

<repository>
    <id>wso2.snapshots</id>
    <name>WSO2 Snapshot Repository</name>
    <url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
    </snapshots>
    <releases>
        <enabled>false</enabled>
    </releases>
</repository>

Released Versions

Use following Maven repository for released stable versions of Carbon Security.

<repository>
    <id>wso2.releases</id>
    <name>WSO2 Releases Repository</name>
    <url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
    <releases>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
        <checksumPolicy>ignore</checksumPolicy>
    </releases>
</repository>

Building From Source

Clone this repository first (git clone https://github.com/wso2/carbon-security.git) and use Maven install to build mvn clean install.

Contributing to Carbon Security Project

Pull requests are highly encouraged and we recommend you to create a JIRA to discuss the issue or feature that you are contributing to.

License

Carbon Security is available under the Apache 2 License.

Copyright

Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

carbon-security's People

Contributors

jkaushalya avatar thanujalk avatar omindu avatar indunilrathnayake avatar johannnallathamby avatar maheshika avatar akalankapagoda avatar ashensw avatar harsha1979 avatar lashinijay avatar madurangasiriwardena avatar denuwanthi avatar mohanvive avatar yasiruk avatar

Stargazers

Nuvindu Nirmana avatar Gabilan Ganeshwaran avatar Sasindu Alahakoon avatar Ayesh Almeida avatar Hasitha Aravinda avatar Hinduja Balasubramaniyam avatar Kaumini Gunasinghe avatar Arshika Mohottige avatar Chamupathi Gigara Hettige avatar Tharindu Jayathilake avatar Tharik Kanaka avatar  avatar Anjana Supun avatar Yasith Deelaka avatar Sarani Mendis avatar Tharindu Udupitiya avatar Sachini Samson avatar Ushira Karunasena avatar Dulaj Dilshan avatar Gimantha Bandara avatar Chiran Fernando avatar Kavith Thiranga Lokuhewage avatar Kanushka Gayan avatar Anuruddha Lanka Liyanarachchi avatar Sumudu Nissanka avatar Nipuna Ransinghe  avatar Aneesha Fernando avatar Krishnananthalingam Tharmigan avatar Tharindu Weerasinghe avatar Madusha Gunasekera avatar Danesh Kuruppu avatar Shammi Kolonne avatar Kaneel Dias avatar Gayal Dassanayake avatar Asma Jabir avatar Fathima Dilhasha avatar Mahmoud Rusty Abdelkader avatar

Watchers

Sameera Medagammaddegedara avatar Deependra Ariyadewa avatar Manoj Kristhombu avatar Yasith Tharindu avatar Kishanthan Thangarajah avatar James Cloos avatar Kasun Gajasinghe avatar Ruwan Abeykoon avatar  avatar  avatar Thanuja Uruththirakodeeswaran avatar Chamila Wijayarathna avatar  avatar Chamith Kumarage avatar Pulasthi Mahawithana avatar Prabath Siriwardena avatar  avatar Chamara Philips avatar Rushmin Fernando avatar Darshana Gunawardana avatar  avatar Shankar avatar Sameera Jayasoma avatar Afkham Azeez avatar Lahiru Manohara avatar Gayan avatar Hasintha Indrajee avatar Nipuni Piyabasi Perera avatar Tanya Madurapperuma avatar Shan Mahanama avatar Chanaka Cooray avatar Malithi Madara Edirisinghe avatar Jayanga Dissanayake avatar Ayesha Dissanayaka avatar Chandana Napagoda avatar Danushka Fernando avatar Nira avatar  avatar Dimuthu Lanerolle avatar Aruna Karunarathna avatar TK avatar  avatar Supun Malinga avatar  avatar  avatar Dharshana Warusavitharana avatar  avatar Thusitha Thilina Dayaratne avatar Samisa Abeysinghe avatar  avatar  avatar Ishara Karunarathna avatar Asela Pathberiya avatar Dulanja Liyanage avatar Waruna De Silva avatar Dilan Ariyaratne avatar Mirage Abeysekara avatar Danesh Kuruppu avatar Isura Karunaratne avatar Godwin Amila Shrimal avatar  avatar  avatar Nipuna Marcus avatar Irunika Weeraratne avatar Nishadi Kirielle avatar Vihanga Liyanage avatar Chiranga Alwis avatar Nisrin avatar Dinali Dabarera avatar Lahiru Cooray avatar  avatar Sumedha Kodithuwakku avatar  avatar  avatar Sajith Abeywardhana avatar Kasun Bandara avatar Sajith Ariyarathna avatar Janak Amarasena avatar Kanagalingam Senthalan avatar  avatar M.G.T.R Manamgoda avatar Aparna Karunarathna avatar Pamoda Wimalasiri avatar Hasanthi avatar  avatar  avatar  avatar Lahiru J Ekanayake avatar Vimukthi Perera avatar Kasun Siyambalapitiya avatar Sherene Mahanama avatar Piraveena Paralogarajah avatar Inthirakumaaran avatar Shan Chathusanda Jayathilaka avatar Samuel Mervyn Gnaniah avatar Ching Tien Shi avatar  avatar Nihla Akram avatar Athiththan Kathirgamasegaran  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.