2013-02-21 2 views
7

私はServiceStackの認証機能を使用しており、CredentialsAuthProviderを使用するAuthプラグインを設定しています。生成されたメタデータ]ページで、ServiceStackは、以下の操作を示しています。ServiceStack APIからAssignRolesとUnAssignRolesを削除するには

  • 認証
  • AssignRolesを
  • UnAssignRoles

私はロールを削除したいと思いますなぜ私は、認証操作を使用していますこのページの読者がAPIの使い方を混乱させるような操作は避けてください。これは可能ですか?

答えて

16

あなたはうんそれはさらに良いですAssignRolesとUnAssignRoles

AuthFeature authFeature = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider() }); 

authFeature.IncludeAssignRoleServices = false; 

Plugins.Add(authFeature); 
+0

のみを削除します以下のことを行うことができます! – mythz

+0

Boo-yaa!素晴らしい解決策。 – ThomasArdal

6

Plugins wikiに記載されているかどうか、疑問のある方はAuthentication pageをご覧ください。

各プラグインはそれだけで利用できますルートでそれをオーバーライドし、この場合には、ビヘイビアのどの上書きのプロパティがあります。

のための短い手で
Plugins.Add(new AuthFeature(() => new AuthUserSession()) { 
    IncludeAssignRoleServices = false 
}); 

Plugins.Add(new AuthFeature(() => new AuthUserSession(), 
    new IAuthProvider[] { ... }, 
    ServiceRoutes = new Dictionary<Type, string[]> { 
     { typeof(AuthService), new[]{"/auth", "/auth/{provider}"} }, 
     //Omit the Un/AssignRoles service definitions here. 
    }  
)); 

source code for the AuthFeature各プロパティのデフォルトを表示するのにも便利です。

関連する問題