2ff6e05ffc
Permit integration - part 1 * WIP permit integration * slim down build * Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/permit-integration-1 * omit swagger from auth * clean build * comment * part 1 completed this is the initial permitio parts and tests without integration. Also testing.md since we have a new test target `task test:permitio` * feature flag for no jwt validation * permit integration * fix ci unit tests * ci fix * build fix * fix home handler * fix redirect * test fix * update docs for auth
28 lines
976 B
Go
28 lines
976 B
Go
package cognitoauth
|
|
|
|
import "strings"
|
|
|
|
// GetResourceFromRoute extracts the resource identifier from the HTTP route
|
|
// Returns only the first path segment (e.g., "/document/foo/123" -> "document")
|
|
// Removes leading slash to match Permit.io resource naming convention
|
|
func GetResourceFromRoute(route string) string {
|
|
// Remove leading slash if present
|
|
route = strings.TrimPrefix(route, "/")
|
|
|
|
// Find the first slash and return only the part before it
|
|
if slashIndex := strings.Index(route, "/"); slashIndex != -1 {
|
|
return route[:slashIndex]
|
|
}
|
|
|
|
// No slash found, return the whole string
|
|
return route
|
|
}
|
|
|
|
// GetActionFromMethod maps HTTP methods to Permit.io actions
|
|
// Converts HTTP methods to lowercase to match Permit.io action naming conventions
|
|
func GetActionFromMethod(method string) string {
|
|
// Convert to lowercase to match Permit.io action naming conventions
|
|
// This ensures case-insensitive matching with configured actions
|
|
return strings.ToLower(method)
|
|
}
|