Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: validate issuer (url) when retrieving configuration #137

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,21 @@
uriBuilder.build(),
{ configuration, ex ->
if (configuration != null) {
// Validate that the issuer of the configuration is a valid URL
// Otherwise we get a NullPointerException, when trying to validate the id token later

val issuerScheme = configuration.discoveryDoc?.issuer?.let {
try {
Uri.parse(it).scheme
} catch (e: Exception) {

Check warning on line 411 in library/src/main/java/io/fusionauth/mobilesdk/oauth/OAuthAuthorizationService.kt

View workflow job for this annotation

GitHub Actions / Detekt Scan

[detekt] reported by reviewdog 🐶 The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Raw Output: {"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"uri":"library/src/main/java/io/fusionauth/mobilesdk/oauth/OAuthAuthorizationService.kt","uriBaseId":"%SRCROOT%"},"region":{"endColumn":50,"endLine":411,"startColumn":38,"startLine":411}}}],"message":{"text":"The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled."},"ruleId":"detekt.exceptions.TooGenericExceptionCaught"}

Check warning on line 411 in library/src/main/java/io/fusionauth/mobilesdk/oauth/OAuthAuthorizationService.kt

View workflow job for this annotation

GitHub Actions / Detekt Scan

[detekt] reported by reviewdog 🐶 The caught exception is swallowed. The original exception could be lost. Raw Output: {"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"uri":"library/src/main/java/io/fusionauth/mobilesdk/oauth/OAuthAuthorizationService.kt","uriBaseId":"%SRCROOT%"},"region":{"endColumn":50,"endLine":411,"startColumn":38,"startLine":411}}}],"message":{"text":"The caught exception is swallowed. The original exception could be lost."},"ruleId":"detekt.exceptions.SwallowedException"}
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
null
}
}
if (issuerScheme != "https" && issuerScheme != "http") {
continuation.resumeWithException(AuthorizationException("Invalid issuer URL"))
return@fetchFromUrl
}

authorizationConfiguration.set(configuration)
continuation.resume(configuration)
} else {
Expand Down
Loading