Skip to content

Bug: Normalize both url path and capability substring for endpoint authorization #170

@denopink

Description

@denopink

bascule checks wether or not one of the sat token capabilities matches the request url. This works by checking 1) the capabilities like hooks is a subset match of the request url and 2) that match starts at index 0:

where re is the regex for hooks capability and urlToMatch should start with hooks

matchIdxs := re.FindStringIndex(urlToMatch)
if matchIdxs == nil || matchIdxs[0] != 0 {
return false
}
return true

The issue at hand is that go's net lib may include a leading / in its url path. So urlToMatch would point to /hooks instead of hooks and thus failing the endpoint authorization.

The solution is to normalize both re and urlToMatch to contain a leading / such that the currently logic works.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions