checkDirect checks if the relation tuple is in the database directly.
(r *relationTuple, restDepth int)
| 167 | |
| 168 | // checkDirect checks if the relation tuple is in the database directly. |
| 169 | func (e *Engine) checkDirect(r *relationTuple, restDepth int) checkgroup.CheckFunc { |
| 170 | if restDepth <= 0 { |
| 171 | e.d.Logger(). |
| 172 | WithField("method", "checkDirect"). |
| 173 | Debug("reached max-depth, therefore this query will not be further expanded") |
| 174 | return checkgroup.UnknownMemberFunc |
| 175 | } |
| 176 | return func(ctx context.Context, resultCh chan<- checkgroup.Result) { |
| 177 | e.d.Logger(). |
| 178 | WithField("request", r.String()). |
| 179 | Trace("check direct") |
| 180 | found, err := e.d.RelationTupleManager().ExistsRelationTuples( |
| 181 | ctx, |
| 182 | r.ToQuery(), |
| 183 | ) |
| 184 | |
| 185 | switch { |
| 186 | case err != nil: |
| 187 | e.d.Logger(). |
| 188 | WithField("method", "checkDirect"). |
| 189 | WithError(err). |
| 190 | Error("failed to look up direct access in db") |
| 191 | resultCh <- checkgroup.Result{ |
| 192 | Membership: checkgroup.NotMember, |
| 193 | } |
| 194 | |
| 195 | case found: |
| 196 | resultCh <- checkgroup.Result{ |
| 197 | Membership: checkgroup.IsMember, |
| 198 | Tree: &ketoapi.Tree[*relationtuple.RelationTuple]{ |
| 199 | Type: ketoapi.TreeNodeLeaf, |
| 200 | Tuple: r, |
| 201 | }, |
| 202 | } |
| 203 | |
| 204 | default: |
| 205 | resultCh <- checkgroup.Result{ |
| 206 | Membership: checkgroup.NotMember, |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | // checkIsAllowed checks if the relation tuple is allowed (there is a path from |
| 213 | // the relation tuple subject to the namespace, object and relation) either |
no test coverage detected