public virtual bool Authorize(ServiceContext ctx, IAuthorizationIdentity identity) { var authorized = this.AuthorizeInternal(ctx, identity); if (!authorized) { ctx.ResultInitialized = true; ctx.ResultValue = AOPResult.Failed("授权失败"); } return(authorized); }
public static bool Authorize(ServiceContext ctx, IAuthorizationIdentity identity) { #if !DEBUG if (ctx.HttpContext.Request.Method != "POST") { ctx.ResultInitialized = true; ctx.ResultValue = AOPResult.Failed(-405, "非法请求"); return(false); } #endif return(true); }
protected override bool AuthorizeInternal(ServiceContext ctx, IAuthorizationIdentity identity) { string msg = null; var oa = (ObsoleteAttribute)identity; if (oa != null) { msg = oa.Message; } if (string.IsNullOrEmpty(msg)) { msg = "此方法已废弃,请更新客户端"; } ctx.ResultInitialized = true; ctx.ResultValue = AOPResult.Failed(-304, msg); return(false); }
public virtual bool Authorize(ServiceContext ctx, IAuthorizationIdentity identity) { var thisType = this.GetType(); var validated = ctx.Items[thisType] as bool?; //避免重复验证 if (validated != null) { return(validated.Value); } var authorized = this.AuthorizeInternal(ctx, identity); if (!authorized && !ctx.ResultInitialized) { ctx.ResultInitialized = true; ctx.ResultValue = AOPResult.Failed(-1, "授权失败"); } ctx.Items[thisType] = authorized; return(authorized); }
protected override bool AuthorizeInternal(ServiceContext ctx, IAuthorizationIdentity identity) { return(PostAuthorizeAttribute.Authorize(ctx, identity)); }
bool IAuthorizationProvider.Authorize(ServiceContext ctx, IAuthorizationIdentity identity) { return(Authorize(ctx, identity)); }
protected abstract bool AuthorizeInternal(ServiceContext ctx, IAuthorizationIdentity identity);