A single sign-on authentication method and system based on Token verification

By generating access tokens and refresh_Tokens, the problem of insufficient bandwidth and efficiency of Token verification in the existing single sign-on authentication technology is solved, and a more efficient and secure user experience is achieved.

CN118381678BActive Publication Date: 2024-10-01SHENZHEN HIGH-TECH IND INFORMATION NETWORK CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410822212.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-10-01
Estimated Expiration
2044-06-25

AI Technical Summary

Technical Problem

The existing single sign-on authentication technology will occupy more bandwidth when it passes token verification, resulting in insufficient efficiency and reduced user experience.

Method used

By verifying the user's login information, generate access tokens and refresh_Tokens, and verify user information through access tokens when the user jumps. If it fails, use refresh_Token to regenerate the token to ensure the efficiency and security of token verification.

Benefits of technology

Improve the security and efficiency of Token verification, reduce bandwidth usage, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118381678B_ABST
    Figure CN118381678B_ABST
Patent Text Reader

Abstract

The present invention discloses a single sign-on authentication method and system based on Token verification, which relates to the technical field of single sign-on authentication, and comprises the following steps: a user logs in to a server; verifies whether the user's login information is valid; generates a Token when the login information is valid and sends it to an application; when the user needs to jump to a browsing page, the application needs to obtain the user information of the user in the server, at which time the application carries the Token when sending a request to the server, the application receives the Token and verifies the validity of the Token, and after the verification is passed, provides the user's information authorization to the jump page. The present invention is used to solve the problem that the existing single sign-on authentication technology still has the problem that Token verification will occupy more bandwidth and the efficiency is insufficient when performing verification, resulting in a decrease in the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of single sign-on authentication, and in particular to a single sign-on authentication method and system based on Token verification. Background Art

[0002] Single sign-on authentication technology refers to an identity authentication and authorization mechanism that allows users to gain access to multiple servers or systems through a single login without having to authenticate separately in each server. Its core goal is to provide a simplified user experience, reduce the number of login credentials that users need to remember and manage, and improve system security.

[0003] Existing single sign-on authentication technologies usually perform authentication and verification on single sign-on through Token verification. However, the existing Token verification will occupy more bandwidth and has insufficient performance when verifying the Token, resulting in a longer verification process. When the user jumps, it often takes more time to verify and jump, which reduces the user experience. For example, in the Chinese patent application publication number: "CN112543180A", a "system and method for implementing single sign-on of multiple authentication centers based on Token" is disclosed. This solution is based on Token, which is the existing Token verification technology. The disadvantage is that it will occupy more bandwidth and reduce the user experience. The existing single sign-on authentication technology also has the problem that Token verification will occupy more bandwidth and is insufficient in efficiency when performing verification, resulting in a decrease in user experience. Summary of the invention

[0004] The present invention aims to solve one of the technical problems in the prior art to at least a certain extent, by verifying the user's login information, randomly extracting an encrypted code from a coding database after the verification is passed, encrypting the user id and the first expiration time through the encrypted code, obtaining an access Token through a series of encryption calculations, and generating a refresh_Token at the same time. When the user needs to jump to a browsing page, the application carries the access Token when sending a request to the server, and then verifies whether the access Token is valid. If the access Token is valid, the access Token is decrypted to obtain the user id and apply for the user information of the user from the server through the user id. If the access Token is invalid, the refresh_Token in the local storage is verified again. After the verification is passed, the access Token and refresh_Token are regenerated. If the verification fails, the user information cannot be obtained, so as to solve the problem that the existing single sign-on authentication technology still has the problem that Token verification will occupy more bandwidth and the efficiency is insufficient during verification, resulting in a decrease in user experience.

[0005] To achieve the above objectives, in a first aspect, the present application provides an authentication method for single sign-on based on Token verification, comprising the following steps:

[0006] The user logs in to the server;

[0007] Verify that the user's login information is valid;

[0008] When the login information is valid, a token is generated and sent to the application;

[0009] When the user needs to jump to a browsing page, the application needs to obtain the user information of the user in the server. At this time, the application carries a Token when sending a request to the server. The application receives the Token and verifies the validity of the Token. After the verification passes, the user's information authorization is provided to the jump page.

[0010] Furthermore, the user logs in to the server including the following sub-steps:

[0011] The user opens the server and enters the login page;

[0012] User enters account name;

[0013] The user enters the account password.

[0014] Furthermore, verifying whether the user's login information is valid includes the following sub-steps:

[0015] Read the account information database;

[0016] Check whether there is account data with the same account name in the account information database. If it exists, a password confirmation signal is output; if it does not exist, an account error signal is output;

[0017] If a password confirmation signal is output, the account data that is the same as the account name will be marked as comparison data, and the password data corresponding to the comparison data will be compared with the account password. If the password data is the same as the account password, a login success signal will be output; if the password data is different from the account password, a password error signal will be output.

[0018] Furthermore, when the login information is valid, generating a token and sending it to the application includes the following sub-steps:

[0019] The token includes an access token and a refresh_Token. When a login success signal is output, the current time is obtained and marked as the issuance time.

[0020] Randomly extract an encryption code from a code database, wherein the encryption code is a six-character code consisting of random uppercase letters and numbers;

[0021] Set the expiration time of the access token, mark it as the first expiration time, calculate the expiration time of the access token by adding the issuance time to the first expiration time, and mark it as the first expiration time;

[0022] Encrypt the user ID and the first expiration time by encryption coding to obtain an encrypted ID and an encrypted expiration time;

