Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update</strong> On further reflection, your initial thought, to create a RequiredScope attribute would be a cleaner way to go. Adding it to the ServiceStack pipeline is as easy as adding the IHasRequestFilter interface, implementing a custom request filter, as documented here: <a href="https://github.com/ServiceStack/ServiceStack/wiki/Filter-attributes">https://github.com/ServiceStack/ServiceStack/wiki/Filter-attributes</a></p> <pre><code>public class RequireScopeAttribute : Attribute, IHasRequestFilter { public void RequireScope(IHttpRequest req, IHttpResponse res, object requestDto) { //This code is executed before the service //Close the request if user lacks required scope } ... } </code></pre> <p>Then decorate your DTO's or Services as you've outlined:</p> <pre><code>using ServiceStack.ServiceInterface; using SpotAuth.Common.ServiceModel; namespace SpotAuth.ResourceServer.Services { [RequireScope("hello")] public class HelloService : Service { public object Any(Hello request) { return new HelloResponse { Result = "Hello, " + request.Name }; } } } </code></pre> <p>Your RequireScope custom filter would be almost identical to <a href="https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.ServiceInterface/RequiredRoleAttribute.cs">ServiceStack's RequiredRoleAttribute implementation.</a>, so use it as a starting point to code from.</p> <p>Alternately, you could map scope to permission. Then decorate your DTO or service accordingly (<a href="https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization">see SS wiki</a> for details) for example:</p> <pre><code>[Authenticate] [RequiredPermission("Hello")] public class HelloService : Service { public object Any(Hello request) { return new HelloResponse { Result = "Hello, " + request.Name }; } } </code></pre> <p>Normally ServiceStack calls the method bool HasPermission(string permission) in IAuthSession. This method checks if the list List Permissions in IAuthSession contains the required permission, so, in a custom IAuthSession you could override HasPermission and put your OAuth2 scopes checking there.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload