Skip to content

Commit

Permalink
Merge pull request #1342 from dvgica/fix-reqd-authorization-url
Browse files Browse the repository at this point in the history
Make authorizationUrl optional
  • Loading branch information
adamw authored Jun 27, 2021
2 parents 109908f + 2f5da55 commit 55b5776
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case class OAuthFlows(
)

case class OAuthFlow(
authorizationUrl: String,
authorizationUrl: Option[String],
tokenUrl: Option[String],
refreshUrl: Option[String],
scopes: ListMap[String, String],
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/sttp/tapir/EndpointIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ object EndpointInput {
override def securitySchemeName(name: String): Http[T] = copy(securitySchemeName = Some(name))
}
case class Oauth2[T](
authorizationUrl: String,
authorizationUrl: Option[String],
tokenUrl: Option[String],
scopes: ListMap[String, String],
refreshUrl: Option[String],
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/sttp/tapir/TapirAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object TapirAuth {

object oauth2 {
def authorizationCode(
authorizationUrl: String,
scopes: ListMap[String, String],
authorizationUrl: Option[String] = None,
scopes: ListMap[String, String] = ListMap(),
tokenUrl: Option[String] = None,
refreshUrl: Option[String] = None,
challenge: WWWAuthenticate = WWWAuthenticate.bearer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class VerifyYamlSecurityTest extends AnyFunSuite with Matchers {
val oauth2 =
auth.oauth2
.authorizationCode(
"https://example.com/auth",
Some("https://example.com/auth"),
ListMap("client" -> "scope for clients", "admin" -> "administration scope")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object OAuth2GithubHttp4sServer extends App {

case class AccessDetails(token: String)

val authorizationUrl = "https://github.com/login/oauth/authorize"
val authorizationUrl = Some("https://github.com/login/oauth/authorize")
val accessTokenUrl = Some("https://github.com/login/oauth/access_token")

val authOAuth2 = auth.oauth2.authorizationCode(authorizationUrl, ListMap.empty, accessTokenUrl)
Expand Down

0 comments on commit 55b5776

Please sign in to comment.