Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

通过传递参数进行身份验证

对于JSON API身份验证目的,可以将以下参数发布/附加到每个JSON API URL:

Authenticate by Passing Parameters

For JSON API authentication purposes, the following parameters can be posted/appended to each of the JSON API URLs:

  • j_username
  • j_password
  • hash

Example:
Assuming the username and password required is "user1" and "password1" respectively, we can post the username and password to the JSON API using following jQuery script.示例
假设用户名和密码分别为“user1”和“password1”,我们可以使用以下jQuery脚本将用户名和密码发布到JSON API。

Code Block
languagejs
<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'user1',
 				j_password : 'password1'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

If you prefer to use hashed password, you can use the following script.

如果您更喜欢使用哈希密码,则可以使用以下脚本。

Note

请注意,哈希密码上的支持是基于您正在使用的目录管理器。某些目录管理器插件可能不支持这种类型的身份验证方法。

每个目录管理器的格式和哈希方法也可能不同。

Note

Please note that the support on Hashed Password is based on the Directory Manager you are using. Some Directory Manager Plugin may not supporting this type of authentication method.

The format and hashing method may vary for each Directory Manager as well.

Code Block
languagejs
<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'user1',
 				hash : 'D012B772672A55A0B561EAA53CA7734E'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });

    });
</script>

 

Master Login Username and Password

When authentication using parameters, you are allowed to using a Master Credential to login as other user to performance workflow activities. 

To use it, set a Master Login Username and Master Login Password under System Settings > General Setting. By setting these values, a different user can be specified by passing in the "loginAs" parameter.

Note
Please note that only enable this when it is necessary. Leaking of your Master Credential will allows others to performs all the unwanted JSON API calls.

Image Removed

Assuming the master login username and master login password is "master" and "master" respectively, the master login hash will be "E505CF727D214A68CB03DA25DA978500".

主登录用户名和密码

使用参数进行身份验证时,您可以使用主身份凭证作为其他用户登录到性能工作流程活动。 

要使用它,请在系统设置  >  常规设置设置主登录用户名和主登录密码   通过设置这些值,可以通过传入“loginAs”参数来指定不同的用户。

Note

请注意,只有在必要时才启用。泄漏您的主证书将允许其他人执行所有不需要的JSON API调用。

Image Added

假设主登录用户名和主登录密码分别为“master”和“master”,则主登录哈希为“ E505CF727D214A68CB03DA25DA978500 ”。

以下示例展示了如何使用Master Credential以“user1”身份登录。The following example showcases how to use a Master Credential to login as "user1".

Code Block
languagejs
<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'master',
 				j_password : 'master',
 				loginAs : 'user1'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

Using master login hash:使用master登录哈希:

Code Block
languagejs
<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'master',
 				hash : 'E505CF727D214A68CB03DA25DA978500',
 				loginAs : 'user1'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

Basic Http Authentication

Since V4, Joget Workflow is suppoeted Basic HTTP Authentication in JSON API authentication, you can passing the credentials in the header.

基本的Http认证

从V4开始,  Joget工作流在JSON API认证中被支持基本的HTTP认证,你可以在头中传递凭证。

示例
假设所需的用户名和密码分别为“user1”和“password1”,我们可以使用以下jQuery脚本将Basic Auth头设置为JSON API。
Example:
Assuming the username and password required is "user1" and "password1" respectively, we can set the Basic Auth header to the JSON API using following jQuery script.

 

Code Block
languagejs
<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            beforeSend: function (xhr) {
    			xhr.setRequestHeader ("Authorization", "Basic dXNlcjE6cGFzc3dvcmQx");
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

...