Commit graph

106 commits

Author SHA1 Message Date
XiaoSeS
55e5c1e10e
feat(observability): add generic request correlation and tracing foundation (#664)
* feat(observability): establish request correlation boundary

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* feat(observability): add selectable tracing modes

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* feat(observability): propagate async trace context

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* docs(observability): document tracing deployment modes

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* fix(observability): tighten tracing integration boundaries

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* fix(observability): harden operational log privacy

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* feat(observability): propagate message trace context

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* fix(observability): document message propagation semantics

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* test(auth): isolate security context between tests

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* fix(observability): skip otlp exporter without endpoint

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-08-04 10:26:42 +08:00
XiaoSeS
19c3070291
Merge pull request #607 from gale-popai/fix/device-auth-redis-typing
fix(auth): read device-code state via ObjectMapper conversion, not cast
2026-07-29 03:37:25 +08:00
gale-popai
d977ea9dc4
fix(api): tell callers why a request was forbidden (#610)
* fix(api): tell callers why a request was forbidden

The scope filter already computes an exact reason ("Missing API token
scope: skill:delete", "API token cannot access endpoint: /x") and the
access-denied handler discarded it, returning a bare "Forbidden" for
every case: missing scope, endpoint closed to API tokens, and paths
that simply don't exist. Clients cannot tell those apart, so they
guess — the published CLI reports every 403 as "token may lack
required scope", which sent us debugging token scopes for an hour when
the real causes were a revoked token and a mistyped namespace path.

The reason now rides in the response via a new error.forbidden.detail
message (en + zh), and is logged alongside the exception type.

Signed-off-by: Gal Eyal <gal.e@popai.health>

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(api): safely expose API token denial reasons

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-07-28 17:42:20 +08:00
Gal Eyal
8435ee1ab1 fix(auth): read device-code state via ObjectMapper conversion, not cast
The shared RedisTemplate uses GenericJackson2JsonRedisSerializer with
the application ObjectMapper, which embeds no type information, so
stored DeviceCodeData deserializes as a LinkedHashMap. The typed casts
in pollToken and authorizeDeviceCode then throw ClassCastException on
every call, making the whole device authorization flow unusable
(every poll returns 500).

Convert the raw value with ObjectMapper.convertValue instead of
casting; this reads both the current untyped map format and any typed
format, so no stored-data migration is needed. Adds bean setters to
DeviceCodeData for map conversion and regression tests that feed the
service exactly what Redis returns in production (untyped maps).

Fixes #604

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Gal Eyal <gal.e@popai.health>
2026-07-28 10:27:37 +03:00
dongmucat
665ee0499a feat(auth): add ISSUE-60 password capability field
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-22 12:40:01 +08:00
dongmucat
b56973fb80 fix(auth): fail closed invalid cli bearer tokens
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-17 11:35:16 +08:00
dongmucat
40d7de8462 fix(security): harden review findings
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-12 14:40:30 +08:00
dongmucat
4776550391
Merge pull request #498 from iflytek/feature/cloud-url-builtin-skills
feat(bootstrap): sync built-in skills from cloud manifest
2026-06-11 17:27:26 +08:00
dongmucat
0298823d06 fix(skill): remove namespace bundle backend residues
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-10 19:48:27 +08:00
dongmucat
973c336c82 fix(auth): protect builtin system account boundaries
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-08 18:01:20 +08:00
dongmucat
6bb89b1c89 fix(skill): address namespace bundle review findings
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-04 17:12:44 +08:00
wrj97
21456b9929
fix(auth): use SimpleUrlAuthenticationSuccessHandler for OAuth2 login (#266)
* fix(auth): use SimpleUrlAuthenticationSuccessHandler for OAuth2 login

Replace SavedRequestAwareAuthenticationSuccessHandler with
SimpleUrlAuthenticationSuccessHandler to prevent redirecting to
saved API requests after OAuth2 login.

Previously, when a user accessed a protected API endpoint (e.g.,
/api/web/skills) without authentication, Spring Security would save
that request. After OAuth2 login, the handler would redirect back to
the API endpoint instead of the dashboard.

Now the handler only uses:
- returnTo parameter from session (if present)
- default target URL (/dashboard) as fallback

* test(auth): add regression for OAuth2 success redirect; restore clearAuthenticationAttributes

Cover the no-returnTo + cached-API-request branch with HttpSessionRequestCache so
the original bug (post-login redirect resolving to /api/web/skills) cannot be
silently reintroduced. Also restore clearAuthenticationAttributes() in the
returnTo branch so it stays symmetric with the default branch (super clears it).

---------

Co-authored-by: xiose <huyanlin@nuaa.edu.cn>
2026-05-19 10:59:46 +08:00
dongmucat
d7d0790b28 fix(auth): close API token scope filter gap on /api/cli/ routes
ApiTokenAuthenticationFilter authenticates /api/cli/** Bearer tokens
but ApiTokenScopeFilter.shouldNotFilter() previously skipped them.
The result: API token requests on CLI routes were authenticated and
authorization-policy-checked, but scope enforcement never ran. Tokens
without skill:publish or skill:delete could call /publish, /publish/validate,
and DELETE despite the policy table requiring those scopes.

Add /api/cli/ to the scope filter's covered prefixes and a filter-level
test that confirms a token missing skill:publish is rejected on the new
validate endpoint. Update the existing CLI controller tests to grant
the appropriate SCOPE_* authorities to their api_token principals so
they continue to pass under enforced scopes.
2026-05-18 15:51:19 +08:00
dongmucat
943294b558 fix(publish): address Codex review findings for dry-run
Fix three blockers and one contract drift issue surfaced in code review:

1. API token policy: add skill:publish scope policy and authentication
   policy for /api/cli/v1/skills/*/publish/validate. Without these the
   AntPathMatcher pattern /publish would not cover /publish/validate,
   so Bearer-token requests would be rejected by the scope filter.

2. Warnings semantics: dry-run now treats warnings as making valid=false.
   The CLI publish flow uses confirmWarnings=false, so the real publish
   rejects any warnings; dry-run must mirror that to avoid false positives.

3. Visibility parameter: validate endpoint now accepts the same
   visibility multipart field as publish. The CLI forwards --visibility
   so invalid values are caught at dry-run time rather than at publish.

4. Schema drift: resolvedSlug and resolvedVersion are nullable in
   practice (returned as null when validation fails before resolution).
   Updated schema.d.ts to reflect string | null instead of optional string.

Tests added:
- RouteSecurityPolicyRegistryTest: validate endpoint scope check
- CliDryRunValidateTest: custom + invalid visibility cases
- publish-dry-run.test.ts: --visibility forwarded to server
2026-05-18 14:50:14 +08:00
dongmucat
84914c9d94
Merge pull request #359 from iflytek/feature/skillhub-cli-v1
Some checks failed
Deploy Docs / build (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(cli): add SkillHub CLI v1
2026-05-09 17:25:24 +08:00
XiaoSeS
a3c07725e5
feat(publish): skill upload limits, nested SKILL.md, session fix (#364)
* feat(publish): increase max file count from 100 to 500

Configurable via SKILLHUB_PUBLISH_MAX_FILE_COUNT env var.

* feat(publish): support SKILL.md in subdirectory with warning for ignored files

When SKILL.md is found in a single subdirectory (e.g. my-skill/SKILL.md),
promote that directory's contents to root and discard files outside it.
Discarded files are reported as warnings through the existing confirm flow.

* feat(publish): pass extraction warnings through confirm flow

When files are ignored during SKILL.md subdirectory promotion,
warnings are surfaced to the user via the existing precheck confirm dialog.

* fix(security): add invalidSessionStrategy to return 401 on expired session

Handles the case where Spring Security detects an invalid session cookie,
returning a clean 401 JSON response instead of triggering cascading exceptions.
Closes #360 (part 1/2)

* fix(security): handle session invalidation IllegalStateException as 401

Catches IllegalStateException with "Session was invalidated" message and
returns 401 instead of letting it fall through to the generic 500 handler.
Non-session IllegalStateExceptions are re-thrown to the catch-all handler.
Closes #360 (part 2/2)

* feat(publish): filter macOS metadata and add integration tests

Skip __MACOSX/, .DS_Store, and ._ resource fork entries during zip
extraction. Add integration tests for nested SKILL.md warning flow,
session invalidation 401 response, and macOS metadata filtering.

* test(publish): add real-world macOS zip and edge case integration tests

Covers: macOS zip with nested SKILL.md + __MACOSX + .DS_Store + stray files,
simple macOS single-folder case, and missing SKILL.md fallback behavior.
2026-04-30 11:20:51 +08:00
dongmucat
b30de8d7af fix(auth): add /api/cli/ path to ApiTokenAuthenticationFilter
Enable API token authentication for CLI endpoints by adding /api/cli/
to the filter's path whitelist. Previously, CLI endpoints were not
processed by the token authentication filter, causing all Bearer token
requests to fail with 401.
2026-04-29 15:37:04 +08:00
dongmucat
351dddc912 feat(cli): add SkillHub CLI v1 with full command suite
Implement complete CLI tool for SkillHub with 12 commands, 7 backend API endpoints, and comprehensive documentation.

CLI Commands:
- help, version: Basic information
- login, logout, whoami: Authentication management
- search: Discover published skills
- install: Install skills to agent directories (14 Tier 1 agents supported)
- list, remove, doctor: Local skill management
- publish: Publish skill packages
- update: Self-update mechanism

Backend API:
- Add /api/cli/v1 endpoints for auth, search, resolve, download, delete, publish
- Implement CliAuthController and CliSkillController
- Add security policies for CLI routes
- Full test coverage (19 backend tests)

CLI Implementation:
- TypeScript with strict mode, Bun runtime
- Pure JS zip handling (fflate) for cross-platform compatibility
- 15 agent profiles (14 Tier 1 + generic fallback)
- Secure token storage (0600 permissions)
- Path safety validation for remove operations
- Comprehensive error handling (404/403/network distinction)
- 41 unit and integration tests

Documentation:
- CLI user guide (Chinese and English)
- README updates with quick start
- GitHub Actions workflow for cross-platform CI

Quality:
- lint: 0 errors
- typecheck: pass
- test: 41/41 pass
- build: 0.30 MB (target=node for npm/npx compatibility)
2026-04-29 15:37:04 +08:00
dongmucat
d945c46785 fix(auth): move OIDC email verification to service layer, add logging
Revert emailVerified check in EmailDomainAccessPolicy to preserve
backward compatibility with GitHub/GitLab OAuth users. Instead, null
unverified emails in CustomOidcUserService.toOAuthClaims() so
EmailDomainAccessPolicy naturally denies them via null email.

Add SLF4J logging to CustomOidcUserService for OIDC authentication
flow tracing and failure diagnostics.

Add registration ID collision warning to deployment docs.
2026-04-29 10:36:34 +08:00
dongmucat
fbbd20a5a6 fix(auth): require verified email for domain access
变更摘要:

- 修复 EMAIL_DOMAIN 准入策略,未验证邮箱不再因域名匹配被放行

- 新增回归测试,覆盖 OIDC 场景下 email_verified=false 的拒绝行为

- 保持修复范围收敛,仅调整策略判定与对应测试

关键文件:

- server/skillhub-auth/src/main/java/com/iflytek/skillhub/auth/policy/EmailDomainAccessPolicy.java

- server/skillhub-auth/src/test/java/com/iflytek/skillhub/auth/policy/AccessPolicyTest.java
2026-04-28 16:31:52 +08:00
dongmucat
4f44ea3976 fix(auth): add OIDC sub claim validation and complete env example
- Add null/blank validation for OIDC sub claim in CustomOidcUserService
- Throw OAuth2AuthenticationException when sub is missing or blank
- Complete .env.release.example with all required OIDC environment variables
- Add test cases for sub validation and providerLogin fallback scenarios
- All 5 tests passing
2026-04-28 13:49:26 +08:00
dongmucat
bb9f8915e2 feat(auth): support oidc login 2026-04-24 13:45:20 +08:00
wrj97
7be6a36960
feat(auth): add GitLab OAuth2 provider support (#264)
* feat(auth): add GitLab OAuth2 provider support

Add GitLab as an additional OAuth2 authentication provider alongside
GitHub. This includes:

- GitLab OAuth2 client configuration with customizable base URL
- GitLabClaimsExtractor for handling GitLab-specific user claims
- Multi-provider login UI with provider-specific icons
- Updated localization to use OAuth-agnostic terminology
- JSON type annotation for IdentityBinding entity

* fix(auth): restore oauth redirect and gitlab email checks

* test(auth): align oauth login handler expectation

---------

Co-authored-by: wowo-zZ <zhenggui5228@126.com>
2026-04-17 19:56:32 +08:00
dongmucat
c419a119f1 merge: sync origin/main into fix/security-hardening-unauth 2026-04-14 10:28:25 +08:00
dongmucat
38ebb13133
feat(auth): 邮箱验证码重置密码与 SMTP 配置支持 (#273)
* feat(auth): add email-based password reset with SMTP config docs

* test(e2e): stabilize password reset flow

* test(e2e): isolate password reset rate limits

* test(ci): stabilize backend and register e2e

* docs(auth): sanitize smtp setup examples
2026-04-13 20:27:00 +08:00
dongmucat
27b631a5d6 merge: sync origin/main into fix/security-hardening-unauth 2026-04-10 09:26:19 +08:00
dongmucat
4cc22d0099
fix(auth): avoid extra session rotation after oauth success (#245) 2026-04-09 18:12:24 +08:00
dongmucat
441dc9e0e7 fix(security): close unauthorized metrics and compat access paths 2026-04-07 16:24:15 +08:00
XiaoSeS
86b4d0508b fix(skill): defer version storage deletion until commit (#162)
* fix(skill): resolve duplicate result error when deleting skill with shared namespace+slug

V13 migration changed the unique constraint from (namespace_id, slug) to
(namespace_id, slug, owner_id), allowing multiple skills with the same
namespace+slug but different owners. The findByNamespaceSlugAndSlug query
returned Optional<Skill> which threw IncorrectResultSizeDataAccessException
when 2 rows matched.

Changed the query to return List<Skill> and added ownerId query param to
DELETE endpoints so the frontend can specify exactly which skill to delete.

* fix(review): keep failed scans reviewable and expose feedback

* fix(skill-delete): delete skills by id

* fix(skill): defer version storage deletion until commit
2026-03-26 13:54:30 +08:00
yun-zhi-ztl
6e8b257abb feat(notification): add in-app notifications and harden delivery 2026-03-23 12:31:28 +08:00
Xudong Sun
21ba6ee938 fea: implement skill label system end to end (#140)
* docs(label): add skill label system design spec

Covers data model, permission model, search integration,
API design, and frontend design for the label system.

* docs(label): address spec review findings

- Add CHECK constraint on label_definition.type, deny-by-default in app layer
- Use TIMESTAMPTZ consistently for all new tables
- Add (label_id) index on skill_label for filter performance
- Add label count limits (10 per skill, 100 definitions)
- Detail async rebuild strategy (Spring @Async, batch 50, error isolation)
- Clarify search_vector is GENERATED STORED column, auto-maintained
- Expand SearchQuery with labelSlugs field, detail SQL changes
- Define all API response JSON structures
- Clarify PUT update: no slug in body, full-replace translations
- Clarify hard delete with audit_log
- Add cross-namespace permission boundary (promotion scenario)
- Pre-reserve multi-label API param for future
- Clarify ClawHub compat layer: no label support in phase 1

* docs(label): address second-round spec review findings

- Fix chapter numbering (duplicate "6." → "6." + "7.")
- Move labelSlugs to end of SearchQuery record to reduce breaking change
- Add TIMESTAMPTZ convention note for new tables
- Clarify async rebuild transaction boundary (per-skill independent tx)
- Move rebuildByLabelId to app layer to preserve module boundaries
- Clarify multi-label filter uses OR semantics with AND extension path

* docs(label): fix section numbering in frontend design chapter

* Implement skill label system end to end

* Unify label app services and DTOs

* Add admin label management page

* Add label admin backend tests

* Fix merge fallout in generated schema
2026-03-20 15:26:41 +08:00
vsxd
a17deb9b7f test(app): cover missing query context paths 2026-03-20 11:33:32 +08:00
vsxd
ef7332d520 refactor(app): clarify query boundaries and workflow owners 2026-03-20 11:33:32 +08:00
yun-zhi-ztl
94ecc4d0b2 feat: add super-admin hard delete skill api (#131)
* feat: add super-admin hard delete skill api

* fix: address hard delete review feedback

* fix: add missing unarchive skill locale

* docs: add skill detail hard delete design

* feat: add owner hard delete flow for skill details
2026-03-20 11:02:02 +08:00
vsxd
2868c10467 refactor(app): slim portal controllers and sync backend findings 2026-03-20 10:09:03 +08:00
vsxd
9bad6a38e2 chore(release): v0.1.0 2026-03-19 20:25:18 +08:00
vsxd
25de227f1b refactor: consolidate backend workflow and security policies 2026-03-19 15:20:08 +08:00
vsxd
8ef53d0fdd docs: enrich backend code documentation 2026-03-19 13:37:21 +08:00
vsxd
0814b8939c refactor: unify backend time handling in utc 2026-03-18 17:16:55 +08:00
vsxd
72054dee0f Allow anonymous downloads for global public skills 2026-03-17 20:25:26 +08:00
vsxd
e52853c49c test: cover role and user status permission edges 2026-03-17 14:27:25 +08:00
vsxd
033ac54c76 chore: unify build and test entrypoints 2026-03-17 14:09:22 +08:00
vsxd
66cbdd7b57 fix: official site urls removed 2026-03-16 21:25:55 +08:00
tww
3ab76b201a cli login fix 2026-03-16 17:33:12 +08:00
tww
bd83f91648 cli fix 2026-03-15 20:34:36 +08:00
yun-zhi-ztl
155a59790a feat(skill): allow withdrawing pending submissions (#40) 2026-03-15 04:26:52 -07:00
yun-zhi-ztl
f544d9419d Merge remote-tracking branch 'origin/main' into feature/project-local
# Conflicts:
#	server/skillhub-app/src/test/java/com/iflytek/skillhub/compat/ClawHubRegistryControllerTest.java
#	server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill/service/SkillQueryService.java
2026-03-15 17:57:58 +08:00
yun-zhi-ztl
39b0f3c852 fix(security): add baseline content security policy 2026-03-15 17:40:20 +08:00
yun-zhi-ztl
458fc6b300 fix(security): enforce admin roles and expand audit log filters 2026-03-15 17:38:51 +08:00
yun-zhi-ztl
d6fac50309 fix(security): harden auth boundaries and metrics access 2026-03-15 17:29:51 +08:00