Custom OAuth 2.0 plugin development

I’m developing a custom plugin to integrate Jira 6.3.14 with an OAuth2 server.

First of all, as described here I changed seraph-confix.xml and extended JiraSeraphAuthenticator.

I overrode the method Principal getUser(HttpServletRequest request,
HttpServletResponse response). The first thing the method has to do is redirecting the user to the server to allow the user insert their credentials in a form via “response.sendRedirect(url);”. The method getUser however gets called more than once. The first time, response is not null but the following times it becomes null and when finally response.sendRedirect(url) gets called I have a NullpointerException. Whys isn’t this working? Do I have to change my web.xml in some way as well other than editing seraph-config.xml? can I perform a redirection inside the getUser method?

1 Like

Rather than messing around with JiraSeraphAuthenticator, you would be better off creating a new AppLinks application type that extends com.atlassian.applinks.spi.application.NonAppLinksApplicationType.

Have a look at the source code in the following two libraries:

    <dependency>
        <groupId>com.atlassian.applinks</groupId>
        <artifactId>applinks-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.applinks</groupId>
        <artifactId>applinks-spi</artifactId>
        <scope>provided</scope>
    </dependency>

Thanks for the hit, I’ll have a look at that. I have another question, should I develop my integration with Oauth2 as a jar to add to ‘lib’ or a Jira plugin?

Go with a plugin. Installation, upgrades, version management: all taken care of.