Skip to content

Commit

Permalink
fix: NPE when email_verified claim is missing in OIDC request
Browse files Browse the repository at this point in the history
Closes: #1054
  • Loading branch information
gotson committed Jan 27, 2023
1 parent 781d839 commit 72e5fd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ERRORCODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ ERR_1023 | Book already present in ReadingList
ERR_1024 | OAuth2 login error: no email attribute
ERR_1025 | OAuth2 login error: no local user exist with that email
ERR_1026 | OpenIDConnect login error: email not verified
ERR_1027 | OpenIDConnect login error: no email_verified attribute
ERR_1028 | OpenIDConnect login error: no email attribute
4 changes: 3 additions & 1 deletion komga-webui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@
"ERR_1023": "Book already present in ReadingList",
"ERR_1024": "OAuth2 login error: no email attribute",
"ERR_1025": "OAuth2 login error: no local user exist with that email",
"ERR_1026": "OpenID Connect login error: email not verified"
"ERR_1026": "OpenID Connect login error: email not verified",
"ERR_1027": "OpenID Connect login error: no email_verified attribute",
"ERR_1028": "OpenID Connect login error: no email attribute"
},
"filter": {
"age_rating": "age rating",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class KomgaOAuth2UserServiceConfiguration(
return OAuth2UserService { userRequest: OidcUserRequest ->
val oidcUser = delegate.loadUser(userRequest)

if (!oidcUser.emailVerified) throw OAuth2AuthenticationException("ERR_1026")
if (oidcUser.email == null) throw OAuth2AuthenticationException("ERR_1028")
if (oidcUser.emailVerified == null) throw OAuth2AuthenticationException("ERR_1027")
if (oidcUser.emailVerified == false) throw OAuth2AuthenticationException("ERR_1026")

val existingUser = userRepository.findByEmailIgnoreCaseOrNull(oidcUser.email)
?: tryCreateNewUser(oidcUser.email)
Expand Down

0 comments on commit 72e5fd9

Please sign in to comment.