
Hivext
This is a web services platform with a common interface for accessing them from different programming languages. The goal of Hivext is to provide useful web services to developers, to ensure their stable operation and at the same time, ease of implementation in projects. Hivext will help to connect many existing platforms through a single API.
If you want to easily and quickly create web applications, including development for mobile devices, then the platform is a very interesting tool.')
The previous article is useful to familiarize yourself with the platform, its architecture, goals and objectives. In this article, we continue to publish changes and new services that have been added to the platform recently.
Major changes
- Translation of all documentation on the wiki system, with the further possibility of building a community, discussing and adding your own developments based on the services of the platform;
- The developer has been provided with basic services and structures for starting development for a platform (working with users, registration, authentication, management of applications and data structures);
- It was decided to allow the developer to expand the platform on the basis of basic services and, accordingly, use these developments in projects and open the developments for other developers;
- Added console for service tests: http://code.hivext.ru/development/APIConsole/
Basic Services
check inRegistration of new users in a common database. Used activation system through the mail.
When registering, the required parameters are mailing address and password.
Registration Service DocumentationIdentification and AuthenticationAuthentication of registered users. Features of the service:
- All users have a unique user identifier (UID);
- A single database allows users registered in the system to enter all applications using the authentication service;
- After authentication, a long secure session is created. The session ID is used to call the session methods of other services;
- An authenticated user is not required to re-enter his data if he has already been authenticated. And if the user has performed authentication on the app1.com domain, then when entering the app2.com domain, the system will know that the user has already been authenticated. This approach is called Single Sign On .
Documentation of the Authentication and Authentication ServiceAccount managementService management of personal data of the user. The required set of methods is defined:
- Editing username;
- Editing the user's email address;
- Edit user password.
Account Service DocumentationApplication ManagementTo start developing applications for the platform, the developer needs to:
- Register in the system (Registration service)
- Authenticate to the system (Identification and authentication service)
- Get application ID (Application Management service)
All service methods are called knowing the application identifier. Without an application identifier, invoking service methods is possible. The application ID can be linked to a domain, IP address or alias (domains and / or IP addresses). Those. using a specific key on other domains / IP is blocked.
Application Service DocumentationIn the development of
service structures . This service will allow to expand the existing structure of the platform to the needs of their projects.
An example of using services
API Console - a web application operating on the basis of basic services.
An example of using an authentication service
The example is made on JavaScript and implements the functions: authentication, session termination and user identification.
Step 1: We study the documentation and select the necessary functions.Documentation of the
Authentication and Authentication Service
We choose the necessary methods. We need methods:
Signin ,
Signout ,
CheckSign .
See if there are ready-made customers for this service. We need a client for javascript.
If there is no client service (for the required language), then the method has enough information to call it. For example, for the Signin method, you need to make an HTTP GET request, the parameters are encoded in
urlEncoding . Request example:
http://api.hivext.ru/1.0/users/authentication/rest/signin?appid=1dd8d191d38fff45e62564fcf67fdcd6&email=email@email.com&password=12345678Step 2: We connect the client service< script src ="http://code.hivext.ru/frameworks/js/core.js" type ="text/javascript" ></ script >
< script src ="http://api.hivext.ru/1.0/users/authentication.js" type ="text/javascript" ></ script >
Step 3: Create the desired application framework< style > <br> <br>body {<br> font-family: "Lucida Grande", Tahoma, Verdana, Arial, Sans-Serif;<br> font-size: 10pt;<br> color:#333;<br>}<br> <br>.error {<br> border: 1px solid #ff5050;<br> background-color: #ffc5b5;<br> padding: 4px 10px;<br> margin-bottom: 6px;<br> display: none;<br> font-size: 8pt;<br> font-weight: bold;<br>}<br><br> </ style > <br><br> < body onload ="Load()" > <br><br> < div id ="error" class ="error" ></ div > <br> <br> < div id ="signin_block" style ="display: none" > <br> : < input id ="email" /> <br>: < input id ="password" type ="password" /> <br> < input id ="signin" value ="Sign In" type ="button" /> <br> </ div > <br> <br> < div id ="signout_block" style ="display: none" > <br> < div id ="welcome_message" /> <br> < input id ="signout" value ="Sign Out" type ="button" /> <br> </ div > <br> <br> </ body > <br><br> * This source code was highlighted with Source Code Highlighter .
Step 4: Install event handlers and implement the necessary logic// <br> // onload body. <br> // <br><br> function Load() {<br><br> function id(element) { return document .getElementById(element); }<br> function error(result, error) { return "Code: " + result + "<br />Error: " + error;}<br><br> var sAppId = "0123456789ABCDEF0123456789ABCDEF" ; // . <br> var sSession; // . <br><br> // , cookies ( 3rd party cookies) <br> sSession = Cookies.Set( "session" );<br><br> // (Sign In). <br> id( "signin" ).onclick = function () {<br><br> // . <br> if (!id( "email" ).value || !id( "password" ).value) { <br> id( "error" ).innerHTML = " ." ;<br> id( "error" ).style.display = "block" ;<br> return false ;<br> }<br><br> // <br> // . <br> // <br><br> Users.Authentication.Signin(sAppId, id( "email" ).value, id( "password" ).value, function (oResponse) {<br> if (oResponse.result === 0) {<br> // , Sign Out ( ). <br> id( "error" ).style.display = "none" ;<br> id( "signin_block" ).style.display = "none" ;<br> id( "signout_block" ).style.display = "block" ;<br><br> // . . <br> sSession = oResponse.session;<br><br> // ( cookies - 3rd party cookies). <br> Cookies.Set( "session" , sSession);<br><br> } else {<br> // , . <br> id( "error" ).innerHTML = error(oResponse.result, oResponse.error);<br> id( "error" ).style.display = "block" ;<br> }<br> });<br><br> return true ;<br> }<br><br> // (Sign Out). <br> id( "signout" ).onclick = function () {<br><br> // <br> // . <br> // <br><br> Users.Authentication.Signout(sAppId, sSession, function (oResponse) {<br> if (oResponse.result === 0) {<br> // . <br> id( "error" ).style.display = "none" ;<br> id( "signin_block" ).style.display = "block" ;<br> id( "signout_block" ).style.display = "none" ;<br> <br> // , . <br> Cookies.Clear( "session" );<br> } else {<br> id( "error" ).innerHTML = error(oResponse.result, oResponse.error);<br> id( "error" ).style.display = "block" ;<br> }<br> });<br> }<br><br> // <br> // . <br> // <br><br> Users.Authentication.CheckSign(sAppId, sSession, function (oResponse) {<br> if (oResponse.result === 0) {<br> // , , . <br> id( "signin_block" ).style.display = "none" ;<br> id( "signout_block" ).style.display = "block" ;<br> } else {<br> // , . <br> id( "signin_block" ).style.display = "block" ;<br> id( "signout_block" ).style.display = "none" ;<br> }<br> });<br>} <br><br> * This source code was highlighted with Source Code Highlighter .
And here is an example of authentication:
http://code.hivext.ru/examples/js/common/sign.htmlLogin:
guest@guest.com , Password:
guestApplications
Platform documentation:
doc.hivext.ruApplications and components:
hivext.ru/index.php/componentsThe source code of examples under the license LGPL3 is uploaded.
Developers
Aleksandrov KM
m007 , Ruslan Sinitsky
sirusUpd : If this topic is interesting, but the essence is not completely clear, then we will make a separate article with a couple of schemes and a description of the work.