Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions services/celest_cloud_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.1

- fix: Allow dashes in routes

## 0.3.0

- feat!: Make database modular
Expand Down
9 changes: 7 additions & 2 deletions services/celest_cloud_auth/lib/src/model/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,19 @@ final class RouteWildcard extends RouteSegment {
/// Not a standard, but a generally accepted upper bound on reasonable URLs.
static const int _maxUrlLength = 2048;

/// Allowed characters in a URL path segment.
// TODO(dnys1): Handle percent-encoded characters.
// https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L241
static final Parser<String> _validChar = pattern('-_.~0-9a-zA-Z');

late final Parser<String> _parser = greedy
// The syntax `**` matches zero or more URL path segments
? (word() | char('/'))
? (_validChar | char('/'))
.repeatLazy(endOfInput(), 0, _maxUrlLength)
.flatten('**')

// The syntax `*` matches a single URL path segment.
: word().plus().flatten('*');
: _validChar.plus().flatten('*');

@override
Result<String> parseOn(Context context) {
Expand Down
2 changes: 1 addition & 1 deletion services/celest_cloud_auth/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: celest_cloud_auth
description: A Dart-native authentication and authorization service built on Celest, Cedar, and SQLite.
version: 0.3.0
version: 0.3.1
homepage: https://celest.dev
repository: https://github.com/celest-dev/celest/tree/main/services/celest_cloud_auth

Expand Down
24 changes: 24 additions & 0 deletions services/celest_cloud_auth/test/model/route_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,30 @@ final _testCases = <_TestCase>[
),
],
),
(
route: '/v1alpha1/{name=organizations/*/projects/*}',
expectedSegments: [
RouteLiteral('v1alpha1'),
RouteParameter(
variable: 'name',
segments: [
RouteLiteral('organizations'),
RouteWildcard(greedy: false),
RouteLiteral('projects'),
RouteWildcard(greedy: false),
],
),
],
expectedVerb: null,
matchTests: [
(
route: '/v1alpha1/organizations/org_1234/projects/my-project',
expected: {
'name': 'organizations/org_1234/projects/my-project',
},
),
],
),
(
route: '/v1alpha1/auth/{name=organizations/*/users/*}',
expectedSegments: [
Expand Down