Recently, the company requested to investigate one-click login business, as shown in the figure below.
This article will compare traditional login with one-click login and briefly introduce the integration of aurora authentication services.
Traditional Login Mode
With the development of mobile Internet, account login has become the standard function of almost all applications. Speaking of login methods, nothing more than account password login and verification code login. But are these two ways really convenient and safe?
Account and Password Login
Account password login as the most primitive login method, but also I hate a login method.
In terms of convenience, the user has to enter a username and password that meets the platform’s rules, and each platform has its own rules. While there is usually nothing wrong, there is always something that can hurt the user experience.
- If I want to enter Chinese, the platform only gives me English, letters, symbols, or vice versa
- The password must contain at least six to eight characters……
- Password entry restrictions, most commonly, require the inclusion of uppercase and lowercase letters and numbers
Sometimes think of a password and pass the same, special requirements include upper and lower case letters, users easy to forget. That’s how iCloud was set up in the early days, and I did forget it, so I had to find the password.
In terms of security, there are drawbacks. I think a lot of people like Write Once, Run Everywhere, one password for all scenarios. This itself is an extremely unsafe thing, often have the so-and-so database that spreads in the street to divulge the password that may expose you, a pile of black produce hits a library every day in the back. On the other hand, if real-name authentication is required or user authentication information is limited, the same user can register an unlimited number of accounts. Although it can be restricted by technical means, it will always bring some inconvenience.
Verification code login
Verification code login to a certain extent to solve the above problem. Instead of coming up with a unique password, users simply enter the phone’s verification code. At the same time, the real-name information of mobile phone numbers also prevents users from registering without limit to a certain extent. Even though most apps still have a password-based login interface, there’s no denying that captcha login has become mainstream.
What are the other disadvantages of captcha logins? The only thing is it’s not convenient enough. The user correctly input mobile phone number, receive verification code, user experience is not good ROM also have to fill verification code, and then meet the network crazy, can only go back to choose account password login.
To put the user first, it would be nice if the user could automatically complete the login process without typing anything. That’s today’s one-click login.
A key to log in
Recall the Gif at the beginning of the article. After the user jumps to the login page, the page automatically displays the user’s mobile phone number without any input. Just click the login button.
The login flow chart above is from the China Mobile secret free login service document. With the carrier’s unique gateway authentication capability, users can obtain the local number for login and registration with one click of authorization. Also for China Unicom, China Telecom, have provided similar services.
- Sky Wing open platform
- China Mobile Internet Capability open platform
- Xiaowo SAAS service platform
It’s a little overwhelming to see that. In order to log in confidential-free, the developer had to connect to three SDKS. As a developer, my pet hate in my life is integrating the SDK, not to mention the quality of the document, but the increase in the size of the application brought by three SDKS for the same business is unacceptable.
Is there an SDK that integrates services from all three carriers?
The aurora certification
I used aurora- Imui, the open source IM chat UI component of the Aurora community, a few years ago.
Aurora IMUI is a general purpose INSTANT messaging (IM) UI library, not specific to any IM SDK. Complete chat list and message input component, also supported ANDROID/IOS/RN. I have researched many LIBRARIES of UI components for IM, few as fully functional as IMUI, and have been impressed by the Aurora community. This time I also investigated aurora community’s one-click login service — Aurora Authentication.
The preparatory work
Let’s talk briefly about the opening process.
- Sign up for an Aurora developer account and complete your developer certification.
- Select the application that you want to enable Aurora certification. You can also create a new application. For Android applications, you need to fill in the application package name and application signature, and provide an RSA encryption public key. The mobile phone number used for one-click login is encrypted with the RSA public key and returned. The developer needs to decrypt the phone number using the corresponding private key. The RSA encryption public key contains 1024 bits and the key format is PKCS#8. The private key corresponding to the public key must be properly kept to avoid disclosure.
The application signature can be obtained directly from the command line.
keytool -list -v -keystore debug.keystore
Copy the code
Replace debug.keystore with your own signature file.
The public and private RSA keys can be generated using OpenSSL.
Pem 1024 ' 'After the SSH command is executed, a private key file named **ras_private.pem** is generated in the current directory, and a public key file is generated based on the private key file. ```java openssl rsa -in rsa_private.pem -pubout -out rsa_public_key.pemCopy the code
After the command is executed, a public key file named ras_public_key.pem is generated in the current directory.
To integrate the SDK
It is recommended to use jCenter automatic dependencies directly. Add the following dependencies to the Module gradle file:
android {
......
defaultConfig {
applicationId "com.xxx.xxx" // The package name of your application.. ndk {// Select the.so library to add for the CPU type.
abiFilters 'armeabi'.'armeabi-v7a'.'arm64-v8a'
// Can also add 'x86', 'x86_64'
}
manifestPlaceholders = [
JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "Your Appkey".// appKey corresponding to the package name registered on the Portal.
JPUSH_CHANNEL : "developer-default".// Enter the default value for now.]... }... } dependencies { ...... compile'cn. Jiguang. SDK: jverification: 2.3.4' // Version 2.3.4 is used as an example.
compile 'cn. Jiguang. SDK: jcore: 2.1.2' // JCore 2.1.2 is used as an example.. }Copy the code
Androidmanifest.xml configuration
Do the following in the manifest file.
<?xml version="1.0" encoding="utf-8"? >
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Package name for your application"
android:versionCode="100"
android:versionName="1.0.0"
>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23" />
<! -- Required -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<! -- Optional -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <! -- Enable cascading window permissions for debug applications on 6.0 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name="Your Application Name">
<! -- since 2.0.0 optional -->
<! -- Since 2.1.1 optional, set the authorization page to screenOrientation -->
<activity
android:name="com.cmic.sso.sdk.activity.OAuthActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:launchMode="singleTop">
</activity>
<! -- since 2.0.0 optional -->
<! -- Since 2.1.1 optional, set the authorization page to screenOrientation -->
<activity
android:name="com.cmic.sso.sdk.activity.LoginAuthActivity"
android:theme="@android:style/Theme.Holo.NoActionBar"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:launchMode="singleTop">
</activity>
<! -- since 2.0.0 optional -->
<! -- Since 2.1.1 optional, set the authorization page to screenOrientation -->
<activity android:name="cn.jiguang.verifysdk.CtLoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@android:style/Theme.Holo.NoActionBar"
android:screenOrientation="portrait"
android:launchMode="singleTop">
</activity>
<! -- Required -->
<meta-data android:name="JPUSH_APPKEY" android:value="Appkey for your application"/>
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
</application>
</manifest>
Copy the code
Initialize the
Initialize in Application.
JVerificationInterface.init(this.new RequestCallback<String>() {
@Override
public void onResult(int code, String result) {... }})Copy the code
The API is introduced
Take a look at the one-click login interface.
JVerificationInterface.loginAuth(final Context context, LoginSettings settings, final VerifyListener listener)
Use as follows:
LoginSettings settings = new LoginSettings();
settings.setAutoFinish(true);// Set whether to automatically close the authorization page after login
settings.setTimeout(15 * 1000);// Set the timeout in milliseconds. Valid range: 0,30000. Outside the range, the default value is 10000
settings.setAuthPageEventListener(new AuthPageEventListener() {
@Override
public void onEvent(int cmd, String msg) {
//do something...}});// Set the authorization page event listening
JVerificationInterface.loginAuth(this, settings, new VerifyListener() {
@Override
public void onResult(int code, String content, String operator) {
if (code == 6000){
Log.d(TAG, "code=" + code + ", token=" + content+" ,operator="+operator);
}else{
Log.d(TAG, "code=" + code + ", message="+ content); }}});Copy the code
6000 represents success.
However, this is not recommended in practical development. One-click login depends on the prefetch number. If there is no prefetch number, one-click login automatically prefetch the number. You are advised to invoke the one-click login prefetch number interface before pulling up the authorization page, for example, on the open screen page or service portal page to perform the prefetch number to improve the speed of pulling up the authorization page and optimize the experience.
One-click login to the prefetch number interface is as follows:
JVerificationInterface.preLogin(Context context, int timeOut, PreLoginListener listener)
JVerificationInterface.preLogin(this.5000.new PreLoginListener() {
@Override
public void onResult(final int code, final String content) {
Log.d(TAG,"[" + code + "]message="+ content ); }});Copy the code
If the code 7000 is returned, the command is successfully obtained. Be careful not to repeatedly call the prefetch number or pull up the authorization page interface in the prefetch number callback.
In addition, remember to determine whether the current network environment supports it before using it.
JVerificationInterface.checkVerifyEnable(Context context)
boolean verifyEnable = JVerificationInterface.checkVerifyEnable(this);
if(! verifyEnable){ Log.d(TAG,"The current network environment does not support authentication");
return;
}
Copy the code
According to my actual measurement, one-click login cannot be carried out when only Wifi is enabled and data traffic is closed. The user is prompted to use the account password or verification code to log in.
Confuse configuration
-dontoptimizefankan
-dontpreverify
-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }
-dontwarn cn.jiguang.**
-keep class cn.jiguang.** { *; }
-dontwarn com.cmic.**
-keep class com.cmic.** { *; }
-dontwarn com.unicom.**
-keep class com.unicom.** { *; }
-dontwarn cn.com.chinatelecom.**
-keep class cn.com.chinatelecom.** { *; }
Copy the code
Use restrictions
- Support the three major domestic operators, China Mobile, China Unicom, China Telecom. Due to carrier restrictions, China Unicom is not currently supported for the Web SDK
- Network support China Mobile 2G/3G/4G, China Unicom 3G/4G, China Telecom 4G. Data traffic must be enabled for mobile users
- The authentication failure rate is high on 2G networks
- Dual SIM phones are supported, but only SIM cards with data network open are authenticated
The above is just a brief introduction to the use of aurora authentication, new users will give 1000 free experience. You can refer to the official documentation for more details, or download the official Demo. I believe that for developers, nothing is as real as a demo.
conclusion
When you look at Aurora – Imui, you see that Aurora also offers plug-ins for various services.
Aurora certification is also available for Android, IOS, Web, React Native, Flutter, Cordova, and more. I have also seen recommendations from Flutter developers on the nuggets, the local number is one click login! The Plugin for The Flutter Aurora certification is recommended.
One-click login is definitely the trend of the future. If you haven’t seen it yet, come and experience it!