[0023] After encryption is completed, the encrypted code is encoded and encrypted to obtain the encrypted code. At the same time, a refresh_Token is generated and stored in the local storage. The encrypted code, the encrypted ID and the encrypted expiration time are combined to obtain the access Token.

[0024] Furthermore, encrypting the user ID and the first expiration time by encryption coding includes the following sub-steps:

[0025] Obtain the decimal number corresponding to the last character of the encryption code in the ASCII code table, mark it as the code judgment symbol, if the code judgment symbol is an even number, output the first code signal; if the code judgment symbol is an odd number, output the second code signal;

[0026] Convert the encrypted code into binary code based on the ASCII code table and mark it as the code to be executed;

[0027] Count the number of digits "1" and "0" in the code to be executed, marking them as the first digital number and the second digital number respectively;

[0028] Convert the user id and the first expiration time into hexadecimal codes according to the ASCII code table, and mark them as id code and time code respectively, wherein the hexadecimal code obtained after converting each character in the user id is named as id element code, and the hexadecimal code obtained after converting each character in the first expiration time is named as time element code;

[0029] The user ID and the first expiration time are encrypted based on the output first coded signal and the second coded signal.

[0030] Further, encrypting the user ID and the first expiration time based on the output first coded signal and the second coded signal includes the following sub-steps:

[0031] If the first coding signal is output, each ID element code in the ID code is increased by the first digital number and subtracted from the second digital number, and the ID update code is obtained after the calculation is completed; each time element code in the time code is increased by the second digital number and subtracted from the first digital number, and the time update code is obtained after the calculation is completed;

[0032] Set the coding rules, change the numbers in the ID update code and the time update code to letters. The letters corresponding to the numbers 0 to 9 are P, H, Y, I, K, S, L, N, V, and G, respectively. The letters corresponding to the numbers -1 to -9 are O, R, T, J, M, W, Q, Z, and X, respectively.

[0033] After the encoding rule is set, convert the letters corresponding to the odd numbers in the ID update code and the time update code into lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time;

[0034] If the second coding signal is output, each ID element code in the ID code is increased by the second digital number and subtracted from the first digital number, and the ID update code is obtained after the calculation is completed; each time element code in the time code is increased by the first digital number and subtracted from the second digital number, and the time update code is obtained after the calculation is completed;

[0035] Set the encoding rules, change the numbers in the ID update code and the time update code to letters. The letters corresponding to the numbers 0 to 9 are U, O, R, T, J, M, W, Q, Z, and X, respectively. The letters corresponding to the numbers -1 to -9 are H, Y, I, K, S, L, N, V, and G, respectively.

[0036] After the encoding rules are set, the letters corresponding to the even numbers in the ID update code and the time update code are converted to lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time.

[0037] Further, after the encryption is completed, the encrypted code is encoded and encrypted to obtain the encrypted code, and a refresh_Token is generated and stored in the local storage. The encrypted code, the encrypted ID and the encrypted expiration time are combined to obtain the access token, including the following sub-steps:

[0038] Number each character in the encrypted code from left to right to obtain a character number, which is represented by the symbol Sn, where n is a positive integer and n is the sequence number of the character number;

[0039] Based on the ASCII encoding table, the character corresponding to Sn is converted into an eight-bit binary code to obtain Bn, where n corresponds to n in Sn;

[0040] In the order of n being 1 to 6, add Bn to “00100000”, “00010000”, “00001000”, “00000100”, “00000010” and “00000001” respectively to obtain Pn, where n corresponds to n in Bn;

[0041] Based on the ASCII encoding table, convert Pn into characters and concatenate them in order of n from small to large to obtain the encrypted code;

[0042] Combine the encrypted code, encrypted ID, and encrypted expiration time in the format of "encrypted code. encrypted ID. encrypted expiration time" to obtain an access token, and send the access token to the application;

[0043] A refresh_Token is generated and stored in the local storage, wherein the refresh_Token stores the second expiration time.

[0044] Furthermore, when the user needs to jump to a browsing page, the application needs to obtain the user information of the user in the server. At this time, the application carries a token when sending a request to the server. The application receives the token and verifies the validity of the token. After the verification is passed, the user information authorization provided to the jump page includes the following sub-steps:

[0045] When the user needs to jump to a browsing page, the application sends a request to the server with the access token;

[0046] Receive the access token, which consists of an encrypted code, an encrypted ID, and an encrypted expiration time. Obtain the encrypted code and the encrypted expiration time.

[0047] Decrypt the encrypted code to obtain the decrypted code;

[0048] Decrypting the encrypted expiration time based on the decryption code to obtain a first expiration time;

[0049] Get the current time, mark it as real time, and compare whether the real time exceeds the first expiration time. If the real time exceeds the first expiration time, output the refresh_Token verification signal; if the real time does not exceed the first expiration time, output the Token validity signal;

[0050] Step S406: If a token validity signal is output, the encrypted ID is decrypted to obtain the user ID and apply for the user information;

[0051] If the refresh_Token verification signal is output, the request is verified through the refresh_Token.

[0052] Furthermore, verifying this request through refresh_Token includes the following sub-steps:

[0053] Get the second expiration time of refresh_Token from local storage;

[0054] Compare whether the real-time time exceeds the second expiration time. If the real-time time exceeds the second expiration time, output a Token expiration signal; if the real-time time does not exceed the second expiration time, output a Token update signal;

[0055] If the Token update signal is output, a new access Token and refresh_Token are generated, and the encrypted ID is decrypted to obtain the user ID and apply for the user's user information; if the Token expiration signal is output, the 401 interface is returned.

