Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature for OAuth2 Token Validation using Fiware Wilma PEP-Proxy #1

Merged
merged 6 commits into from
Oct 26, 2017

Conversation

anmunoz
Copy link
Member

@anmunoz anmunoz commented Oct 26, 2017

The changes associates to this pull request allow to make OAuth2 token validation to the users of api-umbrella. The new feature uses the service of Fiware Wilma Pep Proxy server in "validate" mode, for checking if a token is valid or not, and retrieve the information of the user associate to this token. With this option the users can send a token to access to the APIs registered in the api-umbrella platform instead to use or create an API_ key. This component works together with the use of the api_key, so these changes doesn't affect to use of API request or web access with an API_key.
The use of token validation feature is limited to API requests in two modes, using a param by url value and header value (basicAuthUsername is not allowed). Also the caching mode is not available yet, for this reason the api-key-cache option must be set to false in the configuration file of the platform.
However, for using this feature is needed to have a Fiware Wilma PEP-Proxy registered and working in a local or cloud instance

…inside of the gatekeeper configuration for managing token validation with FIWARE Wilma PEP Poxy, this fields allow to define the PEP proxy host and port to establish the connection. The caching option was changed to false because the token validation option doesn't allow caching yet.

Also, the error messages defined in the api settings were changed for including token as other validation method.
…the word "token" in the url and the header "X-Auth-Token" in the requests made to the platform. With this change is possible to manage and differentiate if the user made a request using an API_Key or OAuth Token
…s allowed to pass the token are by param and header. The variable api_key was changed by a key, value table, this table has two values, fist the key_value that stores the value of the api_key or the token, and the second value called key_type which stores the type of key provided by the user, it can take two values token or api_key

All the variables that previously stored the api_key value, was changed to store api_key ["key_value"], that represents exactly the same value using the new api_key table.
…odified to allow and parse a roles tables that have more than one value by rol, for example: if the function receives the roles in this format Roles":[{"name":"rol1","id":"16"}].

With the modification the function checks if the roles value has more than one value and takes only the value for the key "name" ant after that invert the table.
…ng if the token is valid and retrieve the user information. The function takes the PEP Proxy host and port as parameters and sends a request with the header X-Auth-Token and the value of the token provided by the user.

If the token is valid, PEP proxy sends a response with the user information asociated to the token, otherwise, it sends a message indicating the result of the validation process with his status, 404 , 402, etc.
…on, for achieving this, an extra validation through the key_type value of the api_key variable was used. If the key_value is equal to "api_key", the key_value is checked in the Mongo database. In case of the value of key_values is equal to "token", the token is sent to the PEP Proxy for validation, if the token is valid, the user information is returned.

If the user information is retrieved from the database this information is stored in the variables of the platform as usually did. In case that the user information was retrieved using token validation, the variables the Nick_name is assigned to the user_id and the Roles is assigned to the roles of the platform.
Moreover, if the user information coming from of the token validation with PEP Proxy doesn't have the value of "email", this field is stored in the platform using the Nick_name value, this value is needed for displaying, the user associated with each request in the Analytics option of the web app . The rest of the changes are related to the reassignment of the api_key variable using api_key ["key_value"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant