mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
Drop the last old-stack coupling: ai no longer links the retired Casdoor SDK
module github.com/hanzoai/iam-v1 (which dragged beego/xorm/ldap/aliyun/aws into
ai's build for server code ai never ran). Replace it with an ai-internal
package internal/iam (package iam) that talks to Hanzo IAM (hanzo.id) over
standard OIDC — JWKS token verification against {endpoint}/v1/iam/.well-known/
jwks — and the IAM server's JSON REST API (/v1/iam/get-user, get-organization,
get-application, permissions, resources, send-email, oauth token exchange).
- internal/iam mirrors the IAM wire models. User/Permission/Resource keep the
FULL field set with json tags: object/redact.go reflects over every User
field by json tag as a fail-secure secret-redaction control, so a slim User
would silently weaken it and break redact_test. Read-only response types
(Organization/Application/Provider/Cert) are projections of the fields ai reads.
- All 79 importing files swap github.com/hanzoai/iam-v1 →
github.com/hanzoai/ai/internal/iam (package name unchanged, so call sites are
untouched). iam-v1 require dropped; go mod tidy.
- No Casdoor call was stubbed: SendEmail/UploadResource/GetResources/
DeleteResourceWithTag were already clean /v1/iam/ REST calls, reproduced
faithfully (zero behavior change), not faked.
Verify: CGO_ENABLED=0 go build ./... clean; go vet ./... clean; redaction
security tests pass (TestRedactUserSecrets/AllowlistFailSecure/Claims/NilSafe).
Co-authored-by: Hanzo Dev <[email protected]>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
// Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
|
|
// Portions Copyright 2023 The OpenAgent Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package controllers
|
|
|
|
import iam "github.com/hanzoai/ai/internal/iam"
|
|
|
|
func getStorageProviders() ([]*iam.Provider, error) {
|
|
providers, err := iam.GetProviders()
|
|
if err != nil {
|
|
return providers, err
|
|
}
|
|
|
|
res := []*iam.Provider{}
|
|
for _, provider := range providers {
|
|
if provider.Category == "Storage" {
|
|
res = append(res, provider)
|
|
}
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetStorageProviders
|
|
// @Title GetStorageProviders
|
|
// @Tag Storage Provider API
|
|
// @Description get storage providers
|
|
// @Success 200 {array} object.Provider The Response object
|
|
// @router /get-storage-providers [get]
|
|
func (c *ApiController) GetStorageProviders() {
|
|
if _, ok := c.RequireSignedInUser(); !ok {
|
|
return
|
|
}
|
|
|
|
providers, err := getStorageProviders()
|
|
if err != nil {
|
|
c.ResponseError(err.Error())
|
|
return
|
|
}
|
|
|
|
c.ResponseOk(providers)
|
|
}
|