Skip to content

Commit ed5361b

Browse files
authored
fix(cli): Ensure @authenticated routes require auth with external providers (#266)
This ensures that APIs throw the appropriate error and return the correct status code when a user is not authenticated.
1 parent 6bcd65a commit ed5361b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/cli/lib/src/codegen/api/entrypoint_generator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ final class EntrypointGenerator {
611611
...function.metadata.whereType<ApiAuth>(),
612612
...api.metadata.whereType<ApiAuth>(),
613613
];
614-
// final authRequired = authMetadata.whereType<ApiAuthenticated>().isNotEmpty;
614+
final authRequired = authMetadata.whereType<ApiAuthenticated>().isNotEmpty;
615615
if (authMetadata.isNotEmpty) {
616616
if (project.auth?.providers.isNotEmpty ?? false) {
617617
authMiddleware = DartTypes.celest.middleware.property('shelf').call([
@@ -640,7 +640,7 @@ final class EntrypointGenerator {
640640
),
641641
]),
642642
]),
643-
'required': literalBool(false),
643+
'required': literalBool(authRequired),
644644
});
645645
case SupabaseExternalAuthProvider(
646646
:final projectUrl,
@@ -671,7 +671,7 @@ final class EntrypointGenerator {
671671
]),
672672
],
673673
),
674-
'required': literalBool(false),
674+
'required': literalBool(authRequired),
675675
});
676676
}
677677
}

0 commit comments

Comments
 (0)