<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.2 20190208//EN" "http://jats.nlm.nih.gov/publishing/1.2/JATS-journalpublishing1.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="methods-article" dtd-version="1.2" xml:lang="en">
    <front>
        <journal-meta>
            <journal-id journal-id-type="pmc">F1000Research</journal-id>
            <journal-title-group>
                <journal-title>F1000Research</journal-title>
            </journal-title-group>
            <issn pub-type="epub">2046-1402</issn>
            <publisher>
                <publisher-name>F1000 Research Limited</publisher-name>
                <publisher-loc>London, UK</publisher-loc>
            </publisher>
        </journal-meta>
        <article-meta>
            <article-id pub-id-type="doi">10.12688/f1000research.13256.1</article-id>
            <article-categories>
                <subj-group subj-group-type="heading">
                    <subject>Method Article</subject>
                </subj-group>
                <subj-group>
                    <subject>Articles</subject>
                    <subj-group>
                        <subject>Bioinformatics</subject>
                    </subj-group>
                </subj-group>
            </article-categories>
            <title-group>
                <article-title>META-pipe Authorization service</article-title>
                <fn-group content-type="pub-status">
                    <fn>
                        <p>[version 1; peer review: 2 approved with reservations]</p>
                    </fn>
                </fn-group>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Raknes</surname>
                        <given-names>Inge Alexander</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Methodology</role>
                    <role content-type="http://credit.niso.org/">Software</role>
                    <role content-type="http://credit.niso.org/">Validation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Original Draft Preparation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <xref ref-type="aff" rid="a1">1</xref>
                </contrib>
                <contrib contrib-type="author" corresp="yes">
                    <name>
                        <surname>Bongo</surname>
                        <given-names>Lars Ailo</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Project Administration</role>
                    <role content-type="http://credit.niso.org/">Supervision</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Original Draft Preparation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-7544-2482</uri>
                    <xref ref-type="corresp" rid="c1">a</xref>
                    <xref ref-type="aff" rid="a2">2</xref>
                </contrib>
                <aff id="a1">
                    <label>1</label>Department of Chemistry, UiT - The Arctic University of Norway, Troms&#x00f8;, 9037, Norway</aff>
                <aff id="a2">
                    <label>2</label>Department of Computer Science, UiT - The Arctic University of Norway, Troms&#x00f8;, 9037, Norway</aff>
            </contrib-group>
            <author-notes>
                <corresp id="c1">
                    <label>a</label>
                    <email xlink:href="mailto:larsab@cs.uit.no">larsab@cs.uit.no</email>
                </corresp>
                <fn fn-type="conflict">
                    <p>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>9</day>
                <month>1</month>
                <year>2018</year>
            </pub-date>
            <pub-date pub-type="collection">
                <year>2018</year>
            </pub-date>
            <volume>7</volume>
            <elocation-id>ELIXIR-32</elocation-id>
            <history>
                <date date-type="accepted">
                    <day>4</day>
                    <month>1</month>
                    <year>2018</year>
                </date>
            </history>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2018 Raknes IA and Bongo LA</copyright-statement>
                <copyright-year>2018</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access article distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <self-uri content-type="pdf" xlink:href="https://f1000research.com/articles/7-32/pdf"/>
            <abstract>
                <p>We describe the design, implementation, and use of the META-pipe Authorization service. META-pipe is a complete workflow for the analysis of marine metagenomics data. We will provide META-pipe as a web based data analysis service for ELIXIR users. We have integrated our Authorization service with the ELIXIR Authorization and Authentication Infrastructure (AAI) that allows single sign-on to services across the ELIXIR infrastructure. We use the Authorization service to authorize access to data on the META-pipe storage system and jobs in the META-pipe job queue. Our Authorization server was among the first services that integrated with ELIXIR AAI. The code is open source at: 
                    <ext-link ext-link-type="uri" xlink:href="https://gitlab.com/uit-sfb/AuthService2">https://gitlab.com/uit-sfb/AuthService2</ext-link>.</p>
            </abstract>
            <kwd-group kwd-group-type="author">
                <kwd>ELIXIR AAI</kwd>
                <kwd>SAML</kwd>
                <kwd>OAuth 2.0</kwd>
                <kwd>Authorization</kwd>
                <kwd>Authentication</kwd>
            </kwd-group>
            <funding-group>
                <award-group id="fund-1" xlink:href="http://dx.doi.org/10.13039/100010661">
                    <funding-source>Horizon 2020 Framework Programme</funding-source>
                    <award-id>676559</award-id>
                </award-group>
                <award-group id="fund-2" xlink:href="http://dx.doi.org/10.13039/501100005416">
                    <funding-source>Norges Forskningsr&#x00e5;d</funding-source>
                    <award-id>208481</award-id>
                </award-group>
                <funding-statement>Funding was provided from ELIXIR and ELIXIR-Norway. ELIXIR received funding from the European Union&#x2019;s Horizon 2020 research and innovation program (ELIXIR- EXCELERATE, grant agreement 676559). ELIXIR-Norway is funded by the Research Council of Norway through the ELIXIR.NO project (grant number 208481).</funding-statement>
                <funding-statement>
                    <italic>The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.</italic>
                </funding-statement>
            </funding-group>
        </article-meta>
    </front>
    <body>
        <sec sec-type="intro">
            <title>Introduction</title>
            <p>ELIXIR brings together and coordinates European life science resources, including databases, software tools, training materials, cloud storage, and supercomputers. One of the resources developed in the ELIXIR-EXCELERATE project is META-pipe
                <sup>
                    <xref ref-type="bibr" rid="ref-1">1</xref>
                </sup>, an automated pipeline for annotation and analysis of metagenomic and genomic sequence data is targeted for marine metagenomics. We will provide META-pipe as a web based data analysis service for ELIXIR users.</p>
            <p>The ELIXIR Compute Platform builds distributed cloud, compute, storage, and access services for the life-science research community. An important part of the cloud platform is the geographically distributed Authentication &amp; Authorization Infrastructure (AAI) that provides services for identification, authentication, and authorization of ELIXIR end users. We have integrated our META-pipe Authorization service with the ELIXIR AAI, such that our users can use the single sign-on used across all ELIXIR services. Most users can sign-on using their home institution credentials; the remaining users can use Google, LinkedIn, or ORCID credentials. Our Authorization server was among the first services that integrated with ELIXIR AAI.</p>
            <p>In this paper, we describe the design, implementation, and use of the META-pipe Authorization service. It limits which services and users are authorized to access and modify META-pipe datasets and job results. It 
                <italic toggle="yes">authenticates</italic> users using ELIXIR AAI, and it 
                <italic toggle="yes">authorizes</italic> access to data on the META-pipe storage system and jobs in the META-pipe job queue. We therefore use it as ad-hoc authentication for our own services.</p>
            <p>We designed the META-pipe authorization service with three main design goals:</p>
            <list list-type="bullet">
                <list-item>
                    <label>1. </label>
                    <p>
                        <italic toggle="yes">Keep it simple and stupid</italic>; especially for creating new services.</p>
                </list-item>
                <list-item>
                    <label>2. </label>
                    <p>
                        <italic toggle="yes">Separation of concerns</italic>. Keep authentication and authorization separate from the other META-pipe backend services.</p>
                </list-item>
                <list-item>
                    <label>3. </label>
                    <p>
                        <italic toggle="yes">Stable interface</italic> to avoid doing the same work multiple times. We therefore use existing standards in the interaction between services as these are assumed to be reasonably defined and stable.</p>
                </list-item>
            </list>
            <p>Our solution is an external application decoupled from the rest of our services. It contains all the integration code needed to integrate with an external authentication service such as ELIXIR AAI, and it can be further be improved independent of the other META-pipe services. We also wanted it to be simple enough such that our small development team could implement it from scratch. We follow standards so we can re-use existing libraries and use proven, stable interfaces.</p>
            <p>Existing out-of-the-box solutions do not fulfill our requirements. For example, 
                <ext-link ext-link-type="uri" xlink:href="http://openid.net/connect/">OpenID Connect</ext-link> is a large standard with many mandatory parts that we do not need for our service. We have therefore chosen standards, libraries, and tools that are simple and developer friendly, and that can easily be incorporated in any framework/programming language combination as our services use Scala and Go, and Java.</p>
            <p>The rest of this paper describes the design and implementation of the server, how it is used by end-users and our backend services, and it gives an overview of the standards and libraries we have used. Finally, we outline ongoing and future work.</p>
        </sec>
        <sec sec-type="methods">
            <title>Methods</title>
            <p>This section summarizes the implementation and usage of the META-pipe authorization service. Additional details are in 
                <ext-link ext-link-type="uri" xlink:href="https://docs.google.com/document/d/1dlq23Q5N9xNLKjgolxug2hTRtI0zuZzHKuX_xfUo7Uo/edit">The META-pipe Authorization service design document</ext-link>.</p>
            <sec>
                <title>Design</title>
                <p>The authorization service fits into the context of the META-pipe backend that has two 
                    <italic toggle="yes">Clients</italic>: the 
                    <ext-link ext-link-type="uri" xlink:href="https://metapipe.uit.no/">web application</ext-link> and the 
                    <ext-link ext-link-type="uri" xlink:href="https://galaxy-uit.bioinfo.no/">Galaxy tool</ext-link>. In addition, the context has several services, including storage and job management services. We have integrated our Authorization server with the ELIXIR AAI, which provides user identities from the ELIXIR federated IDP for European educational and research institutions, Google, LinkedIn, and ORCID. Users therefore use the single sign on ELIXIR web interface, and we rely on ELIXIR AAI to maintain (the federated) user databases.</p>
                <p>Since some external IDPs, such as the Norwegian 
                    <ext-link ext-link-type="uri" xlink:href="https://www.feide.no/">Feide</ext-link> that is one of the federated ELIXIR AAI IDPs, requires single sign-out we needed a way to revoke tokens on a short notice. This requires a central service for validating tokens and is one of the reasons we chose to use 
                    <italic toggle="yes">Token Introspection</italic> over 
                    <italic toggle="yes">JWT Bearer Tokens</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7523">RFC-7523</ext-link>).</p>
                <p>The authorization server implements the 
                    <italic toggle="yes">Authorization Code Grant</italic> in the 
                    <italic toggle="yes">OAuth 2.0 Authorization Framework</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6749">RFC-6749</ext-link>) (
                    <xref ref-type="fig" rid="f1">Figure 1</xref>). The server uses 
                    <italic toggle="yes">OAuth 2.0 Bearer Tokens</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>) as the access tokens since the 
                    <italic toggle="yes">Bearer Tokens</italic> are well supported by software libraries and they are required by the 
                    <italic toggle="yes">Token Introspection</italic> specification. In addition, the server implements an 
                    <italic toggle="yes">OAuth 2.0 Token Introspection</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7662">RFC-7662</ext-link>) endpoint that the 
                    <italic toggle="yes">Resource Servers</italic> can use to introspect the tokens, whereby getting information about what can be accessed and if the token is still valid.</p>
                <fig fig-type="figure" id="f1" orientation="portrait" position="float">
                    <label>Figure 1. </label>
                    <caption>
                        <title>META-pipe Authorization service used by the META-pipe web application.</title>
                        <p>The Authorization service is integrated with ELIXIR AAI. It is implemented to isolate the integration to the authorization server. We expose a REST API for the clients. The clients do not know about ELIXIR AAI.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14381/c7e6450a-7993-4026-997f-8a77d6df8c42_figure1.gif"/>
                </fig>
                <p>Our Meta-pipe web application stores the 
                    <italic toggle="yes">Access Tokens</italic> and 
                    <italic toggle="yes">Refresh Tokens</italic> in the browser's local storage.</p>
                <p>In OAuth 2.0 the 
                    <italic toggle="yes">Access Token Scope</italic> is defined by the Authorization server. Since we use a REST architecture for our services, each resource has its own URI. We have defined the 
                    <italic toggle="yes">Access Token Scope</italic> such that a 
                    <italic toggle="yes">Resource Server</italic> can determine if a request is authorized by comparing the 
                    <italic toggle="yes">Access Token Scope</italic> with the requested URI and method.</p>
            </sec>
            <sec>
                <title>Integration with ELIXIR AAI</title>
                <p>We have integrated the META-pipe Authorization service with ELIXIR AAI. We use the 
                    <italic toggle="yes">OAuth 2.0 Authorization Code Grant</italic> since it is flexible enough to isolate the integration to the authorization server. We can therefore implement our 
                    <italic toggle="yes">Clients</italic> without them having to know neither about SAML nor ELIXIR AAI. We cannot use standards such as 
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7522">RFC-7522</ext-link> (
                    <italic toggle="yes">Security Assertion Markup Language (SAML) 2.0 Profile for OAuth2.0 Client Authentication and Authorization Grants</italic>) and the more general 
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7521">RFC-7521</ext-link> (
                    <italic toggle="yes">Assertion Framework for OAuth 2.0 Client Authentication and Authorization Grants</italic>), since these require the 
                    <italic toggle="yes">Client</italic> to directly interact with the 
                    <italic toggle="yes">Issuer</italic> and hence both the 
                    <italic toggle="yes">Client</italic> and the Authorization server need to know SAML and how to interact with the ELIXIR AAI. Another benefit of the 
                    <italic toggle="yes">Authorization Code Grant</italic> is that it has very good software library support.</p>
                <p>A client using the 
                    <italic toggle="yes">OAuth 2.0 Authorization Code Grant</italic> redirects the 
                    <italic toggle="yes">User Agent</italic> to the 
                    <italic toggle="yes">Authorization Endpoint</italic> and then, after the 
                    <italic toggle="yes">Resource Owner</italic> has authorized the request, the 
                    <italic toggle="yes">User Agent</italic> is redirected to a URI defined by the 
                    <italic toggle="yes">Client</italic> where an 
                    <italic toggle="yes">Authorization Code</italic> is included in the URI query parameter. The 
                    <italic toggle="yes">Client</italic> can then exchange this 
                    <italic toggle="yes">Authorization Code</italic> for an 
                    <italic toggle="yes">Access Token and a Refresh Token</italic> by querying the 
                    <italic toggle="yes">Token Endpoint</italic>.</p>
                <p>While 
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6749">RFC-6749</ext-link> specifies how the 
                    <italic toggle="yes">Client</italic> interacts with the 
                    <italic toggle="yes">Authorization Server</italic>, it does not specify how the 
                    <italic toggle="yes">Authorization Endpoint</italic> obtains an authorization from the 
                    <italic toggle="yes">Resource Owner</italic>; this is left to the implementer of the 
                    <italic toggle="yes">Authorization Endpoint</italic>. Therefore, once the 
                    <italic toggle="yes">User Agent</italic> has been redirected to the 
                    <italic toggle="yes">Authorization Endpoint</italic> we can perform the authentication process that is required by the ELIXIR AAI (including any 
                    <italic toggle="yes">Use Agent</italic> interactions/redirects) if we are able to redirect the 
                    <italic toggle="yes">User Agent</italic> to the URI specified by the 
                    <italic toggle="yes">Client</italic> after the user has been authenticated.</p>
            </sec>
            <sec>
                <title>Integration with ELIXIR-Norway Galaxy/Feide</title>
                <p>ELIXIR-Norway uses Galaxy as a common GUI for the analysis services provided for Norwegian users: 
                    <ext-link ext-link-type="uri" xlink:href="https://nels.bioinfo.no/">https://nels.bioinfo.no/</ext-link>. The Galaxy users are authenticated using the 
                    <ext-link ext-link-type="uri" xlink:href="https://www.feide.no/">Feide authentication infrastructure</ext-link> (
                    <ext-link ext-link-type="uri" xlink:href="https://www.feide.no/sites/feide.no/files/documents/feide_technical_guide.pdf">Feide technical guide</ext-link>, 
                    <ext-link ext-link-type="uri" xlink:href="https://www.feide.no/sites/feide.no/files/documents/feide_integration_guide.pdf">Feide integration guide</ext-link>) that is used by all Norwegian universities. We have integrated our ELIXIR-Norway Galaxy using an Apache HTTPD reverse proxy with AuthMemcookie and SimpleSAMLPHP. The Apache HTTPD proxies authenticated requests to the Galaxy web application with an HTTP header used to specify who is logged in.</p>
                <p>A Galaxy tool is defined by an XML file that describes how to launch a process and how the process' arguments should be presented in the Galaxy GUI. The tool developer maps every relevant parameter to a command line that Galaxy executes when the user runs the tool. The parameters include parameters selected by the user in the web GUI as well as a few contextual parameters, like the user's email address that is retrieved from Feide when the user authenticates.</p>
            </sec>
            <sec>
                <title>Software components coupling and limitations</title>
                <p>The Authorization Server must know about ELIXIR AAI, the SAML protocol and the AAI specific attributes that provides information about a user. It must also have knowledge about which users are authorized to use which resources.</p>
                <p>The Client must support 
                    <italic toggle="yes">OAuth 2.0</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6749">RFC-6749</ext-link>) and 
                    <italic toggle="yes">Bearer Token Usage</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>).</p>
                <p>The Resource server must support 
                    <italic toggle="yes">Bearer Token Usage</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>) and 
                    <italic toggle="yes">OAuth 2.0 Token Introspection</italic> (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7662">RFC-7662</ext-link>). It must also know how to interpret a Scope in the correct context of the application.</p>
            </sec>
            <sec>
                <title>Implementation</title>
                <p>We have implemented the authorization service in the 
                    <ext-link ext-link-type="uri" xlink:href="http://www.dropwizard.io/1.2.1/docs/">Dropwizard web framework</ext-link>. Dropwizard is a lightweight Java web framework aimed at creating micro services. It uses 
                    <ext-link ext-link-type="uri" xlink:href="https://oltu.apache.org/">Apache Oltu</ext-link> for handling the OAuth protocol, and it stores all its state in a PostgreSQL database using 
                    <ext-link ext-link-type="uri" xlink:href="http://hibernate.org/orm/">Hibernate</ext-link> ORM. Apache Oltu is a library for implementing OAuth 2.0 servers in Java. It manages the OAuth 2.0 protocol and helps serializing responses and parsing/validating requests. Hibernate is an Object Relational Mapper.</p>
                <p>We have implemented the META-pipe web application (
                    <italic toggle="yes">Client</italic>) in JavaScript using the Client OAuth 2.0 library for interfacing with the authorization server and the Resource Servers. Client Oauth 2 (mulesoft/js-client-oauth2) is a JavaScript library for obtaining an authorization from an OAuth 2.0 Authorization server and for making authorized requests to a Resource Server. Client OAuth 2 supports several 
                    <italic toggle="yes">Authorization Grants</italic> including the 
                    <italic toggle="yes">Resource Owner Password Credentials Grant</italic> and 
                    <italic toggle="yes">Authorization Code Grant</italic>. It also supports 
                    <italic toggle="yes">Bearer Token</italic> usage (
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>). Client OAuth 2 can be used from a web browser or from within NodeJS.</p>
                <p>
                    <italic toggle="yes">OAuth 2.0 Token Introspection</italic> is not yet widely supported by software libraries, so we had to implement this from scratch. The specification is only 17 pages and it is very easy to implement. Our library implementation for 
                    <italic toggle="yes">Resource Servers</italic> is therefore only 176 lines of Go code.</p>
            </sec>
            <sec>
                <title>Standards</title>
                <p>We here list the standards that we used and that are useful for others that are developing a similar service. These contain key definitions, abstraction, and representations:</p>
                <list list-type="bullet">
                    <list-item>
                        <p>The OAuth 2.0 Authorization Framework (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6749">RFC-6749</ext-link>) standard for performing authorization describes the 
                            <italic toggle="yes">Acces Token</italic>, which is a key abstraction in OAuth 2 that provides an abstraction layer, replacing different authorization constructs (such as username and password) with a single token understood by the resource server.</p>
                    </list-item>
                    <list-item>
                        <p>The 
                            <italic toggle="yes">The Oauth2.0 Authorization Framework: Bearer Token Usage</italic> (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>) defines the Bearer Token that is passed directly to the Resource Server when performing an authorized request.</p>
                    </list-item>
                    <list-item>
                        <p>The 
                            <italic toggle="yes">JSON Web token</italic> (JWT) (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7519">RFC-7519</ext-link>) standard describes a compact, URL-safe means of representing claims transferred between two parties.</p>
                    </list-item>
                    <list-item>
                        <p>The 
                            <italic toggle="yes">OAuth 2.0 Token Introspection</italic> (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7662">RFC-7662</ext-link>) defines a method for inspecting a token. The 
                            <italic toggle="yes">Security Assertion Markup Language (SAML) 2.0 Profile for OAuth 2.0 Client Authentication and Authorization Grants</italic> (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc7522">RFC-7522</ext-link>) describes how to use SAML to request an OAuth 2.0 access token and how to use SAML for client authentication.</p>
                    </list-item>
                </list>
            </sec>
        </sec>
        <sec>
            <title>Use Cases</title>
            <p>Here we describe the request flow for three use cases: META-pipe web application, command line, and Galaxy. In addition, we describe the request flow for the REST API used to submit jobs for these three uses cases, and we discuss limitation for downloading of META-pipe results using the browser.</p>
            <sec>
                <title>User login via META-pipe web application</title>
                <p>To authorize an end-user to run META-pipe analyses:</p>
                <list list-type="bullet">
                    <list-item>
                        <label>1. </label>
                        <p>The end-user (Resource Owner) clicks &#x201c;Log in with ELIXIR AAI&#x201d; in the 
                            <ext-link ext-link-type="uri" xlink:href="https://metapipe.uit.no/">META-pipe web application</ext-link>.</p>
                    </list-item>
                    <list-item>
                        <label>2. </label>
                        <p>The end-user is redirected to the Authorization Endpoint as defined by the Authorization Code Grant and then to the ELIXIR AAI using SAML web SSO.</p>
                    </list-item>
                    <list-item>
                        <label>3. </label>
                        <p>The end-user logs in via one of the IDPs that are supported by the ELIXIR AAI and is then redirected back to the web application via the authorization server where it obtains an Authorization Code.</p>
                    </list-item>
                    <list-item>
                        <label>4. </label>
                        <p>The web application obtains an Access Token by contacting the Token Endpoint with the Authorization Code.</p>
                    </list-item>
                </list>
            </sec>
            <sec>
                <title>Command line tool</title>
                <p>We provide a command line tool to a few power users so they can submit multiple jobs simultaneously. The tool obtains an Access Token by using the Client Credentials Grant.</p>
            </sec>
            <sec>
                <title>Galaxy tool login</title>
                <p>When the META-pipe Galaxy tool (
                    <italic toggle="yes">Client</italic>) is called by Galaxy the end user will already be authenticated using the Galaxy/Feide integration at 
                    <ext-link ext-link-type="uri" xlink:href="https://galaxy-uit.bioinfo.no/">https://galaxy-uit.bioinfo.no/</ext-link>.</p>
                <list list-type="bullet">
                    <list-item>
                        <label>1. </label>
                        <p>The Galaxy tool will get the user's email address as a command line parameter.</p>
                    </list-item>
                    <list-item>
                        <label>2. </label>
                        <p>The Galaxy tool will be trusted to access all users&#x2019; data and will obtain an Access Token and a Refresh Token using the 
                            <italic toggle="yes">Client Credentials Grant</italic> (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6749">RFC-6749</ext-link>) with a Scope that is limited to the requesting user's resources that are necessary to run a job.</p>
                    </list-item>
                    <list-item>
                        <label>3. </label>
                        <p>The Galaxy Tool will hold the Access Token and Refresh Token in memory for subsequent API requests until the job has completed, and the tool terminates. No authorization state will be persisted between multiple tool invocations.</p>
                    </list-item>
                </list>
            </sec>
            <sec>
                <title>API request to Resource Server</title>
                <p>The above three use-cases use the META-pipe REST API to either submit jobs or monitor their progress. When a Client contacts an API endpoint (Resource Server) the following happens:</p>
                <list list-type="bullet">
                    <list-item>
                        <label>1. </label>
                        <p>The Client provides the Bearer Access Token in the Authorization header to the API endpoint (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>).</p>
                    </list-item>
                    <list-item>
                        <label>2. </label>
                        <p>When the Resource Server receives the request, it will query the Introspection Endpoint to get the Scope of the Access Token and verify that it is still valid.</p>
                    </list-item>
                    <list-item>
                        <label>3. </label>
                        <p>If the Access Token is valid the Resource Server will compare the Access Token' Scope (as returned by the Introspection Endpoint) to the scope required to process the request. If the request is authorized it will process the request, otherwise it will respond with an appropriate error code (
                            <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link>).</p>
                    </list-item>
                </list>
            </sec>
        </sec>
        <sec>
            <title>Summary</title>
            <p>We have described the design, implementation, and use of the META-pipe Authorization service. We use the Authorization service to authorizes access to data on the META-pipe storage system and jobs in the META-pipe job queue. Our Authorization server was among the first services that integrated with ELIXIR AAI.</p>
            <sec>
                <title>Future work</title>
                <p>When downloading a data set (META-pipe result) from our storage service via the browser it is necessary to provide a direct link to the downloadable content while at the same time provide an Access Token to access the data. 
                    <ext-link ext-link-type="uri" xlink:href="https://tools.ietf.org/html/rfc6750">RFC-6750</ext-link> allows for the use of an "access_token" URI query parameter containing a Bearer Token for authorization. A potential issue with this approach is that if a user shares a download link with other users they will get the user's access token. A solution to this is to limit the access token's Scope to only have read access to that particular resource, thus mitigating the risk of users inadvertently giving access to their account.</p>
                <p>We plan to add an admin group for META-pipe administrators to a configuration file in the Authorization server. Another solution is to create a group in an Virtual Organization provided by ELIXIR AAI.</p>
            </sec>
        </sec>
        <sec>
            <title>Software and data availability</title>
            <p>No data is needed to use the Authorization service.</p>
            <p>The code is open source at: 
                <ext-link ext-link-type="uri" xlink:href="https://gitlab.com/uit-sfb/AuthService2">https://gitlab.com/uit-sfb/AuthService2</ext-link>.</p>
            <p>Archived code at time of publication is: 
                <ext-link ext-link-type="uri" xlink:href="https://doi.org/10.5281/zenodo.1058995">https://doi.org/10.5281/zenodo.1058995</ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-2">2</xref>
                </sup>
            </p>
            <p>The software is licensed under 
                <ext-link ext-link-type="uri" xlink:href="https://opensource.org/licenses/MIT">The MIT License</ext-link>.</p>
            <p>A user guide is at: 
                <ext-link ext-link-type="uri" xlink:href="https://gitlab.com/uit-sfb/AuthService2">https://gitlab.com/uit-sfb/AuthService2</ext-link>.</p>
        </sec>
    </body>
    <back>
        <ref-list>
            <ref id="ref-1">
                <label>1</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">

                        <name name-style="western">
                            <surname>Robertsen</surname>
                            <given-names>EM</given-names>
                        </name>

                        <name name-style="western">
                            <surname>Kahlke</surname>
                            <given-names>T</given-names>
                        </name>

                        <name name-style="western">
                            <surname>Raknes</surname>
                            <given-names>IA</given-names>
                        </name>

                        <etal/>
</person-group>:
                    <article-title>META-pipe - Pipeline Annotation, Analysis and Visualization of Marine Metagenomic Sequence Data.</article-title>
                    <source>

                        <italic toggle="yes">ArXiv160404103 Cs.</italic>
</source>
                    <year>2016</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://arxiv.org/ftp/arxiv/papers/1604/1604.04103.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-2">
                <label>2</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">

                        <name name-style="western">
                            <surname>Raknes</surname>
                            <given-names>IA</given-names>
                        </name>

                        <name name-style="western">
                            <surname>Bongo</surname>
                            <given-names>LA</given-names>
                        </name>
</person-group>:
                    <article-title>META-pipe authorization service (Version Tag: Zenodo-F1000).</article-title>
                    <source>

                        <italic toggle="yes">Zenodo.</italic>
</source>
                    <year>2017</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://dx.doi.org/10.5281/zenodo.1058995">Data Source</ext-link>
                </mixed-citation>
            </ref>
        </ref-list>
    </back>
    <sub-article article-type="reviewer-report" id="report31273">
        <front-stub>
            <article-id pub-id-type="doi">10.5256/f1000research.14381.r31273</article-id>
            <title-group>
                <article-title>Reviewer response for version 1</article-title>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author">
                    <name>
                        <surname>Gl&#x00f6;ckner</surname>
                        <given-names>Frank Oliver</given-names>
                    </name>
                    <xref ref-type="aff" rid="r31273a1">1</xref>
                    <role>Referee</role>
                    <uri content-type="orcid">https://orcid.org/0000-0001-8528-9023</uri>
                </contrib>
                <aff id="r31273a1">
                    <label>1</label>Mi&#x00ad;cro&#x00ad;bial Ge&#x00ad;n&#x00ad;om&#x00ad;ics and Bioin&#x00ad;form&#x00ad;at&#x00ad;ics Re&#x00ad;search Group, Max Planck Institute for Marine Microbiology, Bremen, Germany</aff>
            </contrib-group>
            <author-notes>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>7</day>
                <month>3</month>
                <year>2018</year>
            </pub-date>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2018 Gl&#x00f6;ckner FO</copyright-statement>
                <copyright-year>2018</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access peer review report distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <related-article ext-link-type="doi" id="relatedArticleReport31273" related-article-type="peer-reviewed-article" xlink:href="10.12688/f1000research.13256.1"/>
            <custom-meta-group>
                <custom-meta>
                    <meta-name>recommendation</meta-name>
                    <meta-value>approve-with-reservations</meta-value>
                </custom-meta>
            </custom-meta-group>
        </front-stub>
        <body>
            <p>I agree with the authors that adding META-pipe to the ELIXIR AAI system is a useful invention. Since they were the first ones to add this feature to their pipeline I also appreciate the pioneering character of their work.</p>
            <p> To separate the META-pipe software from the authentication-server makes fully sense to me and supports the reusability of the authentication server for other projects.</p>
            <p> Nevertheless, I have two main questions/concerns where I did not find the answer in the manuscript:</p>
            <p> &#x00a0; 
                <list list-type="order">
                    <list-item>
                        <p>Security: Although I am not an expert in this field I got the information that saving the Token in the local storage of the browser might be a risk. Since AAI is a security relevant component in every software system I would recommend consulting an expert in this field to check if the mode of implementation can be in general regarded as save.</p>
                    </list-item>
                    <list-item>
                        <p>From scratch implementation: It is rather unclear for me why the authors have decided to go for a &#x201c;from scratch&#x201d; implementation of their authorisation server? On page two they briefly state that existing out-of-the box solutions did not fulfil all requirements or are too heavy weight for their application, but only OpenID Connect is given as an example. From our experiences several open source authentication-servers exist, that can do the job pretty well e.g. Keycloak, GLUU, hydra, Shibboleth Identity Provider, with the last one is already used in the ELIXIR environment. To make the advantages of a new implementation clear I would recommend adding a paragraph and a table where the different servers are compared and the reasons why going for a fresh implementation are explained in detail. Sticking with a well-established implementation might have also had advantages with respect to potential security issues. A rather comprehensive list of SSO implementations can be found here 
                            <ext-link ext-link-type="uri" xlink:href="https://en.wikipedia.org/wiki/List_of_single_sign-on_implementations">https://en.wikipedia.org/wiki/List_of_single_sign-on_implementations</ext-link>.</p>
                    </list-item>
                </list>
            </p>
            <p>Is the rationale for developing the new method (or application) clearly explained?</p>
            <p>No</p>
            <p>Is the description of the method technically sound?</p>
            <p>Partly</p>
            <p>Are the conclusions about the method and its performance adequately supported by the findings presented in the article?</p>
            <p>Yes</p>
            <p>If any results are presented, are all the source data underlying the results available to ensure full reproducibility?</p>
            <p>No source data required</p>
            <p>Are sufficient details provided to allow replication of the method development and its use by others?</p>
            <p>Partly</p>
            <p>Reviewer Expertise:</p>
            <p>NA</p>
            <p>I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above.</p>
        </body>
        <sub-article article-type="response" id="comment3676-31273">
            <front-stub>
                <contrib-group>
                    <contrib contrib-type="author">
                        <name>
                            <surname>Bongo</surname>
                            <given-names>Lars Ailo</given-names>
                        </name>
                        <aff>University of Tromso, Norway</aff>
                    </contrib>
                </contrib-group>
                <author-notes>
                    <fn fn-type="conflict">
                        <p>
                            <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                    </fn>
                </author-notes>
                <pub-date pub-type="epub">
                    <day>24</day>
                    <month>5</month>
                    <year>2018</year>
                </pub-date>
            </front-stub>
            <body>
                <p>Thank you for your comments and remarks. We have improved the paper as follows:</p>
                <p>&gt; 
                    <italic>I got the information that saving the Token in the local storage of the browser might be a risk. Since AAI is a security relevant component in every software system I would recommend consulting an expert in this field to check if the mode of implementation can be in general regarded as safe.</italic>
                </p>
                <p>We could not find clear guidelines for the where to store the access token and refresh. It does not seem unusual to store the token in the browser local storage. We agree that this may expose our Authorization server to some attacks (such as cross-site attacks). We have therefore added a comment to the Design section that this may be unsafe, and we are considering alternatives for our server.</p>
                <p>
                    <italic>&gt; It is rather unclear for me why the authors have decided to go for a &#x201c;from scratch&#x201d; implementation of their authorisation server? </italic>
                </p>
                <p>We have added a discussion of the ELIXIR AAI Open ID Connect, Shibboleth, and Keycloak in the introduction. It was not an option when we started our implementation, but is clearly an alternative today. We still believe the simplicity of our server has some advantages for development and testing purposes. In addition, we use many libraries for the implementation such as Spring security. We also believe the simplicity, combined with this paper, makes it a good introduction to OAuth2 and ELIXIR AAI.</p>
            </body>
        </sub-article>
    </sub-article>
    <sub-article article-type="reviewer-report" id="report29637">
        <front-stub>
            <article-id pub-id-type="doi">10.5256/f1000research.14381.r29637</article-id>
            <title-group>
                <article-title>Reviewer response for version 1</article-title>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author">
                    <name>
                        <surname>Linden</surname>
                        <given-names>Mikael</given-names>
                    </name>
                    <xref ref-type="aff" rid="r29637a1">1</xref>
                    <role>Referee</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-3634-3756</uri>
                </contrib>
                <aff id="r29637a1">
                    <label>1</label>CSC &#x2013; IT Center for Science, Espoo, Finland</aff>
            </contrib-group>
            <author-notes>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>Meta-Pipe relies on ELIXIR AAI service that I have been developing.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>22</day>
                <month>1</month>
                <year>2018</year>
            </pub-date>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2018 Linden M</copyright-statement>
                <copyright-year>2018</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access peer review report distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <related-article ext-link-type="doi" id="relatedArticleReport29637" related-article-type="peer-reviewed-article" xlink:href="10.12688/f1000research.13256.1"/>
            <custom-meta-group>
                <custom-meta>
                    <meta-name>recommendation</meta-name>
                    <meta-value>approve-with-reservations</meta-value>
                </custom-meta>
            </custom-meta-group>
        </front-stub>
        <body>
            <p>The paper is a useful description on how Meta-Pipe relies on OAuth2 framework for authorising access to the Meta-Pipe storage and job queue.</p>
            <p> </p>
            <p> What is the criteria the authorisation server uses to authorise the user to a certain resource? Based on what criteria is the authorisation granted to a user? Is it that users can only access their own files? Or are there also other criteria e.g. who in general can access the META-Pipe?</p>
            <p> </p>
            <p> ELIXIR AAI provides an OpenID Connect provider that is an OAuth2 authorisation server. Could you use it instead of developing your own server?</p>
            <p> </p>
            <p> Does the Meta-Pipe web application run in a user's browser or in a server?</p>
            <p> </p>
            <p> What is the relation of Feide and ELIXIR AAI in the context of Meta-Pipe? What is the relation of Meta-Pipe authorisation server and Feide? Does the Meta-Pipe authorisation server rely on them both for user authentication?</p>
            <p> </p>
            <p> In the end of Standards section on page 4 you refer to RFC 7522 as a spec you used but on the previous page you say you couldn't use that spec.</p>
            <p> </p>
            <p> You could improve figure 1 by clearly indicating where are the OAuth2 authorisation server, client and resource server.&#x00a0; Perhaps you could also introduce another drawing where the OAuth2 messages are presented. That would make it easier for the reader to follow how you have mounted OAuth2 for your deployment.</p>
            <p> </p>
            <p> Clients other than Meta-pipe Web app are missing in the Figure 1. What is the service behind the Meta-pipe REST API (from other sections I learn they are the job submission/management and storage services)?</p>
            <p> </p>
            <p> In the future work section; instead of displaying the user a URL with an embedded access token, why can't you protect the URI with OAuth2, triggering the client to obtain the Access token from the Authorisation server directly and then presenting it to the storage server.</p>
            <p>Is the rationale for developing the new method (or application) clearly explained?</p>
            <p>Partly</p>
            <p>Is the description of the method technically sound?</p>
            <p>Yes</p>
            <p>Are the conclusions about the method and its performance adequately supported by the findings presented in the article?</p>
            <p>Yes</p>
            <p>If any results are presented, are all the source data underlying the results available to ensure full reproducibility?</p>
            <p>No source data required</p>
            <p>Are sufficient details provided to allow replication of the method development and its use by others?</p>
            <p>Partly</p>
            <p>Reviewer Expertise:</p>
            <p>NA</p>
            <p>I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above.</p>
        </body>
        <sub-article article-type="response" id="comment3677-29637">
            <front-stub>
                <contrib-group>
                    <contrib contrib-type="author">
                        <name>
                            <surname>Bongo</surname>
                            <given-names>Lars Ailo</given-names>
                        </name>
                        <aff>University of Tromso, Norway</aff>
                    </contrib>
                </contrib-group>
                <author-notes>
                    <fn fn-type="conflict">
                        <p>
                            <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                    </fn>
                </author-notes>
                <pub-date pub-type="epub">
                    <day>24</day>
                    <month>5</month>
                    <year>2018</year>
                </pub-date>
            </front-stub>
            <body>
                <p>Thank you for your insightful remarks. We have made the following improvements to our paper to address the raised concerns:</p>
                <p>
                    <italic>&gt; What is the criteria the authorisation server uses to authorise the user to a certain resource?</italic>
                </p>
                <p>
                    <italic>&gt; Based on what criteria is the authorisation granted to a user?</italic>
                </p>
                <p>
                    <italic>&gt; Is it that users can only access their own files?</italic>
                </p>
                <p>
                    <italic>&gt; Or are there also other criteria e.g. who in general can access the META-Pipe?</italic>
                </p>
                <p>We added an explanation in the &#x201c;Use cases&#x201d; that all users with an ELIXIR AAI supported account have access to (only) their files and job information in META-pipe.</p>
                <p>
                    <italic>&gt; ELIXIR AAI provides an OpenID Connect provider that is an OAuth2 authorisation server. Could you use it instead of developing your own server?</italic>
                </p>
                <p>We added a discussion of the ELIXIR AAI Open ID Connect to the introduction. It was not an option when we started our implementation. We still believe the simplicity of our server has some advantages for development and testing purposes. For example as an introduction to OAuth2 and ELIXIR AAI.</p>
                <p>
                    <italic>&gt; Does the Meta-Pipe web application run in a user's browser or in a server?</italic>
                </p>
                <p>We now specify in Use Cases; User login via META-pipe web application that the web application is run only in the browser.</p>
                <p>
                    <italic>&gt; What is the relation of Feide and ELIXIR AAI in the context of Meta-Pipe?</italic>
                </p>
                <p>
                    <italic>&gt; What is the relation of Meta-Pipe authorisation server and Feide? Does the Meta-Pipe authorisation server rely on them both for user authentication?</italic>
                </p>
                <p>We added explanations in Methods; Integration with ELIXIR-Norway Galaxy/ Feide that we must use Feide for Galaxy. We also describe how the Galaxy tool has an account on the Authorization service, and acts on behalf of all Feide users logged in Galaxy. The Authorization service therefore do not directly rely on both for user authentication.</p>
                <p>
                    <italic>&gt; In the end of Standards section on page 4 you refer to RFC 7522 as a spec you used but on the previous page you say you couldn't use that spec.</italic>
                </p>
                <p>It is correct that we do not use RFC 7522, so we have removed it from the list.</p>
                <p>
                    <italic>&gt; You could improve figure 1 by clearly indicating where are the OAuth2 authorisation server, client and resource server. &#x00a0;Perhaps you could also introduce another drawing where the OAuth2 messages are presented. That would make it easier for the reader to follow how you have mounted OAuth2 for your deployment.</italic>
                </p>
                <p>
                    <italic>&gt; Clients other than Meta-pipe Web app are missing in the Figure 1. What is the service behind the Meta-pipe REST API (from other sections I learn they are the job submission/management and storage services)?</italic>
                </p>
                <p>We have added an explanation to the figure caption that the web application is an OAuth2 Client, the META-pipe REST API is the OAuth2 resource server, and the Authorization Service is an OAuth2 authorization server. We chose not to make changes to the figure since we try to keep it simple for illustration purposes, and since more detailed figures for the OAuth2 messages can be found in the standard documentation.</p>
                <p>We also added a description to the figure caption that the META-pipe servers are represented by the REST API box.</p>
                <p>
                    <italic>&gt; In the future work section; instead of displaying the user a URL with an embedded access token, why can't you protect the URI with OAuth2, triggering the client to obtain the Access token from the Authorisation server directly and then presenting it to the storage server.</italic>
                </p>
                <p>
                    <italic>Misunderstanding? Is in line with OAuth2 specification.</italic>
                </p>
                <p>We added an explanation in Future Work that the URI is built after the client obtains an access token from the Authorization service. We do not know of a better way to do this.</p>
            </body>
        </sub-article>
    </sub-article>
</article>
