37 Star 407 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
handler.go 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
orangedeng 提交于 2018-09-03 10:44 . Cache the API UI in local file
package publicapi
import (
"context"
"net/http"
"github.com/rancher/norman/store/subtype"
"github.com/rancher/norman/types"
rancherapi "github.com/rancher/rancher/pkg/api"
publicSchema "github.com/rancher/types/apis/management.cattle.io/v3public/schema"
v3public "github.com/rancher/types/client/management/v3public"
"github.com/rancher/types/config"
)
func NewHandler(ctx context.Context, mgmtCtx *config.ScaledContext) (http.Handler, error) {
schemas := types.NewSchemas().AddSchemas(publicSchema.PublicSchemas)
if err := authProviderSchemas(ctx, mgmtCtx, schemas); err != nil {
return nil, err
}
return rancherapi.NewServer(schemas)
}
var authProviderTypes = []string{
v3public.ActiveDirectoryProviderType,
v3public.AzureADProviderType,
v3public.GithubProviderType,
v3public.LocalProviderType,
v3public.OpenLdapProviderType,
v3public.FreeIpaProviderType,
v3public.PingProviderType,
v3public.ADFSProviderType,
v3public.KeyCloakProviderType,
}
func authProviderSchemas(ctx context.Context, management *config.ScaledContext, schemas *types.Schemas) error {
schema := schemas.Schema(&publicSchema.PublicVersion, v3public.AuthProviderType)
setAuthProvidersStore(schema, management)
lh := newLoginHandler(ctx, management)
for _, apSubtype := range authProviderTypes {
subSchema := schemas.Schema(&publicSchema.PublicVersion, apSubtype)
subSchema.Store = subtype.NewSubTypeStore(apSubtype, schema.Store)
subSchema.ActionHandler = lh.login
subSchema.Formatter = loginActionFormatter
}
return nil
}
func loginActionFormatter(apiContext *types.APIContext, resource *types.RawResource) {
resource.AddAction(apiContext, "login")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.4-rc2

搜索帮助