rafmacalaba commited on
Commit
b675de3
·
1 Parent(s): 7addaf4

Remove ALLOWED_USERS and enable default document access for unconfigured users

Browse files
app/api/auth/callback/route.js CHANGED
@@ -61,17 +61,7 @@ export async function GET(request) {
61
  const userInfo = await userRes.json();
62
  const username = userInfo.preferred_username || userInfo.name || 'user';
63
 
64
- // Check allowlist (if ALLOWED_USERS is set)
65
- const allowedUsers = process.env.ALLOWED_USERS;
66
- if (allowedUsers) {
67
- const allowlist = allowedUsers.split(',').map(u => u.trim().toLowerCase());
68
- if (!allowlist.includes(username.toLowerCase())) {
69
- return NextResponse.json(
70
- { error: `Access denied. User "${username}" is not in the allowed list.` },
71
- { status: 403 }
72
- );
73
- }
74
- }
75
 
76
  // Set session cookie with username
77
  const response = NextResponse.redirect(host);
 
61
  const userInfo = await userRes.json();
62
  const username = userInfo.preferred_username || userInfo.name || 'user';
63
 
64
+
 
 
 
 
 
 
 
 
 
 
65
 
66
  // Set session cookie with username
67
  const response = NextResponse.redirect(host);
app/api/documents/route.js CHANGED
@@ -34,7 +34,7 @@ async function getUserAssignedDocs(username) {
34
  const config = yaml.load(text);
35
 
36
  const annotator = (config.annotators || []).find(a => a.username === username);
37
- if (!annotator || !annotator.docs) return {}; // user not in config — no docs
38
 
39
  // Support both old format (flat array) and new format (per-corpus object)
40
  if (Array.isArray(annotator.docs)) {
 
34
  const config = yaml.load(text);
35
 
36
  const annotator = (config.annotators || []).find(a => a.username === username);
37
+ if (!annotator || !annotator.docs) return null; // user not in config — see all docs
38
 
39
  // Support both old format (flat array) and new format (per-corpus object)
40
  if (Array.isArray(annotator.docs)) {
middleware.js CHANGED
@@ -42,17 +42,7 @@ export function middleware(request) {
42
  );
43
  }
44
 
45
- // Check ALLOWED_USERS if set
46
- const allowedUsers = process.env.ALLOWED_USERS;
47
- if (allowedUsers) {
48
- const allowlist = allowedUsers.split(',').map(u => u.trim().toLowerCase());
49
- if (!allowlist.includes(username.toLowerCase())) {
50
- return NextResponse.json(
51
- { error: `Access denied. User "${username}" is not authorized.` },
52
- { status: 403 }
53
- );
54
- }
55
- }
56
  } catch (e) {
57
  return NextResponse.json(
58
  { error: 'Invalid session cookie. Please sign in again.' },
 
42
  );
43
  }
44
 
45
+
 
 
 
 
 
 
 
 
 
 
46
  } catch (e) {
47
  return NextResponse.json(
48
  { error: 'Invalid session cookie. Please sign in again.' },