{"id":34600,"date":"2024-08-30T16:16:29","date_gmt":"2024-08-30T14:16:29","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=34600"},"modified":"2024-08-30T16:16:32","modified_gmt":"2024-08-30T14:16:32","slug":"manage-feathers-js-authentication-in-swagger-ui","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/","title":{"rendered":"Manage Feathers.js authentication in Swagger UI"},"content":{"rendered":"\n<p>In addition to my previous articles <a href=\"https:\/\/www.dbi-services.com\/blog\/add-a-ui-to-explore-the-feathers-js-api\/\">Add a UI to explore the Feathers.js API<\/a> and <a href=\"https:\/\/www.dbi-services.com\/blog\/add-authentication-in-a-feathers-js-rest-api\/\">Add authentication in a Feathers.js REST API<\/a>, today, I will explain how to manage Feathers.js authentication in <a href=\"https:\/\/swagger.io\/tools\/swagger-ui\/\">Swagger UI<\/a> and make it simple for our users.<\/p>\n\n\n\n<p>After enabling authentication on API methods, as a result, using Swagger UI for testing is difficult, if not impossible. To solve this problem, Swagger needs to support authentication.<\/p>\n\n\n\n<p>In this article, I will reuse the code from my previous articles.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-first-step-add-authentication-specifications-to-the-application\">First step: add authentication specifications to the application<\/h2>\n\n\n\n<p>For Swagger UI to handle API authentication, I need to update the specifications in the app.ts file. Therefore, in the specs object, I add the components and security parts:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.configure(\n  swagger({\n    specs: {\n      info: {\n        title: 'Workshop API ',\n        description: 'Workshop API rest services',\n        version: '1.0.0'\n      },\n      components: {\n        securitySchemes: {\n          BearerAuth: {\n            type: 'http',\n            scheme: 'bearer',\n          },\n        },\n      },\n      security: &#091;{ BearerAuth: &#091;] }],\n    },\n    ui: swagger.swaggerUI({ \n      docsPath: '\/docs',\n    })\n  })\n)<\/code><\/pre>\n\n\n\n<p>This new configuration, general to the API, tells Swagger that authenticated methods will use a Bearer token.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-second-step-define-documentation-for-authentication-methods\">Second step: define documentation for authentication methods<\/h2>\n\n\n\n<p>The authentication service generated by the CLI does not contain any specifications for Swagger UI, which results in an error message being displayed on the interface. So I&#8217;m adding the specifications needed by Swagger to manage authentication methods:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nexport const authentication = (app: Application) =&gt; {\n  const authentication = new AuthenticationService(app)\n\n  authentication.register('jwt', new JWTStrategy())\n  authentication.register('local', new LocalStrategy())\n\n  \/\/ Swagger definition.\n  authentication.docs = {\n    idNames: {\n      remove: 'accessToken',\n    },\n    idType: 'string',\n    securities: &#091;'remove', 'removeMulti'],\n    multi: &#091;'remove'],\n    schemas: {\n      authRequest: {\n        type: 'object',\n        properties: {\n          strategy: { type: 'string' },\n          email: { type: 'string' },\n          password: { type: 'string' },\n        },\n      },\n      authResult: {\n        type: 'object',\n        properties: {\n          accessToken: { type: 'string' },\n          authentication: {\n            type: 'object',\n            properties: {\n              strategy: { type: 'string' },\n            },\n          },\n          payload: {\n            type: 'object',\n            properties: {},\n          },\n          user: { $ref: '#\/components\/schemas\/User' },\n        },\n      },\n    },\n    refs: {\n      createRequest: 'authRequest',\n      createResponse: 'authResult',\n      removeResponse: 'authResult',\n      removeMultiResponse: 'authResult',\n    },\n    operations: {\n      remove: {\n        description: 'Logout the current user',\n        'parameters&#091;0].description': 'accessToken of the current user',\n      },\n      removeMulti: {\n        description: 'Logout the current user',\n        parameters: &#091;],\n      },\n    },\n  };\n\n  app.use('authentication', authentication)\n}<\/code><\/pre>\n\n\n\n<p>The authentication.docs block defines how Swagger UI can interact with the authentication service.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-third-step-add-the-security-config-into-the-service\">Third step: add the security config into the service<\/h2>\n\n\n\n<p>At the beginning of my service file (workshop.ts), in the docs definition, I add the list of methods that must be authenticated in the securities array:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docs: createSwaggerServiceOptions({\n  schemas: { \n    workshopSchema, \n    workshopDataSchema, \n    workshopPatchSchema, \n    workshopQuerySchema \n  },\n  docs: {\n      \/\/ any options for service.docs can be added here\n      description: 'Workshop service',\n      securities: &#091;'find', 'get', 'create', 'update', 'patch', 'remove'],\n  }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-swagger-ui-authentication-tests\">Swagger UI authentication tests<\/h2>\n\n\n\n<p>As a result of the configuration, new elements appear on the interface:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Authorize button at the top of the page<\/li>\n\n\n\n<li>Padlocks at the end of authenticated method lines<\/li>\n\n\n\n<li>A more complete definition of authentication service methods<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"459\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png\" alt=\"Swagger Authentication\" class=\"wp-image-34609\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-300x135.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-768x344.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication.png 1492w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-obtain-an-access-token-with-the-ui\">Obtain an access token with the UI<\/h3>\n\n\n\n<p>First, I need to log in with my credentials to get a token. After that, the bearer token will be used in the next authenticated calls:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"522\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_request-1024x522.png\" alt=\"Authentication request\" class=\"wp-image-34614\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_request-1024x522.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_request-300x153.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_request-768x391.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_request.png 1462w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The JSON object sent in the request body contains the identification information. In return, we&#8217;ll get an accessToken useful for the next calls:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"631\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_response-1024x631.png\" alt=\"Authentication response\" class=\"wp-image-34615\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_response-1024x631.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_response-300x185.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_response-768x473.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authentication_response.png 1440w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-second-step-define-the-bearer-token-for-authenticated-requests\">Second step, define the bearer token for authenticated requests<\/h3>\n\n\n\n<p>Each call to an authenticated method requires the token to be sent in the http headers. We therefore register the token in Swagger UI by clicking on the Authorize button and paste the token obtained during the authentication step:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"385\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Define_Auth_Credentials-1024x385.png\" alt=\"Define authentication credentials\" class=\"wp-image-34616\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Define_Auth_Credentials-1024x385.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Define_Auth_Credentials-300x113.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Define_Auth_Credentials-768x289.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Define_Auth_Credentials.png 1488w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-testing-authenticated-methods\">Testing authenticated methods<\/h3>\n\n\n\n<p>Once the token has been entered into Swagger UI, I use the methods without worrying about authentication:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"601\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_request-1024x601.png\" alt=\"Call authenticated method\" class=\"wp-image-34619\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_request-1024x601.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_request-300x176.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_request-768x451.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_request.png 1465w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Swagger UI sends the token in the http headers to authenticate the request. Then the api returns the data:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"547\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_response-1024x547.png\" alt=\"Authenticated response\" class=\"wp-image-34620\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_response-1024x547.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_response-300x160.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_response-768x410.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Authenticated_method_response.png 1446w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>Managing Feathers.js authentication in Swagger UI is entirely possible. With a little extra configuration, it becomes easy to use authentication and authenticated methods. It&#8217;s even simple to test all API methods and document their use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In addition to my previous articles Add a UI to explore the Feathers.js API and Add authentication in a Feathers.js REST API, today, I will explain how to manage Feathers.js authentication in Swagger UI and make it simple for our users. After enabling authentication on API methods, as a result, using Swagger UI for testing [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[368,3029],"tags":[979,995,1090,1001,3301,3257],"type_dbi":[],"class_list":["post-34600","post","type-post","status-publish","format-standard","hentry","category-development-performance","category-web","tag-api","tag-authentication","tag-javascript","tag-node-js","tag-swagger-ui","tag-typescript"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Manage Feathers.js authentication in Swagger UI - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Manage Feathers.js authentication in Swagger UI\" \/>\n<meta property=\"og:description\" content=\"In addition to my previous articles Add a UI to explore the Feathers.js API and Add authentication in a Feathers.js REST API, today, I will explain how to manage Feathers.js authentication in Swagger UI and make it simple for our users. After enabling authentication on API methods, as a result, using Swagger UI for testing [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-08-30T14:16:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-30T14:16:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png\" \/>\n<meta name=\"author\" content=\"Nicolas Meunier\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nicolas Meunier\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\"},\"author\":{\"name\":\"Nicolas Meunier\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\"},\"headline\":\"Manage Feathers.js authentication in Swagger UI\",\"datePublished\":\"2024-08-30T14:16:29+00:00\",\"dateModified\":\"2024-08-30T14:16:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\"},\"wordCount\":465,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png\",\"keywords\":[\"api\",\"Authentication\",\"JavaScript\",\"Node.js\",\"Swagger UI\",\"TypeScript\"],\"articleSection\":[\"Development &amp; Performance\",\"Web\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\",\"name\":\"Manage Feathers.js authentication in Swagger UI - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png\",\"datePublished\":\"2024-08-30T14:16:29+00:00\",\"dateModified\":\"2024-08-30T14:16:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication.png\",\"contentUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication.png\",\"width\":1492,\"height\":669},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Manage Feathers.js authentication in Swagger UI\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\",\"name\":\"Nicolas Meunier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"caption\":\"Nicolas Meunier\"},\"description\":\"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Manage Feathers.js authentication in Swagger UI - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/","og_locale":"en_US","og_type":"article","og_title":"Manage Feathers.js authentication in Swagger UI","og_description":"In addition to my previous articles Add a UI to explore the Feathers.js API and Add authentication in a Feathers.js REST API, today, I will explain how to manage Feathers.js authentication in Swagger UI and make it simple for our users. After enabling authentication on API methods, as a result, using Swagger UI for testing [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/","og_site_name":"dbi Blog","article_published_time":"2024-08-30T14:16:29+00:00","article_modified_time":"2024-08-30T14:16:32+00:00","og_image":[{"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png","type":"","width":"","height":""}],"author":"Nicolas Meunier","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nicolas Meunier","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/"},"author":{"name":"Nicolas Meunier","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"headline":"Manage Feathers.js authentication in Swagger UI","datePublished":"2024-08-30T14:16:29+00:00","dateModified":"2024-08-30T14:16:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/"},"wordCount":465,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png","keywords":["api","Authentication","JavaScript","Node.js","Swagger UI","TypeScript"],"articleSection":["Development &amp; Performance","Web"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/","url":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/","name":"Manage Feathers.js authentication in Swagger UI - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication-1024x459.png","datePublished":"2024-08-30T14:16:29+00:00","dateModified":"2024-08-30T14:16:32+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/08\/Swagger_Authentication.png","width":1492,"height":669},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/manage-feathers-js-authentication-in-swagger-ui\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Manage Feathers.js authentication in Swagger UI"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe","name":"Nicolas Meunier","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","caption":"Nicolas Meunier"},"description":"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.","url":"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/34600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=34600"}],"version-history":[{"count":20,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/34600\/revisions"}],"predecessor-version":[{"id":34628,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/34600\/revisions\/34628"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=34600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=34600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=34600"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=34600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}