mirror of
https://github.com/openziti/ziti.git
synced 2026-10-22 19:56:07 +00:00
Revert "GH-18 run go fmt, fix line endings"
This reverts commit e83664035c.
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type AlwaysAllow struct{}
|
||||
|
||||
var always = &AlwaysAllow{}
|
||||
|
||||
func (a *AlwaysAllow) IsAllowed(_ ...string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func Always() *AlwaysAllow {
|
||||
return always
|
||||
}
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type AlwaysAllow struct{}
|
||||
|
||||
var always = &AlwaysAllow{}
|
||||
|
||||
func (a *AlwaysAllow) IsAllowed(_ ...string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func Always() *AlwaysAllow {
|
||||
return always
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireAdmin struct{}
|
||||
|
||||
var requireAdmin = &RequireAdmin{}
|
||||
|
||||
func IsAdmin() *RequireAdmin {
|
||||
return requireAdmin
|
||||
}
|
||||
|
||||
func (ia *RequireAdmin) IsAllowed(identityPerms ...string) bool {
|
||||
for _, p := range identityPerms {
|
||||
if p == AdminPermission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireAdmin struct{}
|
||||
|
||||
var requireAdmin = &RequireAdmin{}
|
||||
|
||||
func IsAdmin() *RequireAdmin {
|
||||
return requireAdmin
|
||||
}
|
||||
|
||||
func (ia *RequireAdmin) IsAllowed(identityPerms ...string) bool {
|
||||
for _, p := range identityPerms {
|
||||
if p == AdminPermission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireAuthenticated struct{}
|
||||
|
||||
var isAuthenticated = &RequireAuthenticated{}
|
||||
|
||||
func IsAuthenticated() *RequireAuthenticated {
|
||||
return isAuthenticated
|
||||
}
|
||||
|
||||
func (ir *RequireAuthenticated) IsAllowed(identityPerms ...string) bool {
|
||||
for _, p := range identityPerms {
|
||||
if p == AuthenticatedPermission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireAuthenticated struct{}
|
||||
|
||||
var isAuthenticated = &RequireAuthenticated{}
|
||||
|
||||
func IsAuthenticated() *RequireAuthenticated {
|
||||
return isAuthenticated
|
||||
}
|
||||
|
||||
func (ir *RequireAuthenticated) IsAllowed(identityPerms ...string) bool {
|
||||
for _, p := range identityPerms {
|
||||
if p == AuthenticatedPermission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
const (
|
||||
AdminPermission = "ADMIN"
|
||||
AuthenticatedPermission = "AUTHENTICATED"
|
||||
)
|
||||
|
||||
type Resolver interface {
|
||||
IsAllowed(...string) bool
|
||||
}
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
const (
|
||||
AdminPermission = "ADMIN"
|
||||
AuthenticatedPermission = "AUTHENTICATED"
|
||||
)
|
||||
|
||||
type Resolver interface {
|
||||
IsAllowed(...string) bool
|
||||
}
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireAll struct {
|
||||
required []string
|
||||
}
|
||||
|
||||
func NewRequireAll(perms ...string) *RequireAll {
|
||||
ra := &RequireAll{
|
||||
required: perms,
|
||||
}
|
||||
return ra
|
||||
}
|
||||
|
||||
func (ra *RequireAll) IsAllowed(identityPerms ...string) bool {
|
||||
ps := map[string]bool{}
|
||||
|
||||
if len(identityPerms) < len(ra.required) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, p := range identityPerms {
|
||||
ps[p] = true
|
||||
|
||||
//short cut admins
|
||||
if p == AdminPermission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for _, r := range ra.required {
|
||||
if _, ok := ps[r]; !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireAll struct {
|
||||
required []string
|
||||
}
|
||||
|
||||
func NewRequireAll(perms ...string) *RequireAll {
|
||||
ra := &RequireAll{
|
||||
required: perms,
|
||||
}
|
||||
return ra
|
||||
}
|
||||
|
||||
func (ra *RequireAll) IsAllowed(identityPerms ...string) bool {
|
||||
ps := map[string]bool{}
|
||||
|
||||
if len(identityPerms) < len(ra.required) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, p := range identityPerms {
|
||||
ps[p] = true
|
||||
|
||||
//short cut admins
|
||||
if p == AdminPermission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for _, r := range ra.required {
|
||||
if _, ok := ps[r]; !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireOne struct {
|
||||
required map[string]bool
|
||||
}
|
||||
|
||||
func NewRequireOne(perms ...string) *RequireOne {
|
||||
ro := &RequireOne{}
|
||||
ro.required = map[string]bool{}
|
||||
|
||||
for _, p := range perms {
|
||||
ro.required[p] = true
|
||||
}
|
||||
|
||||
return ro
|
||||
}
|
||||
|
||||
func (ro *RequireOne) IsAllowed(identityPerms ...string) bool {
|
||||
for _, p := range identityPerms {
|
||||
|
||||
//short cut admins
|
||||
if p == AdminPermission {
|
||||
return true
|
||||
}
|
||||
|
||||
if _, ok := ro.required[p]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
/*
|
||||
Copyright 2019 Netfoundry, Inc.
|
||||
|
||||
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
|
||||
|
||||
https://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 permissions
|
||||
|
||||
type RequireOne struct {
|
||||
required map[string]bool
|
||||
}
|
||||
|
||||
func NewRequireOne(perms ...string) *RequireOne {
|
||||
ro := &RequireOne{}
|
||||
ro.required = map[string]bool{}
|
||||
|
||||
for _, p := range perms {
|
||||
ro.required[p] = true
|
||||
}
|
||||
|
||||
return ro
|
||||
}
|
||||
|
||||
func (ro *RequireOne) IsAllowed(identityPerms ...string) bool {
|
||||
for _, p := range identityPerms {
|
||||
|
||||
//short cut admins
|
||||
if p == AdminPermission {
|
||||
return true
|
||||
}
|
||||
|
||||
if _, ok := ro.required[p]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (ir *RootRouter) List(ae *env.AppEnv, rc *response.RequestContext) {
|
||||
"fabrics": newCrudLinks("./fabrics", "<fabricId>"),
|
||||
"fabric-types": newReadOnlyLinks("./fabric-types", "<fabricTypeId>"),
|
||||
"event-logs": newReadOnlyLinks("./event-logs", "<eventLogId>"),
|
||||
"edge-routers": newCrudLinks("./edge-routers", "<edgeRouterId>"),
|
||||
"edge-routers": newCrudLinks("./edge-routers", "<edgeRouterId>"),
|
||||
"geo-regions": newReadOnlyLinks("./geo-regions", "<geoRegionId>"),
|
||||
"identities": newCrudLinks("./identities", "<identityId>"),
|
||||
"identity-types": newReadOnlyLinks("./identity-types", "<identityTypeId>"),
|
||||
|
||||
@@ -64,7 +64,7 @@ func (ir *VersionRouter) List(ae *env.AppEnv, rc *response.RequestContext) {
|
||||
pfxlog.Logger().WithField("cause", err).Panic("could not set value by path")
|
||||
}
|
||||
|
||||
if _, err := data.SetP(runtime.Version(), "runtimeVersion"); err != nil {
|
||||
if _, err := data.SetP(runtime.Version(),"runtimeVersion"); err != nil {
|
||||
pfxlog.Logger().WithField("cause", err).Panic("could not set value by path")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user