Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

link-based-auth基于链接的身份验证

Agent Skill

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

总安装

915

周安装

37

GitHub Stars

公开资料未说明

下载量

287
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:link-based-auth(基于链接的身份验证)
来源仓库:https://github.com/loxosceles/ai-dev
仓库路径:skills/link-based-auth
安装命令:
npx skills add https://github.com/loxosceles/ai-dev --skill link-based-auth
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/loxosceles/ai-dev --skill link-based-auth

简介

link-based-auth 用于辅助安全审计、权限检查和认证流程分析。

  • 适合梳理敏感配置、检查依赖风险或生成安全复核清单。
  • 不能将工具输出直接作为最终结论,涉及密钥或生产系统时应先确认最小权限。
  • 使用时需脱敏用户数据并明确操作边界,避免越权访问。
  • 建议结合项目现有鉴权逻辑和业务语义进行二次验证。

SKILL.md

Link-Based Authentication

This is a reference pattern. Learn from the approach, adapt to your context — don't copy verbatim.

Problem: Some applications need personalized experiences without the friction of login screens — portfolio sites, demo apps, invite-only access.

Solution: Embed authentication tokens in personalized URLs. An edge function validates the token and sets a session cookie, giving the visitor a seamless authenticated experience.


Pattern

Flow:

1. Admin generates personalized link with embedded token
2. Visitor clicks link
3. CDN edge function intercepts request
4. Edge function validates token, sets auth cookie
5. Frontend loads with authentication already established
6. API requests use cookie/token for authorization

Architecture:

Personalized Link (contains token)
    ↓
CDN Edge Function
    ├── Valid token → Set cookie, redirect to app
    └── No/invalid token → Serve public view
    ↓
Static Frontend (reads cookie for auth state)
    ↓
API (validates token from Authorization header)

Key Components:

  • Link Generator — Creates URLs with embedded tokens, associates each with visitor metadata
  • Identity Backend — Maps tokens to virtual user identities (e.g., Cognito users created without passwords)
  • Edge Auth Function — Validates tokens at CDN edge, sets session cookies
  • Auth Context — Frontend context that extracts tokens from cookies and provides auth state to components

Why This Pattern?

Benefits:

  • Zero friction: No login screen, no password, no signup
  • Personalized: Each link maps to a specific visitor identity
  • Secure: Tokens are validated server-side, cookies are HttpOnly/Secure
  • Tamper-proof: URL manipulation is ineffective — auth is tied to backend identities

Use Cases:

  • Portfolio sites with recruiter-specific views
  • Demo applications with invite-only access
  • Marketing sites with gated personalized content
  • Documentation with customer-specific sections

Implementation

Edge Authentication

// Edge function (Lambda@Edge, CloudFlare Worker, etc.)
export async function handler(event) {
  const request = event.Records[0].cf.request;
  const params = new URLSearchParams(request.querystring);
  const token = params.get('token');

  if (token) {
    const isValid = await validateToken(token);
    if (isValid) {
      return {
        status: '302',
        headers: {
          'location': [{ value: '/' }],
          'set-cookie': [{ value: `auth=${token}; Secure; HttpOnly; SameSite=Strict` }],
        },
      };
    }
  }

  // Check existing session cookie
  const cookies = request.headers.cookie?.[0]?.value || '';
  if (cookies.includes('auth=')) {
    return request; // Authenticated, proceed
  }

  return request; // Unauthenticated, serve public view
}

Frontend Auth Context

// lib/auth/auth-context.tsx
export function useAuth() {
  const tokens = extractTokensFromCookies();
  const environment = detectEnvironment();

  const getAuthHeaders = (routeType: 'public' | 'protected') => {
    if (environment === 'local') {
      return { 'x-api-key': process.env.NEXT_PUBLIC_API_KEY };
    }
    if (routeType === 'public') {
      return { 'x-api-key': process.env.NEXT_PUBLIC_API_KEY };
    }
    if (tokens.accessToken) {
      return { Authorization: `Bearer ${tokens.accessToken}` };
    }
    return {};
  };

  return {
    isAuthenticated: !!tokens.accessToken,
    environment,
    getAuthHeaders,
  };
}

Hook-Based Data Fetching

// lib/profile/use-profile.ts
export function useProfile() {
  const { isAuthenticated, getAuthHeaders } = useAuth();

  const { data, loading } = useQuery(GET_PROFILE, {
    skip: !isAuthenticated,
    context: { headers: getAuthHeaders('protected') },
  });

  return { profile: data?.profile, isLoading: loading };
}

Security Considerations

  • Cookie flags: Secure, HttpOnly, SameSite=Strict — prevents XSS and CSRF
  • Token expiration: Short-lived tokens limit exposure window
  • Content isolation: Each token maps to a specific identity — visitors only see their content
  • No client-side secrets: Tokens are validated server-side; frontend only reads the result
  • Direct URL access: Without a valid token/cookie, only public content is visible (by design)

Local Development

For local development without real tokens, use an environment-aware interceptor:

export function useLocalInterceptor() {
  const { environment } = useAuth();
  const visitorId = useSearchParams()?.get('visitor');
  const shouldIntercept = environment === 'local' && !!visitorId;

  return {
    shouldIntercept,
    getMockData: () => ({
      name: `Test Visitor ${visitorId}`,
      message: 'Mock data for local development',
    }),
  };
}

Components check the interceptor first, falling back to real data:

function PersonalizedContent() {
  const interceptor = useLocalInterceptor();
  const { data } = useRealData();

  const content = interceptor.shouldIntercept
    ? interceptor.getMockData()
    : data;

  return <div>{content.message}</div>;
}

When NOT to Use

  • Sensitive data: This pattern is for personalization, not for protecting highly sensitive information
  • Long-lived sessions: Token-based links are best for short interactions, not persistent accounts
  • Complex auth flows: If you need MFA, password reset, or role management, use a full auth provider

Related Patterns

  • Static Frontend Hosting — The hosting infrastructure this auth pattern runs on
  • Environment Deployment Strategy — How environments affect auth configuration

Progressive Improvement

If the developer corrects a behavior that this skill should have prevented, suggest a specific amendment to this skill to prevent the same correction in the future.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.22%
按下载量换算110

Claude

27.26%
按下载量换算78

Cursor

16.86%
按下载量换算48

Gemini CLI

9.36%
按下载量换算27

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills