mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-20 03:34:00 +00:00
chore: move api to route package
This commit is contained in:
35
server/route/api/v1/acl_config.go
Normal file
35
server/route/api/v1/acl_config.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package v1
|
||||
|
||||
import "strings"
|
||||
|
||||
var allowedMethodsWhenUnauthorized = map[string]bool{
|
||||
"/slash.api.v1.WorkspaceService/GetWorkspaceProfile": true,
|
||||
"/slash.api.v1.WorkspaceService/GetWorkspaceSetting": true,
|
||||
"/slash.api.v1.AuthService/SignIn": true,
|
||||
"/slash.api.v1.AuthService/SignUp": true,
|
||||
"/slash.api.v1.AuthService/SignOut": true,
|
||||
"/memos.api.v1.AuthService/GetAuthStatus": true,
|
||||
"/slash.api.v1.ShortcutService/GetShortcutByName": true,
|
||||
"/slash.api.v1.ShortcutService/GetShortcut": true,
|
||||
"/slash.api.v1.CollectionService/GetCollectionByName": true,
|
||||
}
|
||||
|
||||
// isUnauthorizeAllowedMethod returns true if the method is allowed to be called when the user is not authorized.
|
||||
func isUnauthorizeAllowedMethod(methodName string) bool {
|
||||
if strings.HasPrefix(methodName, "/grpc.reflection") {
|
||||
return true
|
||||
}
|
||||
return allowedMethodsWhenUnauthorized[methodName]
|
||||
}
|
||||
|
||||
var allowedMethodsOnlyForAdmin = map[string]bool{
|
||||
"/slash.api.v1.UserService/CreateUser": true,
|
||||
"/slash.api.v1.UserService/DeleteUser": true,
|
||||
"/slash.api.v1.WorkspaceService/UpdateWorkspaceSetting": true,
|
||||
"/slash.api.v1.SubscriptionService/UpdateSubscription": true,
|
||||
}
|
||||
|
||||
// isOnlyForAdminAllowedMethod returns true if the method is allowed to be called only by admin.
|
||||
func isOnlyForAdminAllowedMethod(methodName string) bool {
|
||||
return allowedMethodsOnlyForAdmin[methodName]
|
||||
}
|
Reference in New Issue
Block a user