diff --git a/README.md b/README.md index cdff0eb..0368804 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ await fastify.register(import('@fastify/fastify-openapi-router-plugin'), { operationId: 'getPetById', ... security: [ - { OAuth2: ['read:pets'] } + { OAuth2: ['pets:read'] } ] } } @@ -136,7 +136,7 @@ await fastify.register(import('@fastify/fastify-openapi-router-plugin'), { ``` > [!TIP] -> The `scopes` returned by the security handler can contain **wildcards**. For example, if the security handler returns `{ scopes: ['read:*'] }`, the route will be authorized for any security scope that starts with `read:`. +> The `scopes` returned by the security handler can contain **wildcards**. For example, if the security handler returns `{ scopes: ['pets:*'] }`, the route will be authorized for any security scope that starts with `pets:`. > [!IMPORTANT] > If your specification uses `http` security schemes with `in: cookie`, you must register [@fastify/cookie](https://github.com/fastify/fastify-cookie) before this plugin. diff --git a/examples/petstore/app.js b/examples/petstore/app.js index 6ca87f4..8b54315 100644 --- a/examples/petstore/app.js +++ b/examples/petstore/app.js @@ -18,7 +18,7 @@ await fastify.register(openApiRouter, { data: { user: { name: 'John Doe' } }, - scopes: ['read:pets'] + scopes: ['pets:read'] }; } }, diff --git a/examples/petstore/petstore.json b/examples/petstore/petstore.json index 8721b6e..281fd8b 100644 --- a/examples/petstore/petstore.json +++ b/examples/petstore/petstore.json @@ -59,7 +59,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ], "requestBody": { @@ -85,7 +85,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ], "requestBody": { @@ -144,7 +144,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ] } @@ -198,7 +198,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ], "deprecated": true @@ -250,7 +250,7 @@ }, "security": [ { - "petstore_auth": ["write:pets"], + "petstore_auth": ["pets:write"], "api_key": [] }, { @@ -283,7 +283,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ], "requestBody": { @@ -341,7 +341,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ] } @@ -378,7 +378,7 @@ }, "security": [ { - "petstore_auth": ["write:pets", "read:pets"] + "petstore_auth": ["pets:write", "pets:read"] } ], "requestBody": { @@ -977,8 +977,8 @@ "implicit": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" + "pets:write": "modify pets in your account", + "pets:read": "read your pets" } } }