A Lightweight Login API for WSO2 Carbon

1. Build the API from https://github.com/facilelogin/aratuwa/tree/master/carbon-security/org.wso2.carbon.security.login

2. Copy the artifact(login.war) created from the above step to IS_HOME/repository/deployment/server/webapps

3. Restart the WSO2 Identity Server and make sure the login.war is deployed properly.

4. Following is an example cURL request just to authenticate a user.

curl -k -v  -H "Content-Type: application/json"  -X POST -d @auth_req.json https://localhost:9443/login
auth_req.json:

{ 
   "username": "admin",
   "password": "admin"
}
Response:

HTTP/1.1 200 OK
{  
   "username":"admin",
   "user_claims":[  

   ],
   "roles":[  

   ]
}
5. Following is an example cURL request to authenticate a user and get all his roles.

curl -k -v  -H "Content-Type: application/json"  -X POST -d @auth_req.json https://localhost:9443/login
auth_req.json:

{  
   "username": "admin",
   "password": "admin",
   "with_roles": true
}
Response:

HTTP/1.1 200 OK
{  
   "username":"admin",
   "user_claims":[  

   ],
   "roles":[  
      "admin",
      "Application/oauth2-proxy",
      "Internal/everyone"
   ]
}
6. Following is an example cURL request to authenticate a user and get all his roles and a selected set of claims.

curl -k -v  -H "Content-Type: application/json"  -X POST -d @auth_req.json https://localhost:9443/login
auth_req.json:

{  
   "username": "admin",
   "password": "admin",
   "with_roles" : true,
   "claims" : ["http://wso2.org/claims/emailaddress"]
}
Response:

HTTP/1.1 200 OK
{  
   "username":"admin",
   "user_claims":[  
      {  
         "claim_uri":"http://wso2.org/claims/emailaddress",
         "value":[  
            "admin@wso2.com"
         ]
      }
   ],
   "roles":[  
      "admin",
      "Application/oauth2-proxy",
      "Internal/everyone"
   ]
}