-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "billing_information" RBAC resource (#5676)
* Expose GRPC client connection to plugins * Replaces global plugin state with the PluginRegistry
- Loading branch information
1 parent
4f10255
commit 472df28
Showing
18 changed files
with
222 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule e
updated
from f8bf84 to 0e18de
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Copyright 2015-2021 Gravitational, 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 | ||
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 plugin | ||
|
||
import "github.com/gravitational/trace" | ||
|
||
// Plugin describes interfaces of the teleport core plugin | ||
type Plugin interface { | ||
// GetName returns plugin name | ||
GetName() string | ||
// RegisterProxyWebHandlers registers new methods with the ProxyWebHandler | ||
RegisterProxyWebHandlers(handler interface{}) error | ||
// RegisterAuthWebHandlers registers new methods with the Auth Web Handler | ||
RegisterAuthWebHandlers(service interface{}) error | ||
// RegisterAuthServices registers new services on the AuthServer | ||
RegisterAuthServices(server interface{}) error | ||
} | ||
|
||
// Registry is the plugin registry | ||
type Registry interface { | ||
// Add adds plugin to the registry | ||
Add(plugin Plugin) error | ||
// RegisterProxyWebHandlers registers Teleport Proxy web handlers | ||
RegisterProxyWebHandlers(hander interface{}) error | ||
// RegisterAuthWebHandlers registers Teleport Auth web handlers | ||
RegisterAuthWebHandlers(handler interface{}) error | ||
// RegisterAuthServices registerse Teleport AuthServer services | ||
RegisterAuthServices(server interface{}) error | ||
} | ||
|
||
// NewRegistry creates an instance of the Registry | ||
func NewRegistry() Registry { | ||
return ®istry{ | ||
plugins: make(map[string]Plugin), | ||
} | ||
} | ||
|
||
type registry struct { | ||
plugins map[string]Plugin | ||
} | ||
|
||
// Add adds plugin to the plugin registry | ||
func (r *registry) Add(p Plugin) error { | ||
if p == nil { | ||
return trace.BadParameter("missing plugin") | ||
} | ||
|
||
name := p.GetName() | ||
if name == "" { | ||
return trace.BadParameter("missing plugin name") | ||
} | ||
|
||
_, exists := r.plugins[name] | ||
if exists { | ||
return trace.AlreadyExists("plugin %v already exists", name) | ||
} | ||
|
||
r.plugins[name] = p | ||
|
||
return nil | ||
} | ||
|
||
// RegisterProxyWebHandlers registers Teleport Proxy web handlers | ||
func (r *registry) RegisterProxyWebHandlers(hander interface{}) error { | ||
for _, p := range r.plugins { | ||
if err := p.RegisterProxyWebHandlers(hander); err != nil { | ||
return trace.Wrap(err, "plugin %v failed to register", p.GetName()) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// RegisterAuthWebHandlers registers Teleport Auth web handlers | ||
func (r *registry) RegisterAuthWebHandlers(handler interface{}) error { | ||
for _, p := range r.plugins { | ||
if err := p.RegisterAuthWebHandlers(handler); err != nil { | ||
return trace.Wrap(err, "plugin %v failed to register", p.GetName()) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// RegisterAuthServices registerse Teleport AuthServer services | ||
func (r *registry) RegisterAuthServices(server interface{}) error { | ||
for _, p := range r.plugins { | ||
if err := p.RegisterAuthServices(server); err != nil { | ||
return trace.Wrap(err, "plugin %v failed to register", p.GetName()) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.