[0056] In a second aspect, the present application provides an authentication system for single sign-on based on Token verification, including a user login module, a login verification module, a Token generation module and a Token verification module; the user login module, the login verification module and the Token verification module are respectively connected to the data of the Token generation module;

[0057] The user login module is used for the user to log in to the server;

[0058] The login verification module is used to verify whether the user's login information is valid;

[0059] The Token generation module is used to generate a Token and send it to the application when the login information is valid;

[0060] The Token verification module is used when the user needs to jump to a browsing page and the application needs to obtain the user information of the user in the server. At this time, the application carries the Token when sending a request to the server. The application receives the Token and verifies the validity of the Token. After the verification passes, the user's information authorization is provided to the jump page.

[0061] Beneficial effects of the present invention: The present invention verifies the user's login information, randomly extracts an encryption code from the code database after the verification, and encrypts the user ID and the first expiration time through the encryption code. The advantage is that the encryption code can be prevented from being leaked and cracked by the encryption code, thereby improving the security of Token verification;

[0062] The present invention generates an access token by encrypting the encryption code, user ID and the first expiration time. When the user needs to jump, the access token is verified and the user information is obtained. The advantage is that the traditional token verification usually consists of three parts: header, payload and signature, and the characters stored therein are usually more, which will occupy more bandwidth. The access token provided by the present invention meets the lightweight standard, and meets the same or even better token verification requirements with the least characters, thereby improving the accuracy of single sign-on authentication verification and the efficiency of token verification.

[0063] The present invention adopts a more convenient encryption algorithm for encryption during the generation process of the access Token, and encodes the access Token based on a unique encoding rule. The advantage is that, different from the existing encoding method, the encoding rule of the present invention adopts unordered encoding, which improves the security of the access Token. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 is a flow chart of the steps of the method of the present invention;

[0065] Figure 2 A schematic diagram of an application of the present invention requesting user information from a server;

[0066] Figure 3 The encryption flow chart of the encrypted ID and the encrypted expiration time of the present invention;

[0067] Figure 4 It is a functional block diagram of the system of the present invention. DETAILED DESCRIPTION

[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0069] Example 1, please refer to Figure 1 As shown, in the first aspect, the present application provides an authentication method for single sign-on based on Token verification, comprising the following steps:

[0070] See also Figure 2 As shown, in step S1, the user logs in to the server; step S1 includes the following sub-steps:

[0071] Step S101, the user opens the server and enters the login page;

[0072] Step S102, the user enters an account name;

[0073] Step S103, the user enters the account password;

[0074] In a specific implementation, the user's login adopts the existing technology, and the account name "admin123" and the account password "password123" entered by the user are obtained.

[0075] Step S2, verifying whether the user's login information is valid; Step S2 includes the following sub-steps:

[0076] Step S201, reading the account information database;

[0077] Step S202, searching the account information database for account data with the same account name, if so, outputting a password confirmation signal; if not, outputting an account error signal;

[0078] Step S203, if a password confirmation signal is output, the account data identical to the account name is marked as comparison data, and the password data corresponding to the comparison data is compared with the account password. If the password data is identical to the account password, a login success signal is output; if the password data is different from the account password, a password error signal is output;

[0079] In the specific implementation, the account information database is stored in the background database of the server and is used to confirm the user's login information. By searching, it is found that there is an account "admin123" in the account information database, and a password confirmation signal is output. The password data corresponding to admin123 in the account information database is obtained as "password123". By comparison, it is found that the password data is the same as the account password, and a login success signal is output.

[0080] See also Figure 3 As shown, in step S3, when the login information is valid, a Token is generated and sent to the application; step S3 includes the following sub-steps:

[0081] Step S301, Token includes access token and refresh_Token; when a login success signal is output, the current time is obtained and marked as the issuance time;

[0082] Step S302, randomly extracting an encryption code from a code database, the encryption code being a six-character code consisting of random uppercase letters and numbers;

[0083] Step S303, setting the expiration time of the access token, marking it as the first expiration time, calculating the expiration time of the access token by adding the issuance time to the first expiration time, marking it as the first expiration time;

[0084] In the specific implementation, a login success signal was output, the issuance time was obtained as 13:24:36, the first expiration time was set to 20 minutes, the first expiration time was calculated to be 13:44:36, and the encryption code obtained by random sampling was "ABC123";

[0085] Step S304, encrypting the user ID and the first expiration time by encryption coding to obtain an encrypted ID and an encrypted expiration time;

[0086] Step S304 includes the following sub-steps:

[0087] Step S3041, obtaining the decimal number corresponding to the last character of the encryption code in the ASCII code table, marking it as a code determination symbol, if the code determination symbol is an even number, outputting a first code signal; if the code determination symbol is an odd number, outputting a second code signal;

[0088] Step S3042, converting the encrypted code into binary code based on the ASCII code table and marking it as code to be executed;

[0089] In a specific implementation, the last character of the encrypted code is 3, and the corresponding decimal number in the ASCII code table is 51, which is an odd number, so the second coding signal is output; the encrypted code is converted into a binary code to obtain the code to be executed as "010000010100001001000011001100010011001000110011";

[0090] Step S3043, counting the number of digits "1" and "0" in the code to be executed, marking them as the first digital number and the second digital number respectively;

[0091] Step S3044, converting the user id and the first expiration time into hexadecimal codes according to the ASCII code table, and marking them as id code and time code respectively, wherein the hexadecimal code obtained after converting each character in the user id is named as id element code, and the hexadecimal code obtained after converting each character in the first expiration time is named as time element code;

