public HateoasFilter( HateoasService hateoasService, IHateoasAuthorizator authorizator) { this.HateoasService = hateoasService; if (authorizator == null) { // TODO: Loggear que tuvo que usarse el dummy this.Authorizator = new DummyAuthorizationService(); } else { this.Authorizator = authorizator; } }
public IEnumerable <Endpoint> GetCollectionActions(string resourceCode, IHateoasAuthorizator authorizator) { var actions = this.GetEndpoints(resourceCode, EndpointScope.Collection, EndpointType.Action, authorizator); return(actions); }
public IEnumerable <Endpoint> GetElementActions(IApiResource resource, IHateoasAuthorizator authorizator) { var actions = this.GetEndpoints(resource, EndpointScope.Element, EndpointType.Action, authorizator); return(actions); }
public IEnumerable <Endpoint> GetElementLinks(IApiResource resource, IHateoasAuthorizator authorizator) { var links = this.GetEndpoints(resource, EndpointScope.Element, EndpointType.Link, authorizator); return(links); }
public IEnumerable <Endpoint> GetCollectionLinks(string resourceCode, IHateoasAuthorizator authorizator) { var links = this.GetEndpoints(resourceCode, EndpointScope.Collection, EndpointType.Link, authorizator); return(links); }
private IEnumerable <Endpoint> GetEndpoints(IApiResource resource, EndpointScope scope, EndpointType type, IHateoasAuthorizator authorizator) { var links = Endpoints .Where(x => x.Type == type && x.Scope == scope && x.ResourceCode == resource.ApiResourceCode && authorizator.IsAuthorized(resource, x)); return(links); }