@@ -51,7 +51,7 @@ type OAuth2Configs struct {
51
51
Github OAuth2Config
52
52
}
53
53
54
- const loggedOutErrorMessage string = "You are logged out. Please log in to continue."
54
+ const signedOutErrorMessage string = "You are signed out. Please sign in to continue."
55
55
56
56
// ExtractAPIKey requires authentication using a valid API key.
57
57
// It handles extending an API key if it comes close to expiry,
@@ -85,7 +85,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
85
85
}
86
86
if cookieValue == "" {
87
87
write (http .StatusUnauthorized , codersdk.Response {
88
- Message : loggedOutErrorMessage ,
88
+ Message : signedOutErrorMessage ,
89
89
Detail : fmt .Sprintf ("Cookie %q or query parameter must be provided." , codersdk .SessionTokenKey ),
90
90
})
91
91
return
@@ -94,7 +94,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
94
94
// APIKeys are formatted: ID-SECRET
95
95
if len (parts ) != 2 {
96
96
write (http .StatusUnauthorized , codersdk.Response {
97
- Message : loggedOutErrorMessage ,
97
+ Message : signedOutErrorMessage ,
98
98
Detail : fmt .Sprintf ("Invalid %q cookie API key format." , codersdk .SessionTokenKey ),
99
99
})
100
100
return
@@ -104,14 +104,14 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
104
104
// Ensuring key lengths are valid.
105
105
if len (keyID ) != 10 {
106
106
write (http .StatusUnauthorized , codersdk.Response {
107
- Message : loggedOutErrorMessage ,
107
+ Message : signedOutErrorMessage ,
108
108
Detail : fmt .Sprintf ("Invalid %q cookie API key id." , codersdk .SessionTokenKey ),
109
109
})
110
110
return
111
111
}
112
112
if len (keySecret ) != 22 {
113
113
write (http .StatusUnauthorized , codersdk.Response {
114
- Message : loggedOutErrorMessage ,
114
+ Message : signedOutErrorMessage ,
115
115
Detail : fmt .Sprintf ("Invalid %q cookie API key secret." , codersdk .SessionTokenKey ),
116
116
})
117
117
return
@@ -120,7 +120,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
120
120
if err != nil {
121
121
if errors .Is (err , sql .ErrNoRows ) {
122
122
write (http .StatusUnauthorized , codersdk.Response {
123
- Message : loggedOutErrorMessage ,
123
+ Message : signedOutErrorMessage ,
124
124
Detail : "API key is invalid." ,
125
125
})
126
126
return
@@ -136,7 +136,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
136
136
// Checking to see if the secret is valid.
137
137
if subtle .ConstantTimeCompare (key .HashedSecret , hashed [:]) != 1 {
138
138
write (http .StatusUnauthorized , codersdk.Response {
139
- Message : loggedOutErrorMessage ,
139
+ Message : signedOutErrorMessage ,
140
140
Detail : "API key secret is invalid." ,
141
141
})
142
142
return
@@ -182,7 +182,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
182
182
// Checking if the key is expired.
183
183
if key .ExpiresAt .Before (now ) {
184
184
write (http .StatusUnauthorized , codersdk.Response {
185
- Message : loggedOutErrorMessage ,
185
+ Message : signedOutErrorMessage ,
186
186
Detail : fmt .Sprintf ("API key expired at %q." , key .ExpiresAt .String ()),
187
187
})
188
188
return
@@ -225,7 +225,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
225
225
})
226
226
if err != nil {
227
227
write (http .StatusInternalServerError , codersdk.Response {
228
- Message : loggedOutErrorMessage ,
228
+ Message : signedOutErrorMessage ,
229
229
Detail : fmt .Sprintf ("API key couldn't update: %s." , err .Error ()),
230
230
})
231
231
return
0 commit comments