[0092] In the specific implementation, the first digital number is 17, and the second digital number is 31; the user id obtained is User123, including the characters U, s, e, r, 1, 2 and 3, which are converted into hexadecimal codes to obtain id element codes of 55, 73, 65, 72, 1, 2 and 3 in sequence; the combined id code is 55736572123; the first expiration time is 13:44:36, including the characters 1, 3, :, 4, 4, :, 3 and 6, which are converted into hexadecimal codes to obtain time element codes of 1, 3, 3A, 4, 4, 3A, 3 and 6 in sequence, and the combined time code is 133A443A36;

[0093] Step S3045, encrypting the user ID and the first expiration time based on the output first coded signal and the second coded signal;

[0094] Step S3045 includes the following sub-steps:

[0095] Step S3045.1, if the first coding signal is output, then each ID element code in the ID code is increased by the first digital number and subtracted from the second digital number, and after the calculation is completed, the ID update code is obtained; each time element code in the time code is increased by the second digital number and subtracted from the first digital number, and after the calculation is completed, the time update code is obtained;

[0096] Step S3045.2, set the coding rules, change the numbers in the ID update code and the time update code to letters, the letters corresponding to the numbers 0 to 9 are P, H, Y, I, K, S, L, N, V ​​and G, and the letters corresponding to the numbers -1 to -9 are O, R, T, J, M, W, Q, Z and X;

[0097] Step S3045.3, after the coding rule is set, convert the letters corresponding to the odd numbers in the ID update code and the time update code into lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time;

[0098] Step S3045.4, if the second coded signal is output, then each ID element code in the ID code is increased by the second digital number and subtracted from the first digital number, and after the calculation is completed, the ID update code is obtained; each time element code in the time code is increased by the first digital number and subtracted from the second digital number, and after the calculation is completed, the time update code is obtained;

[0099] Step S3045.5, set the coding rules, change the numbers in the ID update code and the time update code to letters, the letters corresponding to the numbers 0 to 9 are U, O, R, T, J, M, W, Q, Z and X, and the letters corresponding to the numbers -1 to -9 are H, Y, I, K, S, L, N, V ​​and G;

[0100] Step S3045.6, after the encoding rule is set, convert the letters corresponding to the even numbers in the ID update code and the time update code into lowercase according to the hexadecimal encoding to obtain the encrypted ID and the encrypted expiration time;

[0101] In the specific implementation, since the second coded signal is output, the processing process corresponding to the first coded signal is no longer specifically described in this embodiment. The id element codes in the id code are 55, 73, 65, 72, 1, 2 and 3, respectively. The id update codes obtained by adding the second digital number and subtracting the first digital number are 69, 87, 79, 86, 15, 16 and 17, respectively. The id update codes obtained based on the coding rule change are WX, ZQ, QX, ZW, OM, OW and OQ, respectively; the time element codes in the time code are 1, 3, 3A, 4, 4, 3A, 3 and 6, respectively. The time update codes obtained by subtracting the first digit from the second digit are 15, 17, 4E, 18, 18, 4E, 17 and 20 respectively. The time update codes obtained based on the coding rule are OM, OQ, JE, OZ, OZ, JE and RU respectively. In the coding rule, the numbers corresponding to U, R, J, W and Z are even numbers. In the hexadecimal code, the numbers corresponding to B, D and F are even numbers. Therefore, U, R, J, W, Z, B, D and F are converted to lowercase, and the encrypted id is wXzQQXzWOMOwOQ, and the encrypted time is OMOQjEOzOzjEru.

[0102] Step S305, after the encryption is completed, the encrypted code is encoded and encrypted to obtain the encrypted code, and refresh_Token is generated and stored in the local storage, and the encrypted code, the encrypted ID and the encrypted expiration time are combined to obtain the access token;

[0103] Step S305 includes the following sub-steps:

[0104] Step S3051, numbering each character in the encrypted code from left to right to obtain a character number, represented by the symbol Sn, where n is a positive integer and n is the sequence number of the character number;

[0105] Step S3052, converting the character corresponding to Sn into an eight-bit binary code based on the ASCII encoding table to obtain Bn, where n corresponds to n in Sn;

[0106] In a specific implementation, the encryption code is "ABC123", the numbers S1 to S6 are A, B, C, 1, 2 and 3 respectively, and the codes converted B1 to B6 are 01000001, 01000010, 01000011, 00110001, 00110010 and 00110011 respectively;

[0107] Step S3053, in the order of n being equal to 1 to 6, add Bn to "00100000", "00010000", "00001000", "00000100", "00000010" and "00000001" respectively to obtain Pn, where n corresponds to n in Bn;

[0108] In a specific implementation, 01000001 is added to 00100000, and P1 is 01100001; 01000010 is added to 00010000, and P2 is 01010010; 01000011 is added to 00001000, and P3 is 01001010; 00110001 is added to 00000100, and P4 is 00110101; 00110010 is added to 00000010, and P5 is 00110100; 00110011 is added to 00000001, and P6 is 00110100;

[0109] Step S3054, convert Pn into characters based on the ASCII encoding table and concatenate them in order of n from small to large to obtain an encrypted code;

[0110] Step S3055: Combine the encrypted code, encrypted ID, and encrypted expiration time in the format of "encrypted code. encrypted ID. encrypted expiration time" to obtain an access token, and send the access token to the application;

[0111] Step S3056, generating a refresh_Token and storing it in the local storage, wherein the refresh_Token stores the second expiration time;

[0112] In the specific implementation, Pn is converted into characters based on the ASCII encoding table to obtain P1 to P6, which are a, R, J, 5, 4 and 4 respectively. The encrypted code is concatenated as aRJ544, and the access Token is combined as "aRJ544.wXzQQXzWOMOwOQ.OMOQjEOzOzjEru". Since refresh_Token is only stored in local storage, there is no need to consider bandwidth usage and storage issues. Therefore, refresh_Token is generated using the existing refresh_Token technology.

