File tree 4 files changed +65
-2
lines changed
4 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,18 @@ func (a *Server) WithAdditionalSchemesToBuild(s ...*runtime.Scheme) *Server {
40
40
return a
41
41
}
42
42
43
- // ExposeLoopbackClientConfig exposes loopback client config as an external variable .
43
+ // ExposeLoopbackClientConfig exposes loopback client config as an external singleton .
44
44
func (a * Server ) ExposeLoopbackClientConfig () * Server {
45
45
return a .WithServerFns (func (c * GenericAPIServer ) * GenericAPIServer {
46
46
loopback .SetLoopbackClientConfig (c .LoopbackClientConfig )
47
47
return c
48
48
})
49
49
}
50
+
51
+ // ExposeLoopbackAuthorizer exposes loopback authorizer as an external singleton.
52
+ func (a * Server ) ExposeLoopbackAuthorizer () * Server {
53
+ return a .WithServerFns (func (s * GenericAPIServer ) * GenericAPIServer {
54
+ loopback .SetAuthorizer (s .Authorizer )
55
+ return s
56
+ })
57
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright 2020 The Kubernetes Authors.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ package loopback
18
+
19
+ import (
20
+ "sync"
21
+
22
+ "k8s.io/apiserver/pkg/authorization/authorizer"
23
+ )
24
+
25
+ var authzOnce sync.Once
26
+ var authz authorizer.Authorizer
27
+
28
+ // SetAuthorizer provides loopback authorizer for one time
29
+ func SetAuthorizer (c authorizer.Authorizer ) {
30
+ authzOnce .Do (func () {
31
+ authz = c
32
+ })
33
+ }
34
+
35
+ // GetAuthorizer gets loopback authorizer performing delegated authorization.
36
+ func GetAuthorizer () authorizer.Authorizer {
37
+ return authz
38
+ }
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- // Package loopback is a set of utilities for apiserver loopback connections.
18
17
package loopback
19
18
20
19
import (
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright 2020 The Kubernetes Authors.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ // Package loopback is a set of utilities for apiserver loopback connections.
18
+ package loopback
You can’t perform that action at this time.
0 commit comments