mirror of
https://github.com/casdoor/casdoor.git
synced 2025-08-10 15:27:48 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b5e9084e5d | ||
![]() |
55d5ae10f2 | ||
![]() |
6986dad295 | ||
![]() |
949feb18af | ||
![]() |
d1f88ca9b8 | ||
![]() |
bfe8e5f3e7 | ||
![]() |
702ee6acd0 | ||
![]() |
0a9587901a | ||
![]() |
577bd6ce58 | ||
![]() |
3c4112dd44 |
226
controllers/casbin_api.go
Normal file
226
controllers/casbin_api.go
Normal file
@@ -0,0 +1,226 @@
|
||||
// Copyright 2022 The Casdoor 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 (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/casdoor/casdoor/object"
|
||||
"github.com/casdoor/casdoor/util"
|
||||
)
|
||||
|
||||
// Enforce
|
||||
// @Title Enforce
|
||||
// @Tag Enforce API
|
||||
// @Description Call Casbin Enforce API
|
||||
// @Param body body object.CasbinRequest true "Casbin request"
|
||||
// @Param permissionId query string false "permission id"
|
||||
// @Param modelId query string false "model id"
|
||||
// @Param resourceId query string false "resource id"
|
||||
// @Success 200 {object} controllers.Response The Response object
|
||||
// @router /enforce [post]
|
||||
func (c *ApiController) Enforce() {
|
||||
permissionId := c.Input().Get("permissionId")
|
||||
modelId := c.Input().Get("modelId")
|
||||
resourceId := c.Input().Get("resourceId")
|
||||
|
||||
var request object.CasbinRequest
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &request)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if permissionId != "" {
|
||||
permission, err := object.GetPermission(permissionId)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res := []bool{}
|
||||
|
||||
if permission == nil {
|
||||
res = append(res, false)
|
||||
} else {
|
||||
enforceResult, err := object.Enforce(permission, &request)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
return
|
||||
}
|
||||
|
||||
permissions := []*object.Permission{}
|
||||
if modelId != "" {
|
||||
owner, modelName := util.GetOwnerAndNameFromId(modelId)
|
||||
permissions, err = object.GetPermissionsByModel(owner, modelName)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
} else if resourceId != "" {
|
||||
permissions, err = object.GetPermissionsByResource(resourceId)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.ResponseError(c.T("general:Missing parameter"))
|
||||
return
|
||||
}
|
||||
|
||||
res := []bool{}
|
||||
|
||||
listPermissionIdMap := object.GroupPermissionsByModelAdapter(permissions)
|
||||
for _, permissionIds := range listPermissionIdMap {
|
||||
firstPermission, err := object.GetPermission(permissionIds[0])
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
enforceResult, err := object.Enforce(firstPermission, &request, permissionIds...)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
}
|
||||
|
||||
// BatchEnforce
|
||||
// @Title BatchEnforce
|
||||
// @Tag Enforce API
|
||||
// @Description Call Casbin BatchEnforce API
|
||||
// @Param body body object.CasbinRequest true "array of casbin requests"
|
||||
// @Param permissionId query string false "permission id"
|
||||
// @Param modelId query string false "model id"
|
||||
// @Success 200 {object} controllers.Response The Response object
|
||||
// @router /batch-enforce [post]
|
||||
func (c *ApiController) BatchEnforce() {
|
||||
permissionId := c.Input().Get("permissionId")
|
||||
modelId := c.Input().Get("modelId")
|
||||
|
||||
var requests []object.CasbinRequest
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &requests)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if permissionId != "" {
|
||||
permission, err := object.GetPermission(permissionId)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res := [][]bool{}
|
||||
|
||||
if permission == nil {
|
||||
l := len(requests)
|
||||
resRequest := make([]bool, l)
|
||||
for i := 0; i < l; i++ {
|
||||
resRequest[i] = false
|
||||
}
|
||||
|
||||
res = append(res, resRequest)
|
||||
} else {
|
||||
enforceResult, err := object.BatchEnforce(permission, &requests)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
return
|
||||
}
|
||||
|
||||
permissions := []*object.Permission{}
|
||||
if modelId != "" {
|
||||
owner, modelName := util.GetOwnerAndNameFromId(modelId)
|
||||
permissions, err = object.GetPermissionsByModel(owner, modelName)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.ResponseError(c.T("general:Missing parameter"))
|
||||
return
|
||||
}
|
||||
|
||||
res := [][]bool{}
|
||||
|
||||
listPermissionIdMap := object.GroupPermissionsByModelAdapter(permissions)
|
||||
for _, permissionIds := range listPermissionIdMap {
|
||||
firstPermission, err := object.GetPermission(permissionIds[0])
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
enforceResult, err := object.BatchEnforce(firstPermission, &requests, permissionIds...)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
}
|
||||
|
||||
func (c *ApiController) GetAllObjects() {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
c.ResponseError(c.T("general:Please login first"))
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetAllObjects(userId))
|
||||
}
|
||||
|
||||
func (c *ApiController) GetAllActions() {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
c.ResponseError(c.T("general:Please login first"))
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetAllActions(userId))
|
||||
}
|
||||
|
||||
func (c *ApiController) GetAllRoles() {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
c.ResponseError(c.T("general:Please login first"))
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetAllRoles(userId))
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 The Casdoor Authors. All Rights Reserved.
|
||||
// Copyright 2023 The Casdoor 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.
|
||||
@@ -17,210 +17,129 @@ package controllers
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/beego/beego/utils/pagination"
|
||||
"github.com/casdoor/casdoor/object"
|
||||
"github.com/casdoor/casdoor/util"
|
||||
)
|
||||
|
||||
// Enforce
|
||||
// @Title Enforce
|
||||
// @Tag Enforce API
|
||||
// @Description Call Casbin Enforce API
|
||||
// @Param body body object.CasbinRequest true "Casbin request"
|
||||
// @Param permissionId query string false "permission id"
|
||||
// @Param modelId query string false "model id"
|
||||
// @Param resourceId query string false "resource id"
|
||||
// @Success 200 {object} controllers.Response The Response object
|
||||
// @router /enforce [post]
|
||||
func (c *ApiController) Enforce() {
|
||||
permissionId := c.Input().Get("permissionId")
|
||||
modelId := c.Input().Get("modelId")
|
||||
resourceId := c.Input().Get("resourceId")
|
||||
// GetEnforcers
|
||||
// @Title GetEnforcers
|
||||
// @Tag Enforcer API
|
||||
// @Description get enforcers
|
||||
// @Param owner query string true "The owner of enforcers"
|
||||
// @Success 200 {array} object.Enforcer
|
||||
// @router /get-enforcers [get]
|
||||
func (c *ApiController) GetEnforcers() {
|
||||
owner := c.Input().Get("owner")
|
||||
limit := c.Input().Get("pageSize")
|
||||
page := c.Input().Get("p")
|
||||
field := c.Input().Get("field")
|
||||
value := c.Input().Get("value")
|
||||
sortField := c.Input().Get("sortField")
|
||||
sortOrder := c.Input().Get("sortOrder")
|
||||
|
||||
var request object.CasbinRequest
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &request)
|
||||
if limit == "" || page == "" {
|
||||
enforcers, err := object.GetEnforcers(owner)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(enforcers)
|
||||
} else {
|
||||
limit := util.ParseInt(limit)
|
||||
count, err := object.GetEnforcerCount(owner, field, value)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
paginator := pagination.SetPaginator(c.Ctx, limit, count)
|
||||
enforcers, err := object.GetPaginationEnforcers(owner, paginator.Offset(), limit, field, value, sortField, sortOrder)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(enforcers)
|
||||
}
|
||||
}
|
||||
|
||||
// GetEnforcer
|
||||
// @Title GetEnforcer
|
||||
// @Tag Enforcer API
|
||||
// @Description get enforcer
|
||||
// @Param id query string true "The id ( owner/name ) of enforcer"
|
||||
// @Success 200 {object} object
|
||||
// @router /get-enforcer [get]
|
||||
func (c *ApiController) GetEnforcer() {
|
||||
id := c.Input().Get("id")
|
||||
|
||||
enforcer, err := object.GetEnforcer(id)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if permissionId != "" {
|
||||
permission, err := object.GetPermission(permissionId)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res := []bool{}
|
||||
|
||||
if permission == nil {
|
||||
res = append(res, false)
|
||||
} else {
|
||||
enforceResult, err := object.Enforce(permission, &request)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
return
|
||||
}
|
||||
|
||||
permissions := []*object.Permission{}
|
||||
if modelId != "" {
|
||||
owner, modelName := util.GetOwnerAndNameFromId(modelId)
|
||||
permissions, err = object.GetPermissionsByModel(owner, modelName)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
} else if resourceId != "" {
|
||||
permissions, err = object.GetPermissionsByResource(resourceId)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.ResponseError(c.T("general:Missing parameter"))
|
||||
return
|
||||
}
|
||||
|
||||
res := []bool{}
|
||||
|
||||
listPermissionIdMap := object.GroupPermissionsByModelAdapter(permissions)
|
||||
for _, permissionIds := range listPermissionIdMap {
|
||||
firstPermission, err := object.GetPermission(permissionIds[0])
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
enforceResult, err := object.Enforce(firstPermission, &request, permissionIds...)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
c.ResponseOk(enforcer)
|
||||
}
|
||||
|
||||
// BatchEnforce
|
||||
// @Title BatchEnforce
|
||||
// @Tag Enforce API
|
||||
// @Description Call Casbin BatchEnforce API
|
||||
// @Param body body object.CasbinRequest true "array of casbin requests"
|
||||
// @Param permissionId query string false "permission id"
|
||||
// @Param modelId query string false "model id"
|
||||
// @Success 200 {object} controllers.Response The Response object
|
||||
// @router /batch-enforce [post]
|
||||
func (c *ApiController) BatchEnforce() {
|
||||
permissionId := c.Input().Get("permissionId")
|
||||
modelId := c.Input().Get("modelId")
|
||||
// UpdateEnforcer
|
||||
// @Title UpdateEnforcer
|
||||
// @Tag Enforcer API
|
||||
// @Description update enforcer
|
||||
// @Param id query string true "The id ( owner/name ) of enforcer"
|
||||
// @Param enforcer body object true "The enforcer object"
|
||||
// @Success 200 {object} object
|
||||
// @router /update-enforcer [post]
|
||||
func (c *ApiController) UpdateEnforcer() {
|
||||
id := c.Input().Get("id")
|
||||
|
||||
var requests []object.CasbinRequest
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &requests)
|
||||
enforcer := object.Enforcer{}
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &enforcer)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if permissionId != "" {
|
||||
permission, err := object.GetPermission(permissionId)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res := [][]bool{}
|
||||
|
||||
if permission == nil {
|
||||
l := len(requests)
|
||||
resRequest := make([]bool, l)
|
||||
for i := 0; i < l; i++ {
|
||||
resRequest[i] = false
|
||||
}
|
||||
|
||||
res = append(res, resRequest)
|
||||
} else {
|
||||
enforceResult, err := object.BatchEnforce(permission, &requests)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
return
|
||||
}
|
||||
|
||||
permissions := []*object.Permission{}
|
||||
if modelId != "" {
|
||||
owner, modelName := util.GetOwnerAndNameFromId(modelId)
|
||||
permissions, err = object.GetPermissionsByModel(owner, modelName)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.ResponseError(c.T("general:Missing parameter"))
|
||||
return
|
||||
}
|
||||
|
||||
res := [][]bool{}
|
||||
|
||||
listPermissionIdMap := object.GroupPermissionsByModelAdapter(permissions)
|
||||
for _, permissionIds := range listPermissionIdMap {
|
||||
firstPermission, err := object.GetPermission(permissionIds[0])
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
enforceResult, err := object.BatchEnforce(firstPermission, &requests, permissionIds...)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, enforceResult)
|
||||
}
|
||||
|
||||
c.ResponseOk(res)
|
||||
c.Data["json"] = wrapActionResponse(object.UpdateEnforcer(id, &enforcer))
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *ApiController) GetAllObjects() {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
c.ResponseError(c.T("general:Please login first"))
|
||||
// AddEnforcer
|
||||
// @Title AddEnforcer
|
||||
// @Tag Enforcer API
|
||||
// @Description add enforcer
|
||||
// @Param enforcer body object true "The enforcer object"
|
||||
// @Success 200 {object} object
|
||||
// @router /add-enforcer [post]
|
||||
func (c *ApiController) AddEnforcer() {
|
||||
enforcer := object.Enforcer{}
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &enforcer)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetAllObjects(userId))
|
||||
c.Data["json"] = wrapActionResponse(object.AddEnforcer(&enforcer))
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *ApiController) GetAllActions() {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
c.ResponseError(c.T("general:Please login first"))
|
||||
// DeleteEnforcer
|
||||
// @Title DeleteEnforcer
|
||||
// @Tag Enforcer API
|
||||
// @Description delete enforcer
|
||||
// @Param body body object.Enforce true "The enforcer object"
|
||||
// @Success 200 {object} object
|
||||
// @router /delete-enforcer [post]
|
||||
func (c *ApiController) DeleteEnforcer() {
|
||||
var enforcer object.Enforcer
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &enforcer)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetAllActions(userId))
|
||||
}
|
||||
|
||||
func (c *ApiController) GetAllRoles() {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
c.ResponseError(c.T("general:Please login first"))
|
||||
return
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetAllRoles(userId))
|
||||
c.Data["json"] = wrapActionResponse(object.DeleteEnforcer(&enforcer))
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
@@ -94,11 +94,10 @@ func (c *ApiController) GetPlan() {
|
||||
plan.Options = append(plan.Options, option.DisplayName)
|
||||
}
|
||||
|
||||
c.Data["json"] = plan
|
||||
c.ResponseOk(plan)
|
||||
} else {
|
||||
c.Data["json"] = plan
|
||||
c.ResponseOk(plan)
|
||||
}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
// UpdatePlan
|
||||
|
@@ -88,8 +88,7 @@ func (c *ApiController) GetProduct() {
|
||||
return
|
||||
}
|
||||
|
||||
c.Data["json"] = product
|
||||
c.ServeJSON()
|
||||
c.ResponseOk(product)
|
||||
}
|
||||
|
||||
// UpdateProduct
|
||||
|
@@ -21,15 +21,39 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/casdoor/casdoor/util"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
const GoogleIdTokenKey = "GoogleIdToken"
|
||||
|
||||
type GoogleIdProvider struct {
|
||||
Client *http.Client
|
||||
Config *oauth2.Config
|
||||
}
|
||||
|
||||
// https://developers.google.com/identity/sign-in/web/backend-auth#calling-the-tokeninfo-endpoint
|
||||
type GoogleIdToken struct {
|
||||
// These six fields are included in all Google ID Tokens.
|
||||
Iss string `json:"iss"` // The issuer, or signer, of the token. For Google-signed ID tokens, this value is https://accounts.google.com.
|
||||
Sub string `json:"sub"` // The subject: the ID that represents the principal making the request.
|
||||
Azp string `json:"azp"` // Optional. Who the token was issued to. Here is the ClientID
|
||||
Aud string `json:"aud"` // The audience of the token. Here is the ClientID
|
||||
Iat string `json:"iat"` // Unix epoch time when the token was issued.
|
||||
Exp string `json:"exp"` // Unix epoch time when the token expires.
|
||||
// These seven fields are only included when the user has granted the "profile" and "email" OAuth scopes to the application.
|
||||
Email string `json:"email"`
|
||||
EmailVerified string `json:"email_verified"`
|
||||
Name string `json:"name"`
|
||||
Picture string `json:"picture"`
|
||||
GivenName string `json:"given_name"`
|
||||
FamilyName string `json:"family_name"`
|
||||
Locale string `json:"locale"`
|
||||
}
|
||||
|
||||
func NewGoogleIdProvider(clientId string, clientSecret string, redirectUrl string) *GoogleIdProvider {
|
||||
idp := &GoogleIdProvider{}
|
||||
|
||||
@@ -61,6 +85,25 @@ func (idp *GoogleIdProvider) getConfig() *oauth2.Config {
|
||||
}
|
||||
|
||||
func (idp *GoogleIdProvider) GetToken(code string) (*oauth2.Token, error) {
|
||||
// Obtained the GoogleIdToken through Google OneTap authorization.
|
||||
if strings.HasPrefix(code, GoogleIdTokenKey) {
|
||||
code = strings.TrimPrefix(code, GoogleIdTokenKey+"-")
|
||||
var googleIdToken GoogleIdToken
|
||||
if err := json.Unmarshal([]byte(code), &googleIdToken); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
expiry := int64(util.ParseInt(googleIdToken.Exp))
|
||||
token := &oauth2.Token{
|
||||
AccessToken: fmt.Sprintf("%v-%v", GoogleIdTokenKey, googleIdToken.Sub),
|
||||
TokenType: "Bearer",
|
||||
Expiry: time.Unix(expiry, 0),
|
||||
}
|
||||
token = token.WithExtra(map[string]interface{}{
|
||||
GoogleIdTokenKey: googleIdToken,
|
||||
})
|
||||
return token, nil
|
||||
}
|
||||
|
||||
ctx := context.WithValue(context.Background(), oauth2.HTTPClient, idp.Client)
|
||||
return idp.Config.Exchange(ctx, code)
|
||||
}
|
||||
@@ -88,6 +131,20 @@ type GoogleUserInfo struct {
|
||||
}
|
||||
|
||||
func (idp *GoogleIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error) {
|
||||
if strings.HasPrefix(token.AccessToken, GoogleIdTokenKey) {
|
||||
googleIdToken, ok := token.Extra(GoogleIdTokenKey).(GoogleIdToken)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid googleIdToken")
|
||||
}
|
||||
userInfo := UserInfo{
|
||||
Id: googleIdToken.Sub,
|
||||
Username: googleIdToken.Email,
|
||||
DisplayName: googleIdToken.Name,
|
||||
Email: googleIdToken.Email,
|
||||
AvatarUrl: googleIdToken.Picture,
|
||||
}
|
||||
return &userInfo, nil
|
||||
}
|
||||
url := fmt.Sprintf("https://www.googleapis.com/oauth2/v2/userinfo?alt=json&access_token=%s", token.AccessToken)
|
||||
resp, err := idp.Client.Get(url)
|
||||
if err != nil {
|
||||
|
@@ -34,7 +34,7 @@ func StartLdapServer() {
|
||||
server.Handle(routes)
|
||||
err := server.ListenAndServe("0.0.0.0:" + conf.GetConfigString("ldapServerPort"))
|
||||
if err != nil {
|
||||
return
|
||||
log.Printf("StartLdapServer() failed, ErrMsg = %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
2
main.go
2
main.go
@@ -39,7 +39,7 @@ func getCreateDatabaseFlag() bool {
|
||||
func main() {
|
||||
createDatabase := getCreateDatabaseFlag()
|
||||
|
||||
object.InitAdapter()
|
||||
object.InitAdapter(createDatabase)
|
||||
object.CreateTables(createDatabase)
|
||||
object.DoMigration()
|
||||
|
||||
|
@@ -42,15 +42,17 @@ func InitConfig() {
|
||||
|
||||
beego.BConfig.WebConfig.Session.SessionOn = true
|
||||
|
||||
InitAdapter()
|
||||
InitAdapter(true)
|
||||
CreateTables(true)
|
||||
DoMigration()
|
||||
}
|
||||
|
||||
func InitAdapter() {
|
||||
err := createDatabaseForPostgres(conf.GetConfigString("driverName"), conf.GetConfigDataSourceName(), conf.GetConfigString("dbName"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
func InitAdapter(createDatabase bool) {
|
||||
if createDatabase {
|
||||
err := createDatabaseForPostgres(conf.GetConfigString("driverName"), conf.GetConfigDataSourceName(), conf.GetConfigString("dbName"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
adapter = NewAdapter(conf.GetConfigString("driverName"), conf.GetConfigDataSourceName(), conf.GetConfigString("dbName"))
|
||||
@@ -197,6 +199,11 @@ func (a *Adapter) createTable() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = a.Engine.Sync2(new(Enforcer))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = a.Engine.Sync2(new(Provider))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -100,6 +100,13 @@ func UpdateCasbinAdapter(id string, casbinAdapter *CasbinAdapter) (bool, error)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if name != casbinAdapter.Name {
|
||||
err := casbinAdapterChangeTrigger(name, casbinAdapter.Name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
session := adapter.Engine.ID(core.PK{owner, name}).AllCols()
|
||||
if casbinAdapter.Password == "***" {
|
||||
session.Omit("password")
|
||||
@@ -180,6 +187,26 @@ func initEnforcer(modelObj *Model, casbinAdapter *CasbinAdapter) (*casbin.Enforc
|
||||
return enforcer, nil
|
||||
}
|
||||
|
||||
func casbinAdapterChangeTrigger(oldName string, newName string) error {
|
||||
session := adapter.Engine.NewSession()
|
||||
defer session.Close()
|
||||
|
||||
err := session.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
enforcer := new(Enforcer)
|
||||
enforcer.Adapter = newName
|
||||
_, err = session.Where("adapter=?", oldName).Update(enforcer)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return session.Commit()
|
||||
}
|
||||
|
||||
func safeReturn(policy []string, i int) string {
|
||||
if len(policy) > i {
|
||||
return policy[i]
|
||||
|
@@ -365,7 +365,7 @@ func CheckAccessPermission(userId string, application *Application) (bool, error
|
||||
if containsAsterisk {
|
||||
return true, err
|
||||
}
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
if allowed, err = enforcer.Enforce(userId, application.Name, "read"); allowed {
|
||||
return allowed, err
|
||||
}
|
||||
|
119
object/enforcer.go
Normal file
119
object/enforcer.go
Normal file
@@ -0,0 +1,119 @@
|
||||
// Copyright 2023 The Casdoor 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 object
|
||||
|
||||
import (
|
||||
"github.com/casbin/casbin/v2"
|
||||
"github.com/casdoor/casdoor/util"
|
||||
"github.com/xorm-io/core"
|
||||
)
|
||||
|
||||
type Enforcer struct {
|
||||
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
|
||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
||||
UpdatedTime string `xorm:"varchar(100) updated" json:"updatedTime"`
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
Description string `xorm:"varchar(100)" json:"description"`
|
||||
|
||||
Model string `xorm:"varchar(100)" json:"model"`
|
||||
Adapter string `xorm:"varchar(100)" json:"adapter"`
|
||||
IsEnabled bool `json:"isEnabled"`
|
||||
|
||||
*casbin.Enforcer
|
||||
}
|
||||
|
||||
func GetEnforcerCount(owner, field, value string) (int64, error) {
|
||||
session := GetSession(owner, -1, -1, field, value, "", "")
|
||||
return session.Count(&Enforcer{})
|
||||
}
|
||||
|
||||
func GetEnforcers(owner string) ([]*Enforcer, error) {
|
||||
enforcers := []*Enforcer{}
|
||||
err := adapter.Engine.Desc("created_time").Find(&enforcers, &Enforcer{Owner: owner})
|
||||
if err != nil {
|
||||
return enforcers, err
|
||||
}
|
||||
|
||||
return enforcers, nil
|
||||
}
|
||||
|
||||
func GetPaginationEnforcers(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*Enforcer, error) {
|
||||
enforcers := []*Enforcer{}
|
||||
session := GetSession(owner, offset, limit, field, value, sortField, sortOrder)
|
||||
err := session.Find(&enforcers)
|
||||
if err != nil {
|
||||
return enforcers, err
|
||||
}
|
||||
|
||||
return enforcers, nil
|
||||
}
|
||||
|
||||
func getEnforcer(owner string, name string) (*Enforcer, error) {
|
||||
if owner == "" || name == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
enforcer := Enforcer{Owner: owner, Name: name}
|
||||
existed, err := adapter.Engine.Get(&enforcer)
|
||||
if err != nil {
|
||||
return &enforcer, err
|
||||
}
|
||||
|
||||
if existed {
|
||||
return &enforcer, nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func GetEnforcer(id string) (*Enforcer, error) {
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
return getEnforcer(owner, name)
|
||||
}
|
||||
|
||||
func UpdateEnforcer(id string, enforcer *Enforcer) (bool, error) {
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
if oldEnforcer, err := getEnforcer(owner, name); err != nil {
|
||||
return false, err
|
||||
} else if oldEnforcer == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
affected, err := adapter.Engine.ID(core.PK{owner, name}).AllCols().Update(enforcer)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return affected != 0, nil
|
||||
}
|
||||
|
||||
func AddEnforcer(enforcer *Enforcer) (bool, error) {
|
||||
affected, err := adapter.Engine.Insert(enforcer)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return affected != 0, nil
|
||||
}
|
||||
|
||||
func DeleteEnforcer(enforcer *Enforcer) (bool, error) {
|
||||
affected, err := adapter.Engine.ID(core.PK{enforcer.Owner, enforcer.Name}).Delete(&Enforcer{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return affected != 0, nil
|
||||
}
|
@@ -154,6 +154,15 @@ func modelChangeTrigger(oldName string, newName string) error {
|
||||
permission.Model = newName
|
||||
_, err = session.Where("model=?", oldName).Update(permission)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
enforcer := new(Enforcer)
|
||||
enforcer.Model = newName
|
||||
_, err = session.Where("model=?", oldName).Update(enforcer)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -161,5 +170,8 @@ func modelChangeTrigger(oldName string, newName string) error {
|
||||
}
|
||||
|
||||
func HasRoleDefinition(m model.Model) bool {
|
||||
if m == nil {
|
||||
return false
|
||||
}
|
||||
return m["g"] != nil
|
||||
}
|
||||
|
@@ -112,13 +112,13 @@ func getPermission(owner string, name string) (*Permission, error) {
|
||||
}
|
||||
|
||||
func GetPermission(id string) (*Permission, error) {
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||
return getPermission(owner, name)
|
||||
}
|
||||
|
||||
// checkPermissionValid verifies if the permission is valid
|
||||
func checkPermissionValid(permission *Permission) error {
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
enforcer.EnableAutoSave(false)
|
||||
|
||||
policies := getPolicies(permission)
|
||||
@@ -149,7 +149,7 @@ func UpdatePermission(id string, permission *Permission) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||
oldPermission, err := getPermission(owner, name)
|
||||
if oldPermission == nil {
|
||||
return false, nil
|
||||
|
@@ -26,42 +26,7 @@ import (
|
||||
xormadapter "github.com/casdoor/xorm-adapter/v3"
|
||||
)
|
||||
|
||||
func getEnforcer(permission *Permission, permissionIDs ...string) *casbin.Enforcer {
|
||||
tableName := "permission_rule"
|
||||
if len(permission.Adapter) != 0 {
|
||||
adapterObj, err := getCasbinAdapter(permission.Owner, permission.Adapter)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if adapterObj != nil && adapterObj.Table != "" {
|
||||
tableName = adapterObj.Table
|
||||
}
|
||||
}
|
||||
tableNamePrefix := conf.GetConfigString("tableNamePrefix")
|
||||
driverName := conf.GetConfigString("driverName")
|
||||
dataSourceName := conf.GetConfigRealDataSourceName(driverName)
|
||||
adapter, err := xormadapter.NewAdapterWithTableName(driverName, dataSourceName, tableName, tableNamePrefix, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
permissionModel, err := getModel(permission.Owner, permission.Model)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
m := model.Model{}
|
||||
if permissionModel != nil {
|
||||
m, err = GetBuiltInModel(permissionModel.ModelText)
|
||||
} else {
|
||||
m, err = GetBuiltInModel("")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
func getPermissionEnforcer(p *Permission, permissionIDs ...string) *casbin.Enforcer {
|
||||
// Init an enforcer instance without specifying a model or adapter.
|
||||
// If you specify an adapter, it will load all policies, which is a
|
||||
// heavy process that can slow down the application.
|
||||
@@ -70,14 +35,17 @@ func getEnforcer(permission *Permission, permissionIDs ...string) *casbin.Enforc
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = enforcer.InitWithModelAndAdapter(m, nil)
|
||||
err = p.setEnforcerModel(enforcer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
enforcer.SetAdapter(adapter)
|
||||
err = p.setEnforcerAdapter(enforcer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
policyFilterV5 := []string{permission.GetId()}
|
||||
policyFilterV5 := []string{p.GetId()}
|
||||
if len(permissionIDs) != 0 {
|
||||
policyFilterV5 = permissionIDs
|
||||
}
|
||||
@@ -86,7 +54,7 @@ func getEnforcer(permission *Permission, permissionIDs ...string) *casbin.Enforc
|
||||
V5: policyFilterV5,
|
||||
}
|
||||
|
||||
if !HasRoleDefinition(m) {
|
||||
if !HasRoleDefinition(enforcer.GetModel()) {
|
||||
policyFilter.Ptype = []string{"p"}
|
||||
}
|
||||
|
||||
@@ -98,6 +66,54 @@ func getEnforcer(permission *Permission, permissionIDs ...string) *casbin.Enforc
|
||||
return enforcer
|
||||
}
|
||||
|
||||
func (p *Permission) setEnforcerAdapter(enforcer *casbin.Enforcer) error {
|
||||
tableName := "permission_rule"
|
||||
if len(p.Adapter) != 0 {
|
||||
adapterObj, err := getCasbinAdapter(p.Owner, p.Adapter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if adapterObj != nil && adapterObj.Table != "" {
|
||||
tableName = adapterObj.Table
|
||||
}
|
||||
}
|
||||
tableNamePrefix := conf.GetConfigString("tableNamePrefix")
|
||||
driverName := conf.GetConfigString("driverName")
|
||||
dataSourceName := conf.GetConfigRealDataSourceName(driverName)
|
||||
casbinAdapter, err := xormadapter.NewAdapterWithTableName(driverName, dataSourceName, tableName, tableNamePrefix, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
enforcer.SetAdapter(casbinAdapter)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Permission) setEnforcerModel(enforcer *casbin.Enforcer) error {
|
||||
permissionModel, err := getModel(p.Owner, p.Model)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: return error if permissionModel is nil.
|
||||
m := model.Model{}
|
||||
if permissionModel != nil {
|
||||
m, err = GetBuiltInModel(permissionModel.ModelText)
|
||||
} else {
|
||||
m, err = GetBuiltInModel("")
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = enforcer.InitWithModelAndAdapter(m, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getPolicies(permission *Permission) [][]string {
|
||||
var policies [][]string
|
||||
|
||||
@@ -188,7 +204,7 @@ func getGroupingPolicies(permission *Permission) [][]string {
|
||||
}
|
||||
|
||||
func addPolicies(permission *Permission) {
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
policies := getPolicies(permission)
|
||||
|
||||
_, err := enforcer.AddPolicies(policies)
|
||||
@@ -198,7 +214,7 @@ func addPolicies(permission *Permission) {
|
||||
}
|
||||
|
||||
func addGroupingPolicies(permission *Permission) {
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
groupingPolicies := getGroupingPolicies(permission)
|
||||
|
||||
if len(groupingPolicies) > 0 {
|
||||
@@ -210,7 +226,7 @@ func addGroupingPolicies(permission *Permission) {
|
||||
}
|
||||
|
||||
func removeGroupingPolicies(permission *Permission) {
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
groupingPolicies := getGroupingPolicies(permission)
|
||||
|
||||
if len(groupingPolicies) > 0 {
|
||||
@@ -222,7 +238,7 @@ func removeGroupingPolicies(permission *Permission) {
|
||||
}
|
||||
|
||||
func removePolicies(permission *Permission) {
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
policies := getPolicies(permission)
|
||||
|
||||
_, err := enforcer.RemovePolicies(policies)
|
||||
@@ -234,12 +250,12 @@ func removePolicies(permission *Permission) {
|
||||
type CasbinRequest = []interface{}
|
||||
|
||||
func Enforce(permission *Permission, request *CasbinRequest, permissionIds ...string) (bool, error) {
|
||||
enforcer := getEnforcer(permission, permissionIds...)
|
||||
enforcer := getPermissionEnforcer(permission, permissionIds...)
|
||||
return enforcer.Enforce(*request...)
|
||||
}
|
||||
|
||||
func BatchEnforce(permission *Permission, requests *[]CasbinRequest, permissionIds ...string) ([]bool, error) {
|
||||
enforcer := getEnforcer(permission, permissionIds...)
|
||||
enforcer := getPermissionEnforcer(permission, permissionIds...)
|
||||
return enforcer.BatchEnforce(*requests)
|
||||
}
|
||||
|
||||
@@ -260,7 +276,7 @@ func getAllValues(userId string, fn func(enforcer *casbin.Enforcer) []string) []
|
||||
|
||||
var values []string
|
||||
for _, permission := range permissions {
|
||||
enforcer := getEnforcer(permission)
|
||||
enforcer := getPermissionEnforcer(permission)
|
||||
values = append(values, fn(enforcer)...)
|
||||
}
|
||||
return values
|
||||
|
@@ -82,12 +82,12 @@ func getRole(owner string, name string) (*Role, error) {
|
||||
}
|
||||
|
||||
func GetRole(id string) (*Role, error) {
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||
return getRole(owner, name)
|
||||
}
|
||||
|
||||
func UpdateRole(id string, role *Role) (bool, error) {
|
||||
owner, name := util.GetOwnerAndNameFromId(id)
|
||||
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||
oldRole, err := getRole(owner, name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -391,10 +391,13 @@ func GetAncestorRoles(roleIds ...string) ([]*Role, error) {
|
||||
|
||||
// containsRole is a helper function to check if a roles is related to any role in the given list roles
|
||||
func containsRole(role *Role, roleMap map[string]*Role, visited map[string]bool, roleIds ...string) bool {
|
||||
if isContain, ok := visited[role.GetId()]; ok {
|
||||
roleId := role.GetId()
|
||||
if isContain, ok := visited[roleId]; ok {
|
||||
return isContain
|
||||
}
|
||||
|
||||
visited[role.GetId()] = false
|
||||
|
||||
for _, subRole := range role.Roles {
|
||||
if util.HasString(roleIds, subRole) {
|
||||
return true
|
||||
|
@@ -69,7 +69,7 @@ func getObject(ctx *context.Context) (string, string) {
|
||||
// query == "?id=built-in/admin"
|
||||
id := ctx.Input.Query("id")
|
||||
if id != "" {
|
||||
return util.GetOwnerAndNameFromId(id)
|
||||
return util.GetOwnerAndNameFromIdNoCheck(id)
|
||||
}
|
||||
|
||||
owner := ctx.Input.Query("owner")
|
||||
|
@@ -123,6 +123,12 @@ func initAPI() {
|
||||
beego.Router("/api/add-policy", &controllers.ApiController{}, "POST:AddPolicy")
|
||||
beego.Router("/api/remove-policy", &controllers.ApiController{}, "POST:RemovePolicy")
|
||||
|
||||
beego.Router("/api/get-enforcers", &controllers.ApiController{}, "GET:GetEnforcers")
|
||||
beego.Router("/api/get-enforcer", &controllers.ApiController{}, "GET:GetEnforcer")
|
||||
beego.Router("/api/update-enforcer", &controllers.ApiController{}, "POST:UpdateEnforcer")
|
||||
beego.Router("/api/add-enforcer", &controllers.ApiController{}, "POST:AddEnforcer")
|
||||
beego.Router("/api/delete-enforcer", &controllers.ApiController{}, "POST:DeleteEnforcer")
|
||||
|
||||
beego.Router("/api/set-password", &controllers.ApiController{}, "POST:SetPassword")
|
||||
beego.Router("/api/check-user-password", &controllers.ApiController{}, "POST:CheckUserPassword")
|
||||
beego.Router("/api/get-email-and-phone", &controllers.ApiController{}, "GET:GetEmailAndPhone")
|
||||
|
@@ -155,6 +155,34 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/add-enforcer": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Enforcer API"
|
||||
],
|
||||
"description": "add enforcer",
|
||||
"operationId": "ApiController.AddEnforcer",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "enforcer",
|
||||
"description": "The enforcer object",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/add-group": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -1073,6 +1101,34 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/delete-enforcer": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Enforcer API"
|
||||
],
|
||||
"description": "delete enforcer",
|
||||
"operationId": "ApiController.DeleteEnforcer",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "The enforcer object",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object.Enforce"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/delete-group": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -2018,6 +2074,61 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/get-enforcer": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Enforcer API"
|
||||
],
|
||||
"description": "get enforcer",
|
||||
"operationId": "ApiController.GetEnforcer",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "id",
|
||||
"description": "The id ( owner/name ) of enforcer",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/get-enforcers": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Enforcer API"
|
||||
],
|
||||
"description": "get enforcers",
|
||||
"operationId": "ApiController.GetEnforcers",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "owner",
|
||||
"description": "The owner of enforcers",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/object.Enforcer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/get-global-providers": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -4394,6 +4505,41 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/update-enforcer": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Enforcer API"
|
||||
],
|
||||
"description": "update enforcer",
|
||||
"operationId": "ApiController.UpdateEnforcer",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "id",
|
||||
"description": "The id ( owner/name ) of enforcer",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "enforcer",
|
||||
"description": "The enforcer object",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/update-group": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -5273,6 +5419,14 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"1225.0xc000333110.false": {
|
||||
"title": "false",
|
||||
"type": "object"
|
||||
},
|
||||
"1260.0xc000333140.false": {
|
||||
"title": "false",
|
||||
"type": "object"
|
||||
},
|
||||
"LaravelResponse": {
|
||||
"title": "LaravelResponse",
|
||||
"type": "object"
|
||||
@@ -5289,6 +5443,10 @@
|
||||
"title": "Response",
|
||||
"type": "object"
|
||||
},
|
||||
"casbin.Enforcer": {
|
||||
"title": "Enforcer",
|
||||
"type": "object"
|
||||
},
|
||||
"controllers.AuthForm": {
|
||||
"title": "AuthForm",
|
||||
"type": "object"
|
||||
@@ -5322,16 +5480,10 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"additionalProperties": {
|
||||
"description": "support string, struct or []struct",
|
||||
"type": "string"
|
||||
}
|
||||
"$ref": "#/definitions/1225.0xc000333110.false"
|
||||
},
|
||||
"data2": {
|
||||
"additionalProperties": {
|
||||
"description": "support string, struct or []struct",
|
||||
"type": "string"
|
||||
}
|
||||
"$ref": "#/definitions/1260.0xc000333140.false"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
@@ -5373,6 +5525,10 @@
|
||||
"title": "object",
|
||||
"type": "object"
|
||||
},
|
||||
"object.\u0026{197582 0xc000ace360 false}": {
|
||||
"title": "\u0026{197582 0xc000ace360 false}",
|
||||
"type": "object"
|
||||
},
|
||||
"object.AccountItem": {
|
||||
"title": "AccountItem",
|
||||
"type": "object",
|
||||
@@ -5566,7 +5722,7 @@
|
||||
"title": "CasbinRequest",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/object.CasbinRequest"
|
||||
"$ref": "#/definitions/object.\u0026{197582 0xc000ace360 false}"
|
||||
}
|
||||
},
|
||||
"object.Cert": {
|
||||
@@ -5662,6 +5818,43 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"object.Enforce": {
|
||||
"title": "Enforce",
|
||||
"type": "object"
|
||||
},
|
||||
"object.Enforcer": {
|
||||
"title": "Enforcer",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"adapter": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"isEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"owner": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedTime": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"object.GaugeVecInfo": {
|
||||
"title": "GaugeVecInfo",
|
||||
"type": "object",
|
||||
@@ -7323,6 +7516,9 @@
|
||||
"meetup": {
|
||||
"type": "string"
|
||||
},
|
||||
"metamask": {
|
||||
"type": "string"
|
||||
},
|
||||
"mfaEmailEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
@@ -100,6 +100,24 @@ paths:
|
||||
description: The Response object
|
||||
schema:
|
||||
$ref: '#/definitions/controllers.Response'
|
||||
/api/add-enforcer:
|
||||
post:
|
||||
tags:
|
||||
- Enforcer API
|
||||
description: add enforcer
|
||||
operationId: ApiController.AddEnforcer
|
||||
parameters:
|
||||
- in: body
|
||||
name: enforcer
|
||||
description: The enforcer object
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/object'
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
schema:
|
||||
$ref: '#/definitions/object'
|
||||
/api/add-group:
|
||||
post:
|
||||
tags:
|
||||
@@ -693,6 +711,24 @@ paths:
|
||||
description: The Response object
|
||||
schema:
|
||||
$ref: '#/definitions/controllers.Response'
|
||||
/api/delete-enforcer:
|
||||
post:
|
||||
tags:
|
||||
- Enforcer API
|
||||
description: delete enforcer
|
||||
operationId: ApiController.DeleteEnforcer
|
||||
parameters:
|
||||
- in: body
|
||||
name: body
|
||||
description: The enforcer object
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/object.Enforce'
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
schema:
|
||||
$ref: '#/definitions/object'
|
||||
/api/delete-group:
|
||||
post:
|
||||
tags:
|
||||
@@ -1307,6 +1343,42 @@ paths:
|
||||
description: The Response object
|
||||
schema:
|
||||
$ref: '#/definitions/controllers.Response'
|
||||
/api/get-enforcer:
|
||||
get:
|
||||
tags:
|
||||
- Enforcer API
|
||||
description: get enforcer
|
||||
operationId: ApiController.GetEnforcer
|
||||
parameters:
|
||||
- in: query
|
||||
name: id
|
||||
description: The id ( owner/name ) of enforcer
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
schema:
|
||||
$ref: '#/definitions/object'
|
||||
/api/get-enforcers:
|
||||
get:
|
||||
tags:
|
||||
- Enforcer API
|
||||
description: get enforcers
|
||||
operationId: ApiController.GetEnforcers
|
||||
parameters:
|
||||
- in: query
|
||||
name: owner
|
||||
description: The owner of enforcers
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/object.Enforcer'
|
||||
/api/get-global-providers:
|
||||
get:
|
||||
tags:
|
||||
@@ -2869,6 +2941,29 @@ paths:
|
||||
description: The Response object
|
||||
schema:
|
||||
$ref: '#/definitions/controllers.Response'
|
||||
/api/update-enforcer:
|
||||
post:
|
||||
tags:
|
||||
- Enforcer API
|
||||
description: update enforcer
|
||||
operationId: ApiController.UpdateEnforcer
|
||||
parameters:
|
||||
- in: query
|
||||
name: id
|
||||
description: The id ( owner/name ) of enforcer
|
||||
required: true
|
||||
type: string
|
||||
- in: body
|
||||
name: enforcer
|
||||
description: The enforcer object
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/object'
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
schema:
|
||||
$ref: '#/definitions/object'
|
||||
/api/update-group:
|
||||
post:
|
||||
tags:
|
||||
@@ -3446,6 +3541,12 @@ paths:
|
||||
schema:
|
||||
$ref: '#/definitions/controllers.Response'
|
||||
definitions:
|
||||
1225.0xc000333110.false:
|
||||
title: "false"
|
||||
type: object
|
||||
1260.0xc000333140.false:
|
||||
title: "false"
|
||||
type: object
|
||||
LaravelResponse:
|
||||
title: LaravelResponse
|
||||
type: object
|
||||
@@ -3458,6 +3559,9 @@ definitions:
|
||||
Response:
|
||||
title: Response
|
||||
type: object
|
||||
casbin.Enforcer:
|
||||
title: Enforcer
|
||||
type: object
|
||||
controllers.AuthForm:
|
||||
title: AuthForm
|
||||
type: object
|
||||
@@ -3482,13 +3586,9 @@ definitions:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
additionalProperties:
|
||||
description: support string, struct or []struct
|
||||
type: string
|
||||
$ref: '#/definitions/1225.0xc000333110.false'
|
||||
data2:
|
||||
additionalProperties:
|
||||
description: support string, struct or []struct
|
||||
type: string
|
||||
$ref: '#/definitions/1260.0xc000333140.false'
|
||||
msg:
|
||||
type: string
|
||||
name:
|
||||
@@ -3515,6 +3615,9 @@ definitions:
|
||||
object:
|
||||
title: object
|
||||
type: object
|
||||
object.&{197582 0xc000ace360 false}:
|
||||
title: '&{197582 0xc000ace360 false}'
|
||||
type: object
|
||||
object.AccountItem:
|
||||
title: AccountItem
|
||||
type: object
|
||||
@@ -3646,7 +3749,7 @@ definitions:
|
||||
title: CasbinRequest
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/object.CasbinRequest'
|
||||
$ref: '#/definitions/object.&{197582 0xc000ace360 false}'
|
||||
object.Cert:
|
||||
title: Cert
|
||||
type: object
|
||||
@@ -3710,6 +3813,31 @@ definitions:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
object.Enforce:
|
||||
title: Enforce
|
||||
type: object
|
||||
object.Enforcer:
|
||||
title: Enforcer
|
||||
type: object
|
||||
properties:
|
||||
adapter:
|
||||
type: string
|
||||
createdTime:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
displayName:
|
||||
type: string
|
||||
isEnabled:
|
||||
type: boolean
|
||||
model:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
owner:
|
||||
type: string
|
||||
updatedTime:
|
||||
type: string
|
||||
object.GaugeVecInfo:
|
||||
title: GaugeVecInfo
|
||||
type: object
|
||||
@@ -4828,6 +4956,8 @@ definitions:
|
||||
$ref: '#/definitions/object.ManagedAccount'
|
||||
meetup:
|
||||
type: string
|
||||
metamask:
|
||||
type: string
|
||||
mfaEmailEnabled:
|
||||
type: boolean
|
||||
mfaPhoneEnabled:
|
||||
|
@@ -33,6 +33,7 @@
|
||||
"react-device-detect": "^2.2.2",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-github-corner": "^2.5.0",
|
||||
"react-google-one-tap-login": "^0.1.1",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-highlight-words": "^0.18.0",
|
||||
"react-i18next": "^11.8.7",
|
||||
|
@@ -15,10 +15,6 @@
|
||||
import React, {Component} from "react";
|
||||
import "./App.less";
|
||||
import {Helmet} from "react-helmet";
|
||||
import EnableMfaNotification from "./common/notifaction/EnableMfaNotification";
|
||||
import GroupTreePage from "./GroupTreePage";
|
||||
import GroupEditPage from "./GroupEdit";
|
||||
import GroupListPage from "./GroupList";
|
||||
import {MfaRuleRequired} from "./Setting";
|
||||
import * as Setting from "./Setting";
|
||||
import {StyleProvider, legacyLogicalPropertiesTransformer} from "@ant-design/cssinjs";
|
||||
@@ -33,6 +29,11 @@ import RoleListPage from "./RoleListPage";
|
||||
import RoleEditPage from "./RoleEditPage";
|
||||
import PermissionListPage from "./PermissionListPage";
|
||||
import PermissionEditPage from "./PermissionEditPage";
|
||||
import EnforcerEditPage from "./EnforcerEditPage";
|
||||
import EnforcerListPage from "./EnforcerListPage";
|
||||
import GroupTreePage from "./GroupTreePage";
|
||||
import GroupEditPage from "./GroupEdit";
|
||||
import GroupListPage from "./GroupList";
|
||||
import ProviderListPage from "./ProviderListPage";
|
||||
import ProviderEditPage from "./ProviderEditPage";
|
||||
import ApplicationListPage from "./ApplicationListPage";
|
||||
@@ -86,6 +87,7 @@ import OdicDiscoveryPage from "./auth/OidcDiscoveryPage";
|
||||
import SamlCallback from "./auth/SamlCallback";
|
||||
import i18next from "i18next";
|
||||
import {withTranslation} from "react-i18next";
|
||||
import EnableMfaNotification from "./common/notifaction/EnableMfaNotification";
|
||||
import LanguageSelect from "./common/select/LanguageSelect";
|
||||
import ThemeSelect from "./common/select/ThemeSelect";
|
||||
import OrganizationSelect from "./common/select/OrganizationSelect";
|
||||
@@ -164,6 +166,8 @@ class App extends Component {
|
||||
this.setState({selectedMenuKey: "/models"});
|
||||
} else if (uri.includes("/adapters")) {
|
||||
this.setState({selectedMenuKey: "/adapters"});
|
||||
} else if (uri.includes("/enforcers")) {
|
||||
this.setState({selectedMenuKey: "/enforcers"});
|
||||
} else if (uri.includes("/providers")) {
|
||||
this.setState({selectedMenuKey: "/providers"});
|
||||
} else if (uri.includes("/applications")) {
|
||||
@@ -481,6 +485,10 @@ class App extends Component {
|
||||
res.push(Setting.getItem(<Link to="/adapters">{i18next.t("general:Adapters")}</Link>,
|
||||
"/adapters"
|
||||
));
|
||||
|
||||
res.push(Setting.getItem(<Link to="/enforcers">{i18next.t("general:Enforcers")}</Link>,
|
||||
"/enforcers"
|
||||
));
|
||||
}
|
||||
|
||||
if (Setting.isLocalAdminUser(this.state.account)) {
|
||||
@@ -599,6 +607,8 @@ class App extends Component {
|
||||
<Route exact path="/permissions/:organizationName/:permissionName" render={(props) => this.renderLoginIfNotLoggedIn(<PermissionEditPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/models" render={(props) => this.renderLoginIfNotLoggedIn(<ModelListPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/models/:organizationName/:modelName" render={(props) => this.renderLoginIfNotLoggedIn(<ModelEditPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/enforcers" render={(props) => this.renderLoginIfNotLoggedIn(<EnforcerListPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/enforcers/:organizationName/:enforcerName" render={(props) => this.renderLoginIfNotLoggedIn(<EnforcerEditPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/adapters" render={(props) => this.renderLoginIfNotLoggedIn(<AdapterListPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/adapters/:organizationName/:adapterName" render={(props) => this.renderLoginIfNotLoggedIn(<AdapterEditPage account={this.state.account} {...props} />)} />
|
||||
<Route exact path="/providers" render={(props) => this.renderLoginIfNotLoggedIn(<ProviderListPage account={this.state.account} {...props} />)} />
|
||||
|
@@ -129,32 +129,33 @@ class ApplicationEditPage extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.grantTypes === null || res.grantTypes === undefined || res.grantTypes.length === 0) {
|
||||
res.grantTypes = ["authorization_code"];
|
||||
const application = res.data;
|
||||
if (application.grantTypes === null || application.grantTypes === undefined || application.grantTypes.length === 0) {
|
||||
application.grantTypes = ["authorization_code"];
|
||||
}
|
||||
|
||||
if (res.tags === null || res.tags === undefined) {
|
||||
res.tags = [];
|
||||
if (application.tags === null || application.tags === undefined) {
|
||||
application.tags = [];
|
||||
}
|
||||
|
||||
this.setState({
|
||||
application: res.data,
|
||||
application: application,
|
||||
});
|
||||
|
||||
this.getCerts(res.organization);
|
||||
this.getCerts(application.organization);
|
||||
});
|
||||
}
|
||||
|
||||
getOrganizations() {
|
||||
OrganizationBackend.getOrganizations("admin")
|
||||
.then((res) => {
|
||||
if (res?.status === "error") {
|
||||
if (res.status === "error") {
|
||||
this.setState({
|
||||
isAuthorized: false,
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
organizations: (res.msg === undefined) ? res : [],
|
||||
organizations: res.data || [],
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -164,7 +165,7 @@ class ApplicationEditPage extends React.Component {
|
||||
CertBackend.getCerts(owner)
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
certs: (res.msg === undefined) ? res : [],
|
||||
certs: res.data || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ class ChatEditPage extends React.Component {
|
||||
chat: res.data,
|
||||
});
|
||||
|
||||
this.getUsers(res.organization);
|
||||
this.getUsers(res.data.organization);
|
||||
});
|
||||
}
|
||||
|
||||
|
257
web/src/EnforcerEditPage.js
Normal file
257
web/src/EnforcerEditPage.js
Normal file
@@ -0,0 +1,257 @@
|
||||
// Copyright 2023 The Casdoor 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.
|
||||
|
||||
import React from "react";
|
||||
import {Button, Card, Col, Input, Row, Select, Switch} from "antd";
|
||||
import * as AdapterBackend from "./backend/AdapterBackend";
|
||||
import * as EnforcerBackend from "./backend/EnforcerBackend";
|
||||
import * as ModelBackend from "./backend/ModelBackend";
|
||||
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
||||
import * as Setting from "./Setting";
|
||||
import i18next from "i18next";
|
||||
|
||||
class EnforcerEditPage extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
classes: props,
|
||||
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
||||
enforcerName: props.match.params.enforcerName,
|
||||
enforcer: null,
|
||||
organizations: [],
|
||||
models: [],
|
||||
adapters: [],
|
||||
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
||||
};
|
||||
}
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
this.getEnforcer();
|
||||
this.getOrganizations();
|
||||
}
|
||||
|
||||
getEnforcer() {
|
||||
EnforcerBackend.getEnforcer(this.state.organizationName, this.state.enforcerName)
|
||||
.then((res) => {
|
||||
if (res.data === null) {
|
||||
this.props.history.push("/404");
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.status === "error") {
|
||||
Setting.showMessage("error", res.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
enforcer: res.data,
|
||||
});
|
||||
|
||||
this.getModels(this.state.organizationName);
|
||||
this.getAdapters(this.state.organizationName);
|
||||
});
|
||||
}
|
||||
|
||||
getOrganizations() {
|
||||
OrganizationBackend.getOrganizations("admin")
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
organizations: res.data || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getModels(organizationName) {
|
||||
ModelBackend.getModels(organizationName)
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
models: res.data || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getAdapters(organizationName) {
|
||||
AdapterBackend.getAdapters(organizationName)
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
adapters: res.data || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
parseEnforcerField(key, value) {
|
||||
if ([""].includes(key)) {
|
||||
value = Setting.myParseInt(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
updateEnforcerField(key, value) {
|
||||
value = this.parseEnforcerField(key, value);
|
||||
|
||||
const enforcer = this.state.enforcer;
|
||||
enforcer[key] = value;
|
||||
this.setState({
|
||||
enforcer: enforcer,
|
||||
});
|
||||
}
|
||||
|
||||
renderEnforcer() {
|
||||
return (
|
||||
<Card size="small" title={
|
||||
<div>
|
||||
{this.state.mode === "add" ? i18next.t("enforcer:New Enforcer") : i18next.t("enforcer:Edit Enforcer")}
|
||||
<Button onClick={() => this.submitEnforcerEdit(false)}>{i18next.t("general:Save")}</Button>
|
||||
<Button style={{marginLeft: "20px"}} type="primary" onClick={() => this.submitEnforcerEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
||||
{this.state.mode === "add" ? <Button style={{marginLeft: "20px"}} onClick={() => this.deleteEnforcer()}>{i18next.t("general:Cancel")}</Button> : null}
|
||||
</div>
|
||||
} style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner">
|
||||
<Row style={{marginTop: "10px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Select virtual={false} style={{width: "100%"}} disabled={!Setting.isAdminUser(this.props.account)} value={this.state.enforcer.owner} onChange={(owner => {
|
||||
this.updateEnforcerField("owner", owner);
|
||||
this.getModels(owner);
|
||||
this.getAdapters(owner);
|
||||
})}
|
||||
options={this.state.organizations.map((organization) => Setting.getOption(organization.name, organization.name))
|
||||
} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input value={this.state.enforcer.name} onChange={e => {
|
||||
this.updateEnforcerField("name", e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Display name"), i18next.t("general:Display name - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input value={this.state.enforcer.displayName} onChange={e => {
|
||||
this.updateEnforcerField("displayName", e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Description"), i18next.t("general:Description - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input value={this.state.enforcer.description} onChange={e => {
|
||||
this.updateEnforcerField("description", e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Model"), i18next.t("general:Model - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Select virtual={false} style={{width: "100%"}} value={this.state.enforcer.model} onChange={(model => {
|
||||
this.updateEnforcerField("model", model);
|
||||
})}
|
||||
options={this.state.models.map((model) => Setting.getOption(model.displayName, model.name))
|
||||
} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Adapter"), i18next.t("general:Adapter - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Select virtual={false} style={{width: "100%"}} value={this.state.enforcer.adapter} onChange={(adapter => {
|
||||
this.updateEnforcerField("adapter", adapter);
|
||||
})}
|
||||
options={this.state.adapters.map((adapter) => Setting.getOption(adapter.name, adapter.name))
|
||||
} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 19 : 2}>
|
||||
{Setting.getLabel(i18next.t("general:Is enabled"), i18next.t("general:Is enabled - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={1} >
|
||||
<Switch checked={this.state.enforcer.isEnabled} onChange={checked => {
|
||||
this.updateEnforcerField("isEnabled", checked);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
submitEnforcerEdit(willExist) {
|
||||
const enforcer = Setting.deepCopy(this.state.enforcer);
|
||||
EnforcerBackend.updateEnforcer(this.state.organizationName, this.state.enforcerName, enforcer)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
Setting.showMessage("success", i18next.t("general:Successfully saved"));
|
||||
this.setState({
|
||||
enforcerName: this.state.enforcer.name,
|
||||
});
|
||||
|
||||
if (willExist) {
|
||||
this.props.history.push("/enforcers");
|
||||
} else {
|
||||
this.props.history.push(`/enforcers/${this.state.enforcer.owner}/${this.state.enforcer.name}`);
|
||||
}
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
||||
this.updateEnforcerField("name", this.state.enforcerName);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
deleteEnforcer() {
|
||||
EnforcerBackend.deleteEnforcer(this.state.enforcer)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
this.props.history.push("/enforcers");
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
this.state.enforcer !== null ? this.renderEnforcer() : null
|
||||
}
|
||||
<div style={{marginTop: "20px", marginLeft: "40px"}}>
|
||||
<Button size="large" onClick={() => this.submitEnforcerEdit(false)}>{i18next.t("general:Save")}</Button>
|
||||
<Button style={{marginLeft: "20px"}} type="primary" size="large" onClick={() => this.submitEnforcerEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
||||
{this.state.mode === "add" ? <Button style={{marginLeft: "20px"}} size="large" onClick={() => this.deleteEnforcer()}>{i18next.t("general:Cancel")}</Button> : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default EnforcerEditPage;
|
218
web/src/EnforcerListPage.js
Normal file
218
web/src/EnforcerListPage.js
Normal file
@@ -0,0 +1,218 @@
|
||||
// Copyright 2023 The Casdoor 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.
|
||||
|
||||
import React from "react";
|
||||
import {Link} from "react-router-dom";
|
||||
import {Button, Switch, Table} from "antd";
|
||||
import moment from "moment";
|
||||
import * as Setting from "./Setting";
|
||||
import * as EnforcerBackend from "./backend/EnforcerBackend";
|
||||
import i18next from "i18next";
|
||||
import BaseListPage from "./BaseListPage";
|
||||
import PopconfirmModal from "./common/modal/PopconfirmModal";
|
||||
|
||||
class EnforcerListPage extends BaseListPage {
|
||||
newEnforcer() {
|
||||
const randomName = Setting.getRandomName();
|
||||
const owner = Setting.getRequestOrganization(this.props.account);
|
||||
return {
|
||||
owner: owner,
|
||||
name: `enforcer_${randomName}`,
|
||||
createdTime: moment().format(),
|
||||
displayName: `New Enforcer - ${randomName}`,
|
||||
isEnabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
addEnforcer() {
|
||||
const newEnforcer = this.newEnforcer();
|
||||
EnforcerBackend.addEnforcer(newEnforcer)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
this.props.history.push({pathname: `/enforcers/${newEnforcer.owner}/${newEnforcer.name}`, mode: "add"});
|
||||
Setting.showMessage("success", i18next.t("general:Successfully added"));
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to add")}: ${res.msg}`);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
deleteEnforcer(i) {
|
||||
EnforcerBackend.deleteEnforcer(this.state.data[i])
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
|
||||
this.setState({
|
||||
data: Setting.deleteRow(this.state.data, i),
|
||||
pagination: {total: this.state.pagination.total - 1},
|
||||
});
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
renderTable(enforcers) {
|
||||
const columns = [
|
||||
{
|
||||
title: i18next.t("general:Name"),
|
||||
dataIndex: "name",
|
||||
key: "name",
|
||||
width: "150px",
|
||||
fixed: "left",
|
||||
sorter: true,
|
||||
...this.getColumnSearchProps("name"),
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<Link to={`/enforcers/${record.owner}/${text}`}>
|
||||
{text}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: i18next.t("general:Organization"),
|
||||
dataIndex: "owner",
|
||||
key: "owner",
|
||||
width: "120px",
|
||||
sorter: true,
|
||||
...this.getColumnSearchProps("owner"),
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<Link to={`/organizations/${text}`}>
|
||||
{text}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: i18next.t("general:Created time"),
|
||||
dataIndex: "createdTime",
|
||||
key: "createdTime",
|
||||
width: "160px",
|
||||
sorter: true,
|
||||
render: (text, record, index) => {
|
||||
return Setting.getFormattedDate(text);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: i18next.t("general:Display name"),
|
||||
dataIndex: "displayName",
|
||||
key: "displayName",
|
||||
width: "200px",
|
||||
sorter: true,
|
||||
...this.getColumnSearchProps("displayName"),
|
||||
},
|
||||
{
|
||||
title: i18next.t("general:Is enabled"),
|
||||
dataIndex: "isEnabled",
|
||||
key: "isEnabled",
|
||||
width: "120px",
|
||||
sorter: true,
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: i18next.t("general:Action"),
|
||||
dataIndex: "",
|
||||
key: "op",
|
||||
width: "170px",
|
||||
fixed: (Setting.isMobile()) ? "false" : "right",
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<div>
|
||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary"
|
||||
onClick={() => this.props.history.push(`/enforcers/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
|
||||
<PopconfirmModal
|
||||
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
||||
onConfirm={() => this.deleteEnforcer(index)}
|
||||
>
|
||||
</PopconfirmModal>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const paginationProps = {
|
||||
total: this.state.pagination.total,
|
||||
showQuickJumper: true,
|
||||
showSizeChanger: true,
|
||||
showTotal: () => i18next.t("general:{total} in total").replace("{total}", this.state.pagination.total),
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Table scroll={{x: "max-content"}} columns={columns} dataSource={enforcers} rowKey={(record) => `${record.owner}/${record.name}`} size="middle" bordered
|
||||
pagination={paginationProps}
|
||||
title={() => (
|
||||
<div>
|
||||
{i18next.t("general:Enforcers")}
|
||||
<Button type="primary" size="small"
|
||||
onClick={this.addEnforcer.bind(this)}>{i18next.t("general:Add")}</Button>
|
||||
</div>
|
||||
)}
|
||||
loading={this.state.loading}
|
||||
onChange={this.handleTableChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
fetch = (params = {}) => {
|
||||
let field = params.searchedColumn, value = params.searchText;
|
||||
const sortField = params.sortField, sortOrder = params.sortOrder;
|
||||
if (params.type !== undefined && params.type !== null) {
|
||||
field = "type";
|
||||
value = params.type;
|
||||
}
|
||||
this.setState({loading: true});
|
||||
EnforcerBackend.getEnforcers(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
});
|
||||
if (res.status === "ok") {
|
||||
this.setState({
|
||||
data: res.data,
|
||||
pagination: {
|
||||
...params.pagination,
|
||||
total: res.data2,
|
||||
},
|
||||
searchText: params.searchText,
|
||||
searchedColumn: params.searchedColumn,
|
||||
});
|
||||
} else {
|
||||
if (Setting.isResponseDenied(res)) {
|
||||
this.setState({
|
||||
isAuthorized: false,
|
||||
});
|
||||
} else {
|
||||
Setting.showMessage("error", res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default EnforcerListPage;
|
@@ -58,7 +58,7 @@ class MessageEditPage extends React.Component {
|
||||
this.setState({
|
||||
message: res.data,
|
||||
});
|
||||
this.getUsers(res.organization);
|
||||
this.getUsers(res.data.organization);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class MessageEditPage extends React.Component {
|
||||
ChatBackend.getChats("admin")
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
chats: (res.msg === undefined) ? res : [],
|
||||
chats: res.data || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -41,12 +41,12 @@ class PaymentResultPage extends React.Component {
|
||||
|
||||
getPayment() {
|
||||
PaymentBackend.getPayment("admin", this.state.paymentName)
|
||||
.then((payment) => {
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
payment: payment,
|
||||
payment: res.data,
|
||||
});
|
||||
|
||||
if (payment.state === "Created") {
|
||||
if (res.data.state === "Created") {
|
||||
this.setState({timeout: setTimeout(() => this.getPayment(), 1000)});
|
||||
}
|
||||
});
|
||||
|
@@ -30,7 +30,7 @@ class PermissionEditPage extends React.Component {
|
||||
this.state = {
|
||||
classes: props,
|
||||
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
||||
permissionName: props.match.params.permissionName,
|
||||
permissionName: decodeURIComponent(props.match.params.permissionName),
|
||||
permission: null,
|
||||
organizations: [],
|
||||
model: null,
|
||||
@@ -449,7 +449,7 @@ class PermissionEditPage extends React.Component {
|
||||
if (willExist) {
|
||||
this.props.history.push("/permissions");
|
||||
} else {
|
||||
this.props.history.push(`/permissions/${this.state.permission.owner}/${this.state.permission.name}`);
|
||||
this.props.history.push(`/permissions/${this.state.permission.owner}/${encodeURIComponent(this.state.permission.name)}`);
|
||||
}
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
||||
|
@@ -128,7 +128,7 @@ class PermissionListPage extends BaseListPage {
|
||||
...this.getColumnSearchProps("name"),
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<Link to={`/permissions/${record.owner}/${text}`}>
|
||||
<Link to={`/permissions/${record.owner}/${encodeURIComponent(text)}`}>
|
||||
{text}
|
||||
</Link>
|
||||
);
|
||||
@@ -336,7 +336,7 @@ class PermissionListPage extends BaseListPage {
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<div>
|
||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/permissions/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
|
||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/permissions/${record.owner}/${encodeURIComponent(record.name)}`)}>{i18next.t("general:Edit")}</Button>
|
||||
<PopconfirmModal
|
||||
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
||||
onConfirm={() => this.deletePermission(index)}
|
||||
|
@@ -46,18 +46,18 @@ class PlanEditPage extends React.Component {
|
||||
|
||||
getPlan() {
|
||||
PlanBackend.getPlan(this.state.organizationName, this.state.planName)
|
||||
.then((plan) => {
|
||||
if (plan === null) {
|
||||
.then((res) => {
|
||||
if (res.data === null) {
|
||||
this.props.history.push("/404");
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
plan: plan,
|
||||
plan: res.data,
|
||||
});
|
||||
|
||||
this.getUsers(plan.owner);
|
||||
this.getRoles(plan.owner);
|
||||
this.getUsers(this.state.organizationName);
|
||||
this.getRoles(this.state.organizationName);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -148,7 +148,7 @@ class PlanListPage extends BaseListPage {
|
||||
...this.getColumnSearchProps("role"),
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<Link to={`/roles/${text}`}>
|
||||
<Link to={`/roles/${encodeURIComponent(text)}`}>
|
||||
{text}
|
||||
</Link>
|
||||
);
|
||||
|
@@ -62,7 +62,7 @@ class PricingEditPage extends React.Component {
|
||||
this.setState({
|
||||
pricing: res.data,
|
||||
});
|
||||
this.getPlans(res.owner);
|
||||
this.getPlans(this.state.organizationName);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -46,14 +46,14 @@ class ProductEditPage extends React.Component {
|
||||
|
||||
getProduct() {
|
||||
ProductBackend.getProduct(this.state.organizationName, this.state.productName)
|
||||
.then((product) => {
|
||||
if (product === null) {
|
||||
.then((res) => {
|
||||
if (res.data === null) {
|
||||
this.props.history.push("/404");
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
product: product,
|
||||
product: res.data,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ class RoleEditPage extends React.Component {
|
||||
this.state = {
|
||||
classes: props,
|
||||
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
||||
roleName: props.match.params.roleName,
|
||||
roleName: decodeURIComponent(props.match.params.roleName),
|
||||
role: null,
|
||||
organizations: [],
|
||||
users: [],
|
||||
@@ -56,8 +56,8 @@ class RoleEditPage extends React.Component {
|
||||
role: res.data,
|
||||
});
|
||||
|
||||
this.getUsers(res.owner);
|
||||
this.getRoles(res.owner);
|
||||
this.getUsers(this.state.organizationName);
|
||||
this.getRoles(this.state.organizationName);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ class RoleEditPage extends React.Component {
|
||||
if (willExist) {
|
||||
this.props.history.push("/roles");
|
||||
} else {
|
||||
this.props.history.push(`/roles/${this.state.role.owner}/${this.state.role.name}`);
|
||||
this.props.history.push(`/roles/${this.state.role.owner}/${encodeURIComponent(this.state.role.name)}`);
|
||||
}
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
||||
|
@@ -121,7 +121,7 @@ class RoleListPage extends BaseListPage {
|
||||
...this.getColumnSearchProps("name"),
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<Link to={`/roles/${record.owner}/${record.name}`}>
|
||||
<Link to={`/roles/${record.owner}/${encodeURIComponent(record.name)}`}>
|
||||
{text}
|
||||
</Link>
|
||||
);
|
||||
@@ -213,7 +213,7 @@ class RoleListPage extends BaseListPage {
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<div>
|
||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/roles/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
|
||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/roles/${record.owner}/${encodeURIComponent(record.name)}`)}>{i18next.t("general:Edit")}</Button>
|
||||
<PopconfirmModal
|
||||
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
||||
onConfirm={() => this.deleteRole(index)}
|
||||
|
@@ -61,8 +61,8 @@ class SubscriptionEditPage extends React.Component {
|
||||
subscription: res.data,
|
||||
});
|
||||
|
||||
this.getUsers(res.owner);
|
||||
this.getPlanes(res.owner);
|
||||
this.getUsers(this.state.organizationName);
|
||||
this.getPlanes(this.state.organizationName);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,9 @@
|
||||
|
||||
import {createButton} from "react-social-login-buttons";
|
||||
import {StaticBaseUrl} from "../Setting";
|
||||
import {useGoogleOneTapLogin} from "react-google-one-tap-login";
|
||||
import * as Setting from "../Setting";
|
||||
import * as Provider from "./Provider";
|
||||
|
||||
function Icon({width = 24, height = 24, color}) {
|
||||
return <img src={`${StaticBaseUrl}/buttons/google.svg`} alt="Sign in with Google" />;
|
||||
@@ -29,4 +32,29 @@ const config = {
|
||||
|
||||
const GoogleLoginButton = createButton(config);
|
||||
|
||||
export function GoogleOneTapLoginVirtualButton(prop) {
|
||||
const application = prop.application;
|
||||
const providerConf = prop.providerConf;
|
||||
// https://stackoverflow.com/questions/62281579/google-one-tap-sign-in-ui-not-displayed-after-clicking-the-close-button
|
||||
// document.cookie = "g_state=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT";
|
||||
useGoogleOneTapLogin({
|
||||
googleAccountConfigs: {
|
||||
client_id: providerConf.provider.clientId,
|
||||
},
|
||||
onError: (error) => {
|
||||
Setting.showMessage("error", error);
|
||||
},
|
||||
onSuccess: (response) => {
|
||||
const code = "GoogleIdToken-" + JSON.stringify(response);
|
||||
const authUrlParams = new URLSearchParams(Provider.getAuthUrl(application, providerConf.provider, "signup"));
|
||||
const state = authUrlParams.get("state");
|
||||
let redirectUri = authUrlParams.get("redirect_uri");
|
||||
redirectUri = `${redirectUri}?state=${state}&code=${encodeURIComponent(code)}`;
|
||||
Setting.goToLink(redirectUri);
|
||||
},
|
||||
disableCancelOnUnmount: true,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export default GoogleLoginButton;
|
||||
|
@@ -36,7 +36,7 @@ import {CaptchaModal} from "../common/modal/CaptchaModal";
|
||||
import {CaptchaRule} from "../common/modal/CaptchaModal";
|
||||
import RedirectForm from "../common/RedirectForm";
|
||||
import {MfaAuthVerifyForm, NextMfa, RequiredMfa} from "./mfa/MfaAuthVerifyForm";
|
||||
|
||||
import {GoogleOneTapLoginVirtualButton} from "./GoogleLoginButton";
|
||||
class LoginPage extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -423,6 +423,16 @@ class LoginPage extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
renderOtherFormProvider(application) {
|
||||
for (const providerConf of application.providers) {
|
||||
if (providerConf.provider?.type === "Google" && providerConf.rule === "OneTap" && this.props.preview !== "auto") {
|
||||
return (
|
||||
<GoogleOneTapLoginVirtualButton application={application} providerConf={providerConf} />
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderForm(application) {
|
||||
if (this.state.msg !== null) {
|
||||
return Util.renderMessage(this.state.msg);
|
||||
@@ -580,6 +590,9 @@ class LoginPage extends React.Component {
|
||||
return ProviderButton.renderProviderLogo(providerItem.provider, application, 30, 5, "small", this.props.location);
|
||||
})
|
||||
}
|
||||
{
|
||||
this.renderOtherFormProvider(application)
|
||||
}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
@@ -601,6 +614,9 @@ class LoginPage extends React.Component {
|
||||
return ProviderButton.renderProviderLogo(providerItem.provider, application, 40, 10, "big", this.props.location);
|
||||
})
|
||||
}
|
||||
{
|
||||
this.renderOtherFormProvider(application)
|
||||
}
|
||||
<div>
|
||||
<br />
|
||||
{
|
||||
|
71
web/src/backend/EnforcerBackend.js
Normal file
71
web/src/backend/EnforcerBackend.js
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2023 The Casdoor 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.
|
||||
|
||||
import * as Setting from "../Setting";
|
||||
|
||||
export function getEnforcers(owner, page = "", pageSize = "", field = "", value = "", sortField = "", sortOrder = "") {
|
||||
return fetch(`${Setting.ServerUrl}/api/get-enforcers?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Accept-Language": Setting.getAcceptLanguage(),
|
||||
},
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function getEnforcer(owner, name) {
|
||||
return fetch(`${Setting.ServerUrl}/api/get-enforcer?id=${owner}/${encodeURIComponent(name)}`, {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Accept-Language": Setting.getAcceptLanguage(),
|
||||
},
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function updateEnforcer(owner, name, enforcer) {
|
||||
const newEnforcer = Setting.deepCopy(enforcer);
|
||||
return fetch(`${Setting.ServerUrl}/api/update-enforcer?id=${owner}/${encodeURIComponent(name)}`, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
body: JSON.stringify(newEnforcer),
|
||||
headers: {
|
||||
"Accept-Language": Setting.getAcceptLanguage(),
|
||||
},
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function addEnforcer(enforcer) {
|
||||
const newEnforcer = Setting.deepCopy(enforcer);
|
||||
return fetch(`${Setting.ServerUrl}/api/add-enforcer`, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
body: JSON.stringify(newEnforcer),
|
||||
headers: {
|
||||
"Accept-Language": Setting.getAcceptLanguage(),
|
||||
},
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function deleteEnforcer(enforcer) {
|
||||
const newEnforcer = Setting.deepCopy(enforcer);
|
||||
return fetch(`${Setting.ServerUrl}/api/delete-enforcer`, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
body: JSON.stringify(newEnforcer),
|
||||
headers: {
|
||||
"Accept-Language": Setting.getAcceptLanguage(),
|
||||
},
|
||||
}).then(res => res.json());
|
||||
}
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Erstellte Zeit",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Standard Anwendung",
|
||||
"Default application - Tooltip": "Standard-Anwendung für Benutzer, die direkt von der Organisationsseite registriert wurden",
|
||||
"Default avatar": "Standard-Avatar",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Vom Server verwendet, um die API des Verifizierungscodes-Providers für die Verifizierung aufzurufen",
|
||||
"Send Testing Email": "Senden Sie eine Test-E-Mail",
|
||||
"Send Testing SMS": "Sende Test-SMS",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Signatur Namen",
|
||||
"Sign Name - Tooltip": "Name der Signatur, die verwendet werden soll",
|
||||
"Sign request": "Signaturanfrage",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Created time",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Default application",
|
||||
"Default application - Tooltip": "Default application for users registered directly from the organization page",
|
||||
"Default avatar": "Default avatar",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Used by the server to call the verification code provider API for verification",
|
||||
"Send Testing Email": "Send Testing Email",
|
||||
"Send Testing SMS": "Send Testing SMS",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Sign Name",
|
||||
"Sign Name - Tooltip": "Name of the signature to be used",
|
||||
"Sign request": "Sign request",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Tiempo creado",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Aplicación predeterminada",
|
||||
"Default application - Tooltip": "Aplicación predeterminada para usuarios registrados directamente desde la página de la organización",
|
||||
"Default avatar": "Avatar predeterminado",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Utilizado por el servidor para llamar a la API del proveedor de códigos de verificación para verificar",
|
||||
"Send Testing Email": "Enviar correo electrónico de prueba",
|
||||
"Send Testing SMS": "Enviar SMS de prueba",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Firma de Nombre",
|
||||
"Sign Name - Tooltip": "Nombre de la firma a ser utilizada",
|
||||
"Sign request": "Solicitud de firma",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Temps créé",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Application par défaut",
|
||||
"Default application - Tooltip": "Application par défaut pour les utilisateurs enregistrés directement depuis la page de l'organisation",
|
||||
"Default avatar": "Avatar par défaut",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Utilisé par le serveur pour appeler l'API du fournisseur de code de vérification pour vérifier",
|
||||
"Send Testing Email": "Envoyer un e-mail de test",
|
||||
"Send Testing SMS": "Envoyer des messages SMS de tests",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Nom de signature",
|
||||
"Sign Name - Tooltip": "Nom de la signature à utiliser",
|
||||
"Sign request": "Demande de signature",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Waktu dibuat",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Aplikasi default",
|
||||
"Default application - Tooltip": "Aplikasi default untuk pengguna yang terdaftar langsung dari halaman organisasi",
|
||||
"Default avatar": "Avatar default",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Digunakan oleh server untuk memanggil API penyedia kode verifikasi untuk melakukan verifikasi",
|
||||
"Send Testing Email": "Kirim Email Uji Coba",
|
||||
"Send Testing SMS": "Kirim SMS Uji Coba",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Tanda Tangan",
|
||||
"Sign Name - Tooltip": "Nama tanda tangan yang akan digunakan",
|
||||
"Sign request": "Permintaan tanda tangan",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "作成された時間",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "デフォルトアプリケーション",
|
||||
"Default application - Tooltip": "組織ページから直接登録されたユーザーのデフォルトアプリケーション",
|
||||
"Default avatar": "デフォルトのアバター",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "認証のためにサーバーによって使用され、認証コードプロバイダAPIを呼び出すためのもの",
|
||||
"Send Testing Email": "テスト用メールを送信する",
|
||||
"Send Testing SMS": "テストSMSを送信してください",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "署名",
|
||||
"Sign Name - Tooltip": "使用する署名の名前",
|
||||
"Sign request": "サインリクエスト",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "작성한 시간",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "기본 애플리케이션",
|
||||
"Default application - Tooltip": "조직 페이지에서 직접 등록한 사용자의 기본 응용 프로그램",
|
||||
"Default avatar": "기본 아바타",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "검증을 위해 서버에서 인증 코드 공급자 API를 호출하는 데 사용됩니다",
|
||||
"Send Testing Email": "테스트 이메일을 보내기",
|
||||
"Send Testing SMS": "테스트 SMS를 보내세요",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "신명서",
|
||||
"Sign Name - Tooltip": "사용할 서명의 이름",
|
||||
"Sign request": "표지 요청",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Hora de Criação",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Aplicação padrão",
|
||||
"Default application - Tooltip": "Aplicação padrão para usuários registrados diretamente na página da organização",
|
||||
"Default avatar": "Avatar padrão",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Usada pelo servidor para chamar a API do fornecedor de código de verificação para verificação",
|
||||
"Send Testing Email": "Enviar E-mail de Teste",
|
||||
"Send Testing SMS": "Enviar SMS de Teste",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Nome do Sinal",
|
||||
"Sign Name - Tooltip": "Nome da assinatura a ser usada",
|
||||
"Sign request": "Solicitação de assinatura",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Созданное время",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Приложение по умолчанию",
|
||||
"Default application - Tooltip": "По умолчанию приложение для пользователей, зарегистрированных непосредственно со страницы организации",
|
||||
"Default avatar": "Стандартный аватар",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Используется сервером для вызова API-интерфейса поставщика кода подтверждения для проверки",
|
||||
"Send Testing Email": "Отправить тестовое письмо",
|
||||
"Send Testing SMS": "Отправить тестовое SMS-сообщение",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Подпись имени",
|
||||
"Sign Name - Tooltip": "Имя подписи, которую нужно использовать",
|
||||
"Sign request": "Подписать запрос",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Created time": "Thời gian tạo",
|
||||
"Custom": "Custom",
|
||||
"Default": "Default",
|
||||
"Default application": "Ứng dụng mặc định",
|
||||
"Default application - Tooltip": "Ứng dụng mặc định cho người dùng đăng ký trực tiếp từ trang tổ chức",
|
||||
"Default avatar": "Hình đại diện mặc định",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "Được sử dụng bởi máy chủ để gọi API nhà cung cấp mã xác minh để xác minh",
|
||||
"Send Testing Email": "Gửi Email kiểm tra",
|
||||
"Send Testing SMS": "Gửi SMS kiểm tra",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "Ký tên",
|
||||
"Sign Name - Tooltip": "Tên chữ ký sẽ được sử dụng",
|
||||
"Sign request": "Yêu cầu ký tên",
|
||||
|
@@ -197,6 +197,7 @@
|
||||
"Confirm": "确认",
|
||||
"Created time": "创建时间",
|
||||
"Custom": "自定义",
|
||||
"Default": "默认",
|
||||
"Default application": "默认应用",
|
||||
"Default application - Tooltip": "直接从组织页面注册的用户默认所属的应用",
|
||||
"Default avatar": "默认头像",
|
||||
@@ -722,6 +723,8 @@
|
||||
"Secret key - Tooltip": "用于服务端调用验证码提供商API进行验证",
|
||||
"Send Testing Email": "发送测试邮件",
|
||||
"Send Testing SMS": "发送测试短信",
|
||||
"Sender number": "Sender number",
|
||||
"Sender number - Tooltip": "Sender number - Tooltip",
|
||||
"Sign Name": "签名名称",
|
||||
"Sign Name - Tooltip": "签名名称",
|
||||
"Sign request": "签名请求",
|
||||
|
@@ -178,21 +178,37 @@ class ProviderTable extends React.Component {
|
||||
key: "rule",
|
||||
width: "100px",
|
||||
render: (text, record, index) => {
|
||||
if (record.provider?.category !== "Captcha") {
|
||||
if (record.provider?.type === "Google") {
|
||||
if (text === "None") {
|
||||
text = "Default";
|
||||
}
|
||||
return (
|
||||
<Select virtual={false} style={{width: "100%"}}
|
||||
value={text}
|
||||
defaultValue="Default"
|
||||
onChange={value => {
|
||||
this.updateField(table, index, "rule", value);
|
||||
}} >
|
||||
<Option key="Default" value="Default">{i18next.t("general:Default")}</Option>
|
||||
<Option key="OneTap" value="OneTap">{"One Tap"}</Option>
|
||||
</Select>
|
||||
);
|
||||
} else if (record.provider?.category === "Captcha") {
|
||||
return (
|
||||
<Select virtual={false} style={{width: "100%"}}
|
||||
value={text}
|
||||
defaultValue="None"
|
||||
onChange={value => {
|
||||
this.updateField(table, index, "rule", value);
|
||||
}} >
|
||||
<Option key="None" value="None">{i18next.t("general:None")}</Option>
|
||||
<Option key="Dynamic" value="Dynamic">{i18next.t("application:Dynamic")}</Option>
|
||||
<Option key="Always" value="Always">{i18next.t("application:Always")}</Option>
|
||||
</Select>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Select virtual={false} style={{width: "100%"}}
|
||||
value={text}
|
||||
defaultValue="None"
|
||||
onChange={value => {
|
||||
this.updateField(table, index, "rule", value);
|
||||
}} >
|
||||
<Option key="None" value="None">{i18next.t("general:None")}</Option>
|
||||
<Option key="Dynamic" value="Dynamic">{i18next.t("application:Dynamic")}</Option>
|
||||
<Option key="Always" value="Always">{i18next.t("application:Always")}</Option>
|
||||
</Select>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@@ -10199,6 +10199,11 @@ react-github-corner@^2.5.0:
|
||||
resolved "https://registry.yarnpkg.com/react-github-corner/-/react-github-corner-2.5.0.tgz#e350d0c69f69c075bc0f1d2a6f1df6ee91da31f2"
|
||||
integrity sha512-ofds9l6n61LJc6ML+jSE6W9ZSQvATcMR9evnHPXua1oDYj289HKODnVqFUB/g2a4ieBjDHw416iHP3MjqnU76Q==
|
||||
|
||||
react-google-one-tap-login@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/react-google-one-tap-login/-/react-google-one-tap-login-0.1.1.tgz#12a61e63e19251622cf1575b601d79fd4d07847a"
|
||||
integrity sha512-RCbOfR3Z7VcRae4AzrLoBfY/aqqdN24pkQeNz9CJ0W65C9SY3vAwF0Yp8mwpeFwsugaZ5b1HZsfhUYWtb3IMrw==
|
||||
|
||||
react-helmet@^6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726"
|
||||
|
Reference in New Issue
Block a user