[0113] Step S4: When the user needs to jump to a browsing page, the application needs to obtain the user information of the user in the server. At this time, the application carries a token when sending a request to the server. The application receives the token and verifies the validity of the token. After the verification is passed, the user's information authorization is provided to the jump page. Step S4 includes the following sub-steps:

[0114] Step S401: When a user needs to jump to a browsing page, the application sends a request to the server with an access token.

[0115] Step S402, receiving an access token, the access token consists of an encrypted code, an encrypted ID, and an encrypted expiration time, and obtaining the encrypted code and the encrypted expiration time;

[0116] Step S403, decrypting the encrypted code to obtain a decrypted code;

[0117] Step S404, decrypting the encrypted expiration time based on the decryption code to obtain a first expiration time;

[0118] Step S405, obtain the current time, mark it as real time, and compare whether the real time exceeds the first expiration time. If the real time exceeds the first expiration time, output a refresh_Token verification signal; if the real time does not exceed the first expiration time, output a Token valid signal;

[0119] Step S406: If a token validity signal is output, the encrypted ID is decrypted to obtain the user ID and apply for the user information;

[0120] In a specific implementation, the received access Token is "aRJ544.wXzQQXzWOMOwOQ.OMOQjEOzOzjEru", wherein the encrypted code is "aRJ544", the encrypted expiration time is "OMOQjEOzOzjEru", the process of decrypting the encrypted code is opposite to the encryption process of the encrypted code, so it is not specifically demonstrated in this embodiment, the decrypted code is "ABC123", the encrypted expiration time is decrypted by ABC123, the decryption process of the encrypted expiration time is opposite to the encryption process of the first expiration time, so it is not specifically demonstrated in this embodiment, the first expiration time is 13:44:36 after decryption, the real-time time is 13:49:24, the real-time time is compared to exceed the first expiration time, and the refresh_Token verification signal is output;

[0121] Step S407: If a refresh_Token verification signal is output, the request is verified through refresh_Token;

[0122] Step S407 includes the following sub-steps:

[0123] Step S4071, obtaining the second expiration time of refresh_Token from local storage;

[0124] Step S4072, comparing whether the real-time time exceeds the second expiration time, if the real-time time exceeds the second expiration time, outputting a Token expiration signal; if the real-time time does not exceed the second expiration time, outputting a Token update signal;

[0125] Step S4073: if a token update signal is output, a new access token and refresh_Token are generated, the encrypted ID is decrypted, the user ID is obtained, and the user information of the user is requested; if a token expiration signal is output, the interface 401 is returned;

[0126] In the specific implementation, since the refresh_Token verification signal is output, the refresh_Token is obtained from the local storage and the second expiration time of the refresh_Token is 2024.05.12, and the real time is 13:49:24 on 2024.05.05. By comparing the dates, it is obtained that the real time does not exceed the second expiration time, so the Token update signal is output, and the access Token and refresh_Token are regenerated. The encrypted id is then decrypted to obtain the user id "admin12", and the user information of the user is requested from the server through the user id.

[0127] Embodiment 2: This embodiment differs from Embodiment 1 in that Embodiment 1 only explains the analysis process of the second coded signal, while this embodiment is used to supplement the analysis process of the first coded signal. The encryption code in this embodiment is "ABC124", and the first coded signal is output through analysis.

[0128] Step S3041, obtaining the decimal number corresponding to the last character of the encryption code in the ASCII code table, marking it as a code determination symbol, if the code determination symbol is an even number, outputting a first code signal; if the code determination symbol is an odd number, outputting a second code signal;

[0129] Step S3042, converting the encrypted code into binary code based on the ASCII code table and marking it as code to be executed;

[0130] In a specific implementation, the last character of the encryption code is 4, and the corresponding decimal number in the ASCII code table is 52, which is an even number, so the first coding signal is output; the encryption code is converted into a binary code to obtain the code to be executed as "010000010100001001000011001100010011001000110100";

[0131] Step S3043, counting the number of digits "1" and "0" in the code to be executed, marking them as the first digital number and the second digital number respectively;

[0132] Step S3044, converting the user id and the first expiration time into hexadecimal codes according to the ASCII code table, and marking them as id code and time code respectively, wherein the hexadecimal code obtained after converting each character in the user id is named as id element code, and the hexadecimal code obtained after converting each character in the first expiration time is named as time element code;

[0133] In the specific implementation, the first digital number is 16 and the second digital number is 32. The user id obtained is User123, including the characters U, s, e, r, 1, 2 and 3. The id element codes converted into hexadecimal codes are 55, 73, 65, 72, 1, 2 and 3 in sequence. The combined id code is 55736572123. The first expiration time is 13:44:36, including the characters 1, 3, :, 4, 4, :, 3 and 6. The time element codes converted into hexadecimal codes are 1, 3, 3A, 4, 4, 3A, 3 and 6 in sequence. The combined time code is 133A443A36.

[0134] Step S3045, encrypting the user ID and the first expiration time based on the output first coded signal and the second coded signal;

[0135] Step S3045 includes the following sub-steps:

[0136] Step S3045.1, if the first coding signal is output, then each ID element code in the ID code is increased by the first digital number and subtracted from the second digital number, and after the calculation is completed, the ID update code is obtained; each time element code in the time code is increased by the second digital number and subtracted from the first digital number, and after the calculation is completed, the time update code is obtained;

