Skip to content

Commit eb583fe

Browse files
authored
Infra Role Handling and Admin Token Create, better Token documentation (#69)
1 parent c22c41c commit eb583fe

File tree

22 files changed

+466
-298
lines changed

22 files changed

+466
-298
lines changed

doc/index.html

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12474,7 +12474,11 @@ <h3 id="metalstack.api.v2.MethodPermission">MethodPermission</h3>
1247412474
<td><a href="#string">string</a></td>
1247512475
<td></td>
1247612476
<td><p>Subject maybe either the project or the tenant
12477-
for which the methods should be allowed </p></td>
12477+
for which the methods should be allowed
12478+
12479+
asterisk (*) can be specified to match any subject
12480+
empty string (&#34;&#34;) can be specified for requests that do not require a subject, e.g. partition list
12481+
otherwise either a projectid or a tenant login should be specified </p></td>
1247812482
</tr>
1247912483

1248012484
<tr>
@@ -12492,7 +12496,7 @@ <h3 id="metalstack.api.v2.MethodPermission">MethodPermission</h3>
1249212496

1249312497

1249412498
<h3 id="metalstack.api.v2.Token">Token</h3>
12495-
<p>Token is a jwt authentication token to access the api</p>
12499+
<p>Token generates a jwt authentication token to access the api</p><p>There are two different types of tokens, api- and user- tokens</p><p>A user token is used to authenticate end user requests for example from a cli.</p><p>The configured roles in a user token are expanded in the api server</p><p>based on the memberships in other projects and tenants based on the role granted there.</p><p>User tokens will never contain permissions.</p><p>Permissions are always derived from the tenant and project roles and memberships.</p><p>The api token should be used to authenticate services.</p><p>In contrast to a user token, the api token permissions and roles apply as configured during the token create process.</p>
1249612500

1249712501

1249812502
<table class="field-table">
@@ -12578,6 +12582,13 @@ <h3 id="metalstack.api.v2.Token">Token</h3>
1257812582
<td><p>AdminRole defines the admin role of the token owner </p></td>
1257912583
</tr>
1258012584

12585+
<tr>
12586+
<td>infra_role</td>
12587+
<td><a href="#metalstack.api.v2.InfraRole">InfraRole</a></td>
12588+
<td>optional</td>
12589+
<td><p>InfraRole defines the infrastructure role of the token owner </p></td>
12590+
</tr>
12591+
1258112592
</tbody>
1258212593
</table>
1258312594

@@ -12699,6 +12710,13 @@ <h3 id="metalstack.api.v2.TokenServiceCreateRequest">TokenServiceCreateRequest</
1269912710
<td><p>AdminRole defines the admin role of the token owner </p></td>
1270012711
</tr>
1270112712

12713+
<tr>
12714+
<td>infra_role</td>
12715+
<td><a href="#metalstack.api.v2.InfraRole">InfraRole</a></td>
12716+
<td>optional</td>
12717+
<td><p>InfraRole defines the infrastructure role of the token owner </p></td>
12718+
</tr>
12719+
1270212720
<tr>
1270312721
<td>labels</td>
1270412722
<td><a href="#metalstack.api.v2.Labels">Labels</a></td>
@@ -13014,6 +13032,13 @@ <h3 id="metalstack.api.v2.TokenServiceUpdateRequest">TokenServiceUpdateRequest</
1301413032
<td><p>AdminRole defines the admin role of the token owner </p></td>
1301513033
</tr>
1301613034

13035+
<tr>
13036+
<td>infra_role</td>
13037+
<td><a href="#metalstack.api.v2.InfraRole">InfraRole</a></td>
13038+
<td>optional</td>
13039+
<td><p>InfraRole defines the infrastructure role of the token owner </p></td>
13040+
</tr>
13041+
1301713042
<tr>
1301813043
<td>labels</td>
1301913044
<td><a href="#metalstack.api.v2.UpdateLabels">UpdateLabels</a></td>
@@ -13168,7 +13193,7 @@ <h3 id="metalstack.api.v2.TokenService">TokenService</h3>
1316813193
<td>Create</td>
1316913194
<td><a href="#metalstack.api.v2.TokenServiceCreateRequest">TokenServiceCreateRequest</a></td>
1317013195
<td><a href="#metalstack.api.v2.TokenServiceCreateResponse">TokenServiceCreateResponse</a></td>
13171-
<td><p>Create a token to authenticate against the platform, the secret will be only visible in the response</p></td>
13196+
<td><p>Create a token to authenticate against the platform, the secret will be only visible in the response.</p></td>
1317213197
</tr>
1317313198

1317413199
<tr>
@@ -13391,7 +13416,8 @@ <h3 id="metalstack.admin.v2.TokenService">TokenService</h3>
1339113416
<td>Create</td>
1339213417
<td><a href="#metalstack.admin.v2.TokenServiceCreateRequest">TokenServiceCreateRequest</a></td>
1339313418
<td><a href="#metalstack.admin.v2.TokenServiceCreateResponse">TokenServiceCreateResponse</a></td>
13394-
<td><p>Create a token to authenticate against the platform, the secret will be only visible in the response</p></td>
13419+
<td><p>Create a token to authenticate against the platform, the secret will be only visible in the response.
13420+
This service is suitable to create tokens for other users instead of deriving users from tokens directly.</p></td>
1339513421
</tr>
1339613422

1339713423
</tbody>

generate/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ generate: go-mocks
44
rm -f ../go/permissions/servicepermissions.go
55
rm -f ../go/client/client.go
66
rm -f ../go/tests/mock_clients.go
7-
rm -f ../js/permissions/servicepermissions.json
87

98
go run ./generate.go
109

generate/generate.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ func servicePermissions(root string) (*permissions.ServicePermissions, error) {
100100
Tenant: permissions.Tenant{},
101101
Project: permissions.Project{},
102102
}
103-
methods = permissions.Methods{}
103+
methods = permissions.Methods{
104+
// Allow service reflection to list available methods
105+
serverReflectionInfov1alpha1: true,
106+
serverReflectionInfo: true,
107+
}
104108
visibility = permissions.Visibility{
105109
Public: map[string]bool{
106110
// Allow service reflection to list available methods
@@ -177,10 +181,10 @@ func servicePermissions(root string) (*permissions.ServicePermissions, error) {
177181
// noop
178182
// Infra
179183
case v1.InfraRole_INFRA_ROLE_EDITOR.String():
180-
roles.Infra[v1.InfraRole_INFRA_ROLE_EDITOR.String()] = append(roles.Admin[v1.InfraRole_INFRA_ROLE_EDITOR.String()], methodName)
184+
roles.Infra[v1.InfraRole_INFRA_ROLE_EDITOR.String()] = append(roles.Infra[v1.InfraRole_INFRA_ROLE_EDITOR.String()], methodName)
181185
visibility.Infra[methodName] = true
182186
case v1.InfraRole_INFRA_ROLE_VIEWER.String():
183-
roles.Infra[v1.InfraRole_INFRA_ROLE_VIEWER.String()] = append(roles.Admin[v1.InfraRole_INFRA_ROLE_VIEWER.String()], methodName)
187+
roles.Infra[v1.InfraRole_INFRA_ROLE_VIEWER.String()] = append(roles.Infra[v1.InfraRole_INFRA_ROLE_VIEWER.String()], methodName)
184188
visibility.Infra[methodName] = true
185189
case v1.InfraRole_INFRA_ROLE_UNSPECIFIED.String():
186190
// noop

generate/go_servicepermissions.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated discover.go. DO NOT EDIT.
1+
// Code generated generate.go. DO NOT EDIT.
22
package permissions
33

44
import (

go.mod

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,26 @@ require (
1010
github.com/go-task/slim-sprig/v3 v3.0.0
1111
github.com/golang-jwt/jwt/v5 v5.3.0
1212
github.com/google/go-cmp v0.7.0
13-
github.com/klauspost/connect-compress/v2 v2.0.0
13+
github.com/klauspost/connect-compress/v2 v2.1.0
1414
github.com/stretchr/testify v1.11.1
1515
google.golang.org/protobuf v1.36.10
1616
)
1717

1818
require (
19-
cel.dev/expr v0.24.0 // indirect
19+
cel.dev/expr v0.25.1 // indirect
2020
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
2121
github.com/davecgh/go-spew v1.1.1 // indirect
2222
github.com/google/cel-go v0.26.1 // indirect
23-
github.com/klauspost/compress v1.18.0 // indirect
23+
github.com/klauspost/compress v1.18.1 // indirect
2424
github.com/kr/pretty v0.3.1 // indirect
25+
github.com/minio/minlz v1.0.1 // indirect
2526
github.com/pmezard/go-difflib v1.0.0 // indirect
2627
github.com/stoewer/go-strcase v1.3.1 // indirect
2728
github.com/stretchr/objx v0.5.3 // indirect
28-
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
29-
golang.org/x/text v0.30.0 // indirect
30-
google.golang.org/genproto/googleapis/api v0.0.0-20251007200510-49b9836ed3ff // indirect
31-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251007200510-49b9836ed3ff // indirect
29+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
30+
golang.org/x/text v0.31.0 // indirect
31+
google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba // indirect
32+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba // indirect
3233
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3334
gopkg.in/yaml.v3 v3.0.1 // indirect
3435
)

go.sum

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-202509121410
22
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4=
33
buf.build/go/protovalidate v1.0.0 h1:IAG1etULddAy93fiBsFVhpj7es5zL53AfB/79CVGtyY=
44
buf.build/go/protovalidate v1.0.0/go.mod h1:KQmEUrcQuC99hAw+juzOEAmILScQiKBP1Oc36vvCLW8=
5-
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
6-
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
5+
cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=
6+
cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
77
connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14=
88
connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w=
99
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
@@ -22,17 +22,19 @@ github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ=
2222
github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
2323
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2424
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
25-
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
26-
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
27-
github.com/klauspost/connect-compress/v2 v2.0.0 h1:L7TVsLa6Oo9Hkkb6r3DwSrhBbcWlXjneqBj7fCRXviU=
28-
github.com/klauspost/connect-compress/v2 v2.0.0/go.mod h1:604CD9JSAjGqtVzCM4SRgM/9TFTkWBcp+2wlQfGyJ6c=
25+
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
26+
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
27+
github.com/klauspost/connect-compress/v2 v2.1.0 h1:8fM8QrVeHT69e5VVSh4yjDaQASYIvOp2uMZq7nVLj2U=
28+
github.com/klauspost/connect-compress/v2 v2.1.0/go.mod h1:Ayurh2wscMMx3AwdGGVL+ylSR5316WfApREDgsqHyH8=
2929
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
3030
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
3131
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3232
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
3333
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
3434
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3535
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
36+
github.com/minio/minlz v1.0.1 h1:OUZUzXcib8diiX+JYxyRLIdomyZYzHct6EShOKtQY2A=
37+
github.com/minio/minlz v1.0.1/go.mod h1:qT0aEB35q79LLornSzeDH75LBf3aH1MV+jB5w9Wasec=
3638
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
3739
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3840
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -50,14 +52,14 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
5052
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
5153
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
5254
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
53-
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b h1:18qgiDvlvH7kk8Ioa8Ov+K6xCi0GMvmGfGW0sgd/SYA=
54-
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
55-
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
56-
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
57-
google.golang.org/genproto/googleapis/api v0.0.0-20251007200510-49b9836ed3ff h1:8Zg5TdmcbU8A7CXGjGXF1Slqu/nIFCRaR3S5gT2plIA=
58-
google.golang.org/genproto/googleapis/api v0.0.0-20251007200510-49b9836ed3ff/go.mod h1:dbWfpVPvW/RqafStmRWBUpMN14puDezDMHxNYiRfQu0=
59-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251007200510-49b9836ed3ff h1:A90eA31Wq6HOMIQlLfzFwzqGKBTuaVztYu/g8sn+8Zc=
60-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251007200510-49b9836ed3ff/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
55+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
56+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
57+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
58+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
59+
google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba h1:B14OtaXuMaCQsl2deSvNkyPKIzq3BjfxQp8d00QyWx4=
60+
google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba/go.mod h1:G5IanEx8/PgI9w6CFcYQf7jMtHQhZruvfM1i3qOqk5U=
61+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba h1:UKgtfRM7Yh93Sya0Fo8ZzhDP4qBckrrxEr2oF5UIVb8=
62+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
6163
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
6264
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
6365
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

go/metalstack/admin/v2/adminv2connect/token.connect.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/metalstack/api/v2/apiv2connect/token.connect.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)