@@ -1096,15 +1096,6 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
1096
1096
return
1097
1097
}
1098
1098
1099
- if idToken .Subject == "" {
1100
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
1101
- Message : "OIDC token missing 'sub' claim field or 'sub' claim field is empty." ,
1102
- Detail : "'sub' claim field is required to be unique for all users by a given issue, " +
1103
- "an empty field is invalid and this authentication attempt is rejected." ,
1104
- })
1105
- return
1106
- }
1107
-
1108
1099
logger := api .Logger .Named (userAuthLoggerName )
1109
1100
1110
1101
// "email_verified" is an optional claim that changes the behavior
@@ -1121,6 +1112,20 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
1121
1112
return
1122
1113
}
1123
1114
1115
+ if idToken .Subject == "" {
1116
+ logger .Error (ctx , "oauth2: missing 'sub' claim field in OIDC token" ,
1117
+ slog .F ("source" , "id_token" ),
1118
+ slog .F ("claim_fields" , claimFields (idtokenClaims )),
1119
+ slog .F ("blank" , blankFields (idtokenClaims )),
1120
+ )
1121
+ httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
1122
+ Message : "OIDC token missing 'sub' claim field or 'sub' claim field is empty." ,
1123
+ Detail : "'sub' claim field is required to be unique for all users by a given issue, " +
1124
+ "an empty field is invalid and this authentication attempt is rejected." ,
1125
+ })
1126
+ return
1127
+ }
1128
+
1124
1129
logger .Debug (ctx , "got oidc claims" ,
1125
1130
slog .F ("source" , "id_token" ),
1126
1131
slog .F ("claim_fields" , claimFields (idtokenClaims )),
0 commit comments