[0137] Step S3045.2, set the coding rules, change the numbers in the ID update code and the time update code to letters, the letters corresponding to the numbers 0 to 9 are P, H, Y, I, K, S, L, N, V ​​and G, and the letters corresponding to the numbers -1 to -9 are O, R, T, J, M, W, Q, Z and X;

[0138] Step S3045.3, after the coding rule is set, convert the letters corresponding to the odd numbers in the ID update code and the time update code into lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time;

[0139] In a specific implementation, a first coding signal is output, the id element codes in the id code are 55, 73, 65, 72, 1, 2 and 3 in sequence, the id update codes obtained by adding the first digital number and subtracting the second digital number are 39, 57, 49, 56, -15, -14 and -13 in sequence, and the id update codes obtained based on the coding rule change are IG, SN, KG, SL, OS, OK and OI in sequence; the time element codes in the time code are 1, 3, 3A, 4, 4, 3A, 3 and 6 in sequence, and the time update codes obtained by adding the first digital number and subtracting the second digital number are -15, -13, 24, -12, -12, 24, -13 and -10. The time update codes changed based on the coding rules are OS, OI, YK, OY, OY, OI and OP respectively. In the coding rules, the numbers corresponding to P, Y, K, L, V, R, J, W and Z are even numbers. In the hexadecimal code, the numbers corresponding to B, D and F are even numbers. Therefore, P, Y, K, L, V, R, J, W, Z, B, D and F are converted to lowercase, and the encrypted id is IGSNkGSlOSOkOI, and the encrypted time is OSOIykOyOyOIOp.

[0140] Example 3, please refer to Figure 4 As shown, in the second aspect, the present application provides an authentication system for single sign-on based on Token verification, including a user login module, a login verification module, a Token generation module and a Token verification module; the user login module, the login verification module and the Token verification module are respectively connected to the Token generation module data;

[0141] The user login module is used for users to log in to the server;

[0142] The user login module is configured with user login policies, which include:

[0143] The user opens the server and enters the login page;

[0144] User enters account name;

[0145] The user enters the account password;

[0146] The login verification module is used to verify whether the user's login information is valid;

[0147] The login verification module is configured with a login verification policy, which includes:

[0148] Read the account information database;

[0149] Check whether there is account data with the same account name in the account information database. If it exists, a password confirmation signal is output; if it does not exist, an account error signal is output;

[0150] If a password confirmation signal is output, the account data identical to the account name is marked as comparison data, and the password data corresponding to the comparison data is compared with the account password. If the password data is identical to the account password, a login success signal is output; if the password data is different from the account password, a password error signal is output;

[0151] The Token generation module is used to generate a Token and send it to the application when the login information is valid; the Token generation module includes an initial generation unit, a coding processing unit, a coding encryption unit and a Token generation unit;

[0152] The initial generation unit is configured with an initial generation strategy, which includes:

[0153] Token includes access token and refresh_Token. When the login success signal is output, the current time is obtained and marked as the issuance time.

[0154] Randomly extract an encrypted code from the code database, where the encrypted code is a six-character code consisting of random uppercase letters and numbers;

[0155] Set the expiration time of the access token, mark it as the first expiration time, calculate the expiration time of the access token by adding the issuance time to the first expiration time, and mark it as the first expiration time;

[0156] Encrypt the user ID and the first expiration time by encryption coding to obtain an encrypted ID and an encrypted expiration time;

[0157] After encryption is completed, the encrypted code is encoded and encrypted to obtain the encrypted code. At the same time, a refresh_Token is generated and stored in the local storage. The encrypted code, the encrypted ID and the encrypted expiration time are combined to obtain the access token.

[0158] The encoding processing unit is configured with an encoding processing strategy, which includes:

[0159] Obtain the decimal number corresponding to the last character of the encryption code in the ASCII code table, mark it as the code judgment symbol, if the code judgment symbol is an even number, output the first code signal; if the code judgment symbol is an odd number, output the second code signal;

[0160] Convert the encrypted code into binary code based on the ASCII code table and mark it as the code to be executed;

[0161] Count the number of digits "1" and "0" in the code to be executed, marking them as the first digital number and the second digital number respectively;

[0162] Convert the user id and the first expiration time into hexadecimal codes according to the ASCII code table, and mark them as id code and time code respectively, wherein the hexadecimal code obtained after converting each character in the user id is named as id element code, and the hexadecimal code obtained after converting each character in the first expiration time is named as time element code;

[0163] Encrypting the user ID and the first expiration time based on the output first coded signal and the second coded signal;

[0164] The encoding and encryption unit is configured with an encoding and encryption strategy, which includes:

[0165] If the first coding signal is output, each ID element code in the ID code is increased by the first digital number and subtracted from the second digital number, and the ID update code is obtained after the calculation is completed; each time element code in the time code is increased by the second digital number and subtracted from the first digital number, and the time update code is obtained after the calculation is completed;

[0166] Set the coding rules, change the numbers in the ID update code and the time update code to letters. The letters corresponding to the numbers 0 to 9 are P, H, Y, I, K, S, L, N, V, and G, respectively. The letters corresponding to the numbers -1 to -9 are O, R, T, J, M, W, Q, Z, and X, respectively.

[0167] After the encoding rule is set, convert the letters corresponding to the odd numbers in the ID update code and the time update code into lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time;

[0168] If the second coding signal is output, each ID element code in the ID code is increased by the second digital number and subtracted from the first digital number, and the ID update code is obtained after the calculation is completed; each time element code in the time code is increased by the first digital number and subtracted from the second digital number, and the time update code is obtained after the calculation is completed;

