@@ -78,8 +78,6 @@ func getAuthTokenFromContext(ctx context.Context) (string, error) {
78
78
// artifact storage, and deleting as well.
79
79
func (s * Server ) GenerateSignedURLs (ctx context.Context ,
80
80
q * artifacts.GenerateSignedURLsRequest ) (* artifacts.GenerateSignedURLsResponse , error ) {
81
- log .Info ("[GenerateSignedURLs] Received" , zap .Reflect ("request" , q ))
82
-
83
81
response := & artifacts.GenerateSignedURLsResponse {}
84
82
token , err := getAuthTokenFromContext (ctx )
85
83
if err != nil {
@@ -93,12 +91,22 @@ func (s *Server) GenerateSignedURLs(ctx context.Context,
93
91
return response , nil
94
92
}
95
93
96
- artifact , err := s .authenticate (token , q .Paths )
94
+ artifact , claims , err := s .authenticateAndGetClaims (token , q .Paths )
97
95
if err != nil {
98
96
log .Error ("Error authenticating request" , zap .Error (err ))
99
97
return nil , err
100
98
}
101
99
100
+ log .Info ("[GenerateSignedURLs] Authenticated request" ,
101
+ zap .String ("type" , q .Type .String ()),
102
+ zap .Int ("paths_count" , len (q .Paths )),
103
+ zap .Strings ("paths" , q .Paths ),
104
+ zap .String ("artifact" , claims .ArtifactID ),
105
+ zap .String ("project" , claims .Project ),
106
+ zap .String ("job" , claims .Job ),
107
+ zap .String ("workflow" , claims .Workflow ),
108
+ )
109
+
102
110
var us []* artifacts.SignedURL
103
111
switch q .Type {
104
112
case artifacts .GenerateSignedURLsRequest_PUSH :
@@ -177,26 +185,23 @@ func getMaxReceiveMessageSize() int {
177
185
return maxReceiveMsgSize
178
186
}
179
187
180
- func (s * Server ) authenticate (token string , paths []string ) (* models.Artifact , error ) {
188
+ func (s * Server ) authenticateAndGetClaims (token string , paths []string ) (* models.Artifact , * jwt. Claims , error ) {
181
189
resourceType , resourceID , err := s .findAndValidateResource (paths )
182
190
if err != nil {
183
- return nil , err
191
+ return nil , nil , err
184
192
}
185
193
186
194
claims , err := s .validateJWT (resourceType , resourceID , token )
187
195
if err != nil {
188
- return nil , status .Error (codes .PermissionDenied , err .Error ())
196
+ return nil , nil , status .Error (codes .PermissionDenied , err .Error ())
189
197
}
190
198
191
- log .Info (
192
- "Granted access to artifact storage through JWT" ,
193
- zap .String ("artifact" , claims .ArtifactID ),
194
- zap .String ("project" , claims .Project ),
195
- zap .String ("job" , claims .Job ),
196
- zap .String ("workflow" , claims .Workflow ),
197
- )
199
+ artifacts , err := models .FindArtifactByID (claims .ArtifactID )
200
+ if err != nil {
201
+ return nil , nil , err
202
+ }
198
203
199
- return models . FindArtifactByID ( claims . ArtifactID )
204
+ return artifacts , claims , nil
200
205
}
201
206
202
207
func (s * Server ) validateJWT (resourceType , resourceID , token string ) (* jwt.Claims , error ) {
0 commit comments