@@ -65,15 +65,15 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
65
65
}
66
66
if cookieValue == "" {
67
67
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
68
- Message :fmt .Sprintf ("Cookie %q or query parameter must be provided" ,SessionTokenKey ),
68
+ Message :fmt .Sprintf ("Cookie %q or query parameter must be provided. " ,SessionTokenKey ),
69
69
})
70
70
return
71
71
}
72
72
parts := strings .Split (cookieValue ,"-" )
73
73
// APIKeys are formatted: ID-SECRET
74
74
if len (parts )!= 2 {
75
75
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
76
- Message :fmt .Sprintf ("Invalid %q cookie API key format" ,SessionTokenKey ),
76
+ Message :fmt .Sprintf ("Invalid %q cookie API key format. " ,SessionTokenKey ),
77
77
})
78
78
return
79
79
}
@@ -82,26 +82,26 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
82
82
// Ensuring key lengths are valid.
83
83
if len (keyID )!= 10 {
84
84
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
85
- Message :fmt .Sprintf ("Invalid %q cookie API key id" ,SessionTokenKey ),
85
+ Message :fmt .Sprintf ("Invalid %q cookie API key id. " ,SessionTokenKey ),
86
86
})
87
87
return
88
88
}
89
89
if len (keySecret )!= 22 {
90
90
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
91
- Message :fmt .Sprintf ("Invalid %q cookie API key secret" ,SessionTokenKey ),
91
+ Message :fmt .Sprintf ("Invalid %q cookie API key secret. " ,SessionTokenKey ),
92
92
})
93
93
return
94
94
}
95
95
key ,err := db .GetAPIKeyByID (r .Context (),keyID )
96
96
if err != nil {
97
97
if errors .Is (err ,sql .ErrNoRows ) {
98
98
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
99
- Message :"API key is invalid" ,
99
+ Message :"API key is invalid. " ,
100
100
})
101
101
return
102
102
}
103
103
httpapi .Write (rw ,http .StatusInternalServerError , httpapi.Response {
104
- Message :"Internal error fetching API key by id" ,
104
+ Message :"Internal error fetching API key by id. " ,
105
105
Detail :err .Error (),
106
106
})
107
107
return
@@ -111,7 +111,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
111
111
// Checking to see if the secret is valid.
112
112
if subtle .ConstantTimeCompare (key .HashedSecret ,hashed [:])!= 1 {
113
113
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
114
- Message :"API key secret is invalid" ,
114
+ Message :"API key secret is invalid. " ,
115
115
})
116
116
return
117
117
}
@@ -128,7 +128,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
128
128
oauthConfig = oauth .Github
129
129
default :
130
130
httpapi .Write (rw ,http .StatusInternalServerError , httpapi.Response {
131
- Message :fmt .Sprintf ("Unexpected authentication type %q" ,key .LoginType ),
131
+ Message :fmt .Sprintf ("Unexpected authentication type %q. " ,key .LoginType ),
132
132
})
133
133
return
134
134
}
@@ -140,7 +140,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
140
140
}).Token ()
141
141
if err != nil {
142
142
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
143
- Message :"Could not refresh expired Oauth token" ,
143
+ Message :"Could not refresh expired Oauth token. " ,
144
144
Detail :err .Error (),
145
145
})
146
146
return
@@ -156,7 +156,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
156
156
// Checking if the key is expired.
157
157
if key .ExpiresAt .Before (now ) {
158
158
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
159
- Message :fmt .Sprintf ("API key expired at %q" ,key .ExpiresAt .String ()),
159
+ Message :fmt .Sprintf ("API key expired at %q. " ,key .ExpiresAt .String ()),
160
160
})
161
161
return
162
162
}
@@ -184,7 +184,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
184
184
})
185
185
if err != nil {
186
186
httpapi .Write (rw ,http .StatusInternalServerError , httpapi.Response {
187
- Message :fmt .Sprintf ("API key couldn't update: %s" ,err .Error ()),
187
+ Message :fmt .Sprintf ("API key couldn't update: %s. " ,err .Error ()),
188
188
})
189
189
return
190
190
}
@@ -196,7 +196,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
196
196
roles ,err := db .GetAuthorizationUserRoles (r .Context (),key .UserID )
197
197
if err != nil {
198
198
httpapi .Write (rw ,http .StatusUnauthorized , httpapi.Response {
199
- Message :"Internal error fetching user's roles" ,
199
+ Message :"Internal error fetching user's roles. " ,
200
200
Detail :err .Error (),
201
201
})
202
202
return