[0169] Set the encoding rules, change the numbers in the ID update code and the time update code to letters. The letters corresponding to the numbers 0 to 9 are U, O, R, T, J, M, W, Q, Z, and X, respectively. The letters corresponding to the numbers -1 to -9 are H, Y, I, K, S, L, N, V, and G, respectively.

[0170] After the encoding rule is set, convert the letters corresponding to the even numbers in the ID update code and the time update code into lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time;

[0171] The token generation unit is configured with a token generation strategy, which includes:

[0172] Number each character in the encrypted code from left to right to obtain a character number, which is represented by the symbol Sn, where n is a positive integer and n is the sequence number of the character number;

[0173] Based on the ASCII encoding table, the character corresponding to Sn is converted into an eight-bit binary code to obtain Bn, where n corresponds to n in Sn;

[0174] In the order of n being 1 to 6, add Bn to “00100000”, “00010000”, “00001000”, “00000100”, “00000010” and “00000001” respectively to obtain Pn, where n corresponds to n in Bn;

[0175] Based on the ASCII encoding table, convert Pn into characters and concatenate them in order of n from small to large to obtain the encrypted code;

[0176] Combine the encrypted code, encrypted ID, and encrypted expiration time in the format of "encrypted code. encrypted ID. encrypted expiration time" to obtain an access token, and send the access token to the application;

[0177] Generate a refresh_Token and store it in local storage. The refresh_Token stores the second expiration time.

[0178] The Token verification module is used when the user needs to jump to a browsing page and the application needs to obtain the user information of the user in the server. At this time, the application carries the Token when sending a request to the server. The application receives the Token and verifies the validity of the Token. After the verification is passed, the user's information authorization is provided to the jump page. The Token verification module includes the access Token verification unit and the refresh_Token verification unit.

[0179] The access token verification unit is configured with an access token verification policy, which includes:

[0180] When the user needs to jump to a browsing page, the application sends a request to the server with the access token;

[0181] Receive the access token, which consists of an encrypted code, an encrypted ID, and an encrypted expiration time. Obtain the encrypted code and the encrypted expiration time.

[0182] Decrypt the encrypted code to obtain the decrypted code;

[0183] Decrypting the encrypted expiration time based on the decryption code to obtain a first expiration time;

[0184] Get the current time, mark it as real time, and compare whether the real time exceeds the first expiration time. If the real time exceeds the first expiration time, output the refresh_Token verification signal; if the real time does not exceed the first expiration time, output the Token validity signal;

[0185] Step S406: If a token validity signal is output, the encrypted ID is decrypted to obtain the user ID and apply for the user information;

[0186] If the refresh_Token verification signal is output, the request is verified through refresh_Token;

[0187] The refresh_Token verification unit is configured with a refresh_Token verification strategy, which includes:

[0188] Get the second expiration time of refresh_Token from local storage;

[0189] Compare whether the real-time time exceeds the second expiration time. If the real-time time exceeds the second expiration time, output a Token expiration signal; if the real-time time does not exceed the second expiration time, output a Token update signal;

[0190] If the Token update signal is output, a new access Token and refresh_Token are generated, and the encrypted ID is decrypted to obtain the user ID and apply for the user's user information; if the Token expiration signal is output, the 401 interface is returned.

[0191] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0192] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0193] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

Claims

1. A single sign-on authentication method based on Token verification, characterized in that: The steps include: The user logs in to the server; Verify that the user's login information is valid; When the login information is valid, a token is generated and sent to the application; When the login information is valid, generating a token and sending it to the application includes the following sub-steps: The token includes an access token and a refresh_Token. When a login success signal is output, the current time is obtained and marked as the issuance time. Randomly extract an encryption code from a code database, wherein the encryption code is a six-character code consisting of random uppercase letters and numbers; Set the expiration time of the access token, mark it as the first expiration time, calculate the expiration time of the access token by adding the issuance time to the first expiration time, and mark it as the first expiration time; Encrypt the user ID and the first expiration time by encryption coding to obtain an encrypted ID and an encrypted expiration time; After encryption is completed, the encrypted code is encoded and encrypted to obtain the encrypted code. At the same time, a refresh_Token is generated and stored in the local storage. The encrypted code, the encrypted ID and the encrypted expiration time are combined to obtain the access token. Encrypting the user ID and the first expiration time by encryption coding includes the following sub-steps: Obtain the decimal number corresponding to the last character of the encryption code in the ASCII code table, mark it as the code judgment symbol, if the code judgment symbol is an even number, output the first code signal; if the code judgment symbol is an odd number, output the second code signal; Convert the encrypted code into binary code based on the ASCII code table and mark it as the code to be executed; Count the number of digits "1" and "0" in the code to be executed, marking them as the first digital number and the second digital number respectively; Convert the user id and the first expiration time into hexadecimal codes according to the ASCII code table, and mark them as id code and time code respectively, wherein the hexadecimal code obtained after converting each character in the user id is named as id element code, and the hexadecimal code obtained after converting each character in the first expiration time is named as time element code; Encrypting the user ID and the first expiration time based on the output first coded signal and the second coded signal; When the user needs to jump to a browsing page, the application needs to obtain the user information of the user in the server. At this time, the application carries a token when sending a request to the server. The application receives the token and verifies the validity of the token. After the verification passes, the user's information authorization is provided to the jump page; Encrypting the user ID and the first expiration time based on the output first coded signal and the second coded signal includes the following sub-steps: If the first coding signal is output, each ID element code in the ID code is increased by the first digital number and subtracted from the second digital number, and the ID update code is obtained after the calculation is completed; each time element code in the time code is increased by the second digital number and subtracted from the first digital number, and the time update code is obtained after the calculation is completed; Set the coding rules, change the numbers in the ID update code and the time update code to letters. The letters corresponding to the numbers 0 to 9 are P, H, Y, I, K, S, L, N, V, and G, respectively. The letters corresponding to the numbers -1 to -9 are O, R, T, J, M, W, Q, Z, and X, respectively. After the encoding rule is set, convert the letters corresponding to the odd numbers in the ID update code and the time update code into lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time; If the second coding signal is output, each ID element code in the ID code is increased by the second digital number and subtracted from the first digital number, and the ID update code is obtained after the calculation is completed; each time element code in the time code is increased by the first digital number and subtracted from the second digital number, and the time update code is obtained after the calculation is completed; Set the encoding rules, change the numbers in the ID update code and the time update code to letters. The letters corresponding to the numbers 0 to 9 are U, O, R, T, J, M, W, Q, Z, and X, respectively. The letters corresponding to the numbers -1 to -9 are H, Y, I, K, S, L, N, V, and G, respectively. After the encoding rules are set, the letters corresponding to the even numbers in the ID update code and the time update code are converted to lowercase according to the hexadecimal code to obtain the encrypted ID and the encrypted expiration time.

