AtlassianSpringbootJira插件在内部REST请求时返回401
创始人
2024-11-12 07:30:20
0

一种可能的解决方法是添加内部REST请求的权限。在您的插件的pom.xml文件中,需要添加以下依赖项:


    com.atlassian.plugins.rest
    atlassian-rest-common
    ${atlassian-rest-common.version}
    provided

然后,您可以使用以下代码在插件中进行内部REST请求:

import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
import com.atlassian.plugins.rest.common.security.AuthenticationRequiredException;
import com.atlassian.plugins.rest.common.security.CorsAllowed;
import com.atlassian.plugins.rest.common.security.RequestAuthenticationProvider;
import com.atlassian.plugins.rest.common.security.jersey.XsrfCheckInterceptor;
import com.atlassian.sal.api.pluginsettings.PluginSettings;

import javax.ws.rs.*;
import javax.ws.rs.core.Response;

@Path("/myresource")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public class MyResource {
    private final PluginSettingsFactory pluginSettingsFactory;

    public MyResource(PluginSettingsFactory pluginSettingsFactory) {
        this.pluginSettingsFactory = pluginSettingsFactory;
    }

    @GET
    @Path("/test")
    @AuthenticationRequired
    @XsrfCheck
    public Response test() {
        PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
        // Do something with plugin settings
        return Response.ok().build();
    }
}

请注意,您需要将插件设置工厂传递给该类的构造函数,以便可以在内部REST请求中访问插件设置。 另外,您需要为您的REST端点添加必要的身份验证和XSRF检查。

相关内容

热门资讯

黑科技辅助!fishpoker... 黑科技辅助!fishpoker正规,(鱼扑克俱乐部)原来真的有挂,解密教程(猫腻)-哔哩哔哩是一款可...
黑科技辅助!微扑克有辅助挂,(... 《黑科技辅助!微扑克有辅助挂,(微扑克ai智能)原来真的有挂,必胜教程(助手)-哔哩哔哩》 微扑克有...
黑科技辅助!wpk ai机器人... 黑科技辅助!wpk ai机器人,(WPK ai辅助)原来真的有挂,揭秘教程(秘籍)-哔哩哔哩;WPK...
黑科技辅助!wepoke算法,... 黑科技辅助!wepoke算法,(WePoKe参数)原来真的有挂,系统教程(有挂规律)-哔哩哔哩;一、...
黑科技辅助!wpk有ai,(W... 黑科技辅助!wpk有ai,(WPK发牌)原来真的有挂,解说技巧(功能)-哔哩哔哩是一款可以让一直输的...
黑科技辅助!wepoke智能a... 黑科技辅助!wepoke智能ai,(WePoKe支持)原来真的有挂,玩家教你(果真有挂)-哔哩哔哩;...
黑科技辅助!微扑克ai辅助工具... 您好:微扑克ai辅助这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的牌特...
黑科技辅助!wepoke有挂蓝... 黑科技辅助!wepoke有挂蓝鸟,(wepoke)原来真的有挂,2025新版教程(有挂神器)-哔哩哔...
黑科技辅助!wepoke可以看... 黑科技辅助!wepoke可以看有外挂,(WePoKe黑科技功能)原来真的有挂,我来教教你(真的有挂)...
黑科技辅助!wpk辅助插件,(... 黑科技辅助!wpk辅助插件,(WPK专用)原来真的有挂,辅助教程(头条)-哔哩哔哩是一款可以让一直输...