We use proprietary and third party´s cookies to improve your experience and our services, identifying your Internet Browsing preferences on our website; develop analytic activities and display advertising based on your preferences. If you keep browsing, you accept its use. You can get more information on our Cookie Policy
Cookies Policy
Ask Your Question

Gabriela's profile - activity

2016-10-19 08:17:13 +0100 received badge  Popular Question (source)
2016-10-11 05:09:01 +0100 received badge  Editor (source)
2016-10-11 05:08:26 +0100 asked a question SCIM API - Keyrock Fiware

I am using a fiware-idm image in a docker container (https://hub.docker.com/r/fiware/idm/) and I'm trying access the SCIM API. There is user "idm" (default user), he's provider and has all permissions. But when I try get all users:

private String getAccessToken() {
    HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    HttpSession session = httpServletRequest.getSession();
    String accessToken = (String) session.getAttribute("access_token");
    return accessToken;
 }

public void getUsers() throws IOException {
    String accessToken = getAccessToken(); 

    Client client = ClientBuilder.newClient();
    Response response = client.target("http://192.168.99.100:5000/v3/projects")
      .request(MediaType.TEXT_PLAIN_TYPE)
      .header("X-Auth-token", accessToken)
      .get();

    setResultUsersList("-- status: " + response.getStatus() + " <br>" 
            + "-- headers: " + response.getHeaders() + " <br>"
            + "-- body: " + response.readEntity(String.class) + " <br>"
            + "-- token: " + accessToken);
}

I receive an error msg: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}

But the authentication works and get the user infos too:

public void authenticateUser() throws OAuthSystemException, IOException {
    HttpServletResponse httpServletResponse = (HttpServletResponse)  FacesContext.getCurrentInstance().getExternalContext().getResponse();


    OAuthClientRequest codeRequest = OAuthClientRequest
        .authorizationLocation("http://192.168.99.100:8000/oauth2/authorize")
        .setParameter("response_type", "code")
        .setClientId(CLIENT_ID)
        .setRedirectURI("http://localhost:8080/Example-Application-Security-UI/auth")
        .buildQueryMessage();
    httpServletResponse.sendRedirect(codeRequest.getLocationUri());

}

   public void requestUserInfo() {
        HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        HttpSession session = httpServletRequest.getSession();
        accessToken = (String) session.getAttribute("access_token");

        String strJson = callWebservice("http://192.168.99.100:8000/user?access_token=" + accessToken);
        JSONObject jsonObject = new JSONObject(strJson);
        resultUserInfo = jsonObject.toString();
   }
2016-09-15 08:15:18 +0100 asked a question FIWARE Authentication in Python

I'm trying to authenticate user using FIWARE. It returns a 404 when I request the token, but I don't have problems to get access code request. My init and get_token method:

def __init__(self):
    self.client_id = 'ee79a182fe014e118499652fb92c95a6'  # IDM APP CLIENT ID
    self.client_secret = '39d0e791563b4216a740778ed7f258ef'  # IDM APP CLIENT SECRET

    raw_auth_code = '{}:{}'.format(self.client_id, self.client_secret)
    self.base_64_auth_code = base64.b64encode(raw_auth_code.encode('utf-8')).decode('utf-8')

    self.redirect_uri = 'http://192.168.99.100:8000/auth'  # CALLBACK URL REGISTERED ON IDM (UI APP AUTH ADDRESS)

    self.idm_address = 'http://0.0.0.0:8000/'  # IDM ADDRESS
    self.authorization_url = self.idm_address + 'oauth2/authorize'
    self.token_url = self.idm_address + 'oauth2/token'
    self.acess_token = ''

def get_token(self, code):
    headers = {'Authorization': 'Basic {}'.format(self.base_64_auth_code),
               'Content-Type': 'application/x-www-form-urlencoded'}
    data = {'grant_type': 'authorization_code', 'code': code, 'redirect_uri': self.redirect_uri}
    response = requests.post(self.token_url, headers=headers, data=data)

    str_response_content = response.content.decode('utf-8')
    token_dict = json.loads(str_response_content)
    self.access_token = token_dict['access_token']
    return token_dict

I don't get how I get the authorization code correctly, but not the token.

My project: https://github.com/I-am-Gabi/security...