2. According to the single sign-on authentication method based on Token verification according to claim 1, it is characterized in that: The user logs in to the server in the following steps: The user opens the server and enters the login page; User enters account name; The user enters the account password.

3. According to claim 2, a single sign-on authentication method based on Token verification is characterized in that: Verifying that the user's login information is valid includes the following sub-steps: Read the account information database; Check whether there is account data with the same account name in the account information database. If it exists, a password confirmation signal is output; if it does not exist, an account error signal is output; If a password confirmation signal is output, the account data that is the same as the account name will be marked as comparison data, and the password data corresponding to the comparison data will be compared with the account password. If the password data is the same as the account password, a login success signal will be output; if the password data is different from the account password, a password error signal will be output.

4. According to the single sign-on authentication method based on Token verification in claim 3, it is characterized in that: After encryption is completed, the encrypted code is encoded and encrypted to obtain the encrypted code, and refresh_Token is generated and stored in the local storage. The encrypted code, encrypted ID and encrypted expiration time are combined to obtain the access token, including the following sub-steps: Number each character in the encrypted code from left to right to obtain a character number, which is represented by the symbol Sn, where n is a positive integer and n is the sequence number of the character number; Based on the ASCII encoding table, the character corresponding to Sn is converted into an eight-bit binary code to obtain Bn, where n corresponds to n in Sn; In the order of n being 1 to 6, add Bn to "00100000", "00010000", "00001000", "00000100", "00000010" and "00000001" respectively to obtain Pn, where n corresponds to n in Bn; Based on the ASCII encoding table, convert Pn into characters and concatenate them in order of n from small to large to obtain the encrypted code; Combine the encrypted code, encrypted ID, and encrypted expiration time in the format of "encrypted code. encrypted ID. encrypted expiration time" to obtain an access token, and send the access token to the application; A refresh_Token is generated and stored in the local storage, wherein the refresh_Token stores the second expiration time.

5. According to the single sign-on authentication method based on Token verification according to claim 4, it is characterized in that: When the user needs to jump to a browsing page, the application needs to obtain the user information of the user in the server. At this time, the application carries a token when sending a request to the server. The application receives the token and verifies the validity of the token. After the verification is passed, the user information authorization provided to the jump page includes the following sub-steps: When the user needs to jump to a browsing page, the application sends a request to the server with the access token; Receive the access token, which consists of an encrypted code, an encrypted ID, and an encrypted expiration time. Obtain the encrypted code and the encrypted expiration time. Decrypt the encrypted code to obtain the decrypted code; Decrypting the encrypted expiration time based on the decryption code to obtain a first expiration time; Get the current time, mark it as real time, and compare whether the real time exceeds the first expiration time. If the real time exceeds the first expiration time, output the refresh_Token verification signal; If the real time does not exceed the first expiration time, a token validity signal is output; If the token is valid, the encrypted ID is decrypted to obtain the user ID and apply for the user's information. If the refresh_Token verification signal is output, the request is verified through the refresh_Token.

6. The authentication method for single sign-on based on Token verification according to claim 5, characterized in that: Verifying this request through refresh_Token includes the following sub-steps: Get the second expiration time of refresh_Token from local storage; Compare whether the real-time time exceeds the second expiration time. If the real-time time exceeds the second expiration time, output a token expiration signal; If the real time does not exceed the second expiration time, a Token update signal is output; If the Token update signal is output, a new access Token and refresh_Token are generated, and the encrypted ID is decrypted to obtain the user ID and apply for the user's user information; if the Token expiration signal is output, the 401 interface is returned.

7. A single sign-on authentication system based on Token verification, applicable to a single sign-on authentication method based on Token verification as claimed in any one of claims 1 to 6, characterized in that: It includes a user login module, a login verification module, a Token generation module and a Token verification module; the user login module, the login verification module and the Token verification module are respectively connected to the Token generation module data; The user login module is used for the user to log in to the server; The login verification module is used to verify whether the user's login information is valid; The Token generation module is used to generate a Token and send it to the application when the login information is valid; The Token verification module is used when the user needs to jump to a browsing page and the application needs to obtain the user information of the user in the server. At this time, the application carries the Token when sending a request to the server. The application receives the Token and verifies the validity of the Token. After the verification passes, the user's information authorization is provided to the jump page.

Citation Information

Cited By

  • Heterogeneous system organization user data synchronization method, system, device and medium

    CN119537473A