Skip to content

Commit

Permalink
provide openid connect discovery meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Nov 26, 2024
1 parent 7ac2035 commit ae71cbf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/controllers/OAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import lila.app.*
import lila.common.HTTPRequest
import lila.common.Json.given
import lila.core.net.Bearer
import lila.oauth.{ AccessTokenRequest, AuthorizationRequest, OAuthScopes }
import lila.oauth.{ AccessTokenRequest, AuthorizationRequest, OAuthScopes, OAuthScope }

import Api.ApiResult

Expand Down Expand Up @@ -137,3 +137,21 @@ final class OAuth(env: Env, apiC: => Api) extends LilaController(env):
}))
}
.map(apiC.toHttp)

def openIdConfiguration = Anon:
// https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
JsonOk(
Json.obj(
"issuer" -> env.net.baseUrl,
"authorization_endpoint" -> s"${env.net.baseUrl}${routes.OAuth.authorize.url}",
"token_endpoint" -> s"${env.net.baseUrl}${routes.OAuth.tokenApply.url}",
// "userinfo_endpoint" -> ???,
// "jwks_uri" -> ???,
"scopes_supported" -> OAuthScope.all.map(_.key),
"response_types_supported" -> List("code"),
"response_modes_supported" -> List("query"),
"grant_types_supported" -> List("authorization_code"),
// "subject_types_supported" -> ???,
"id_token_signing_alg_values_supported" -> List("RS256")
)
)
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ POST /account/oauth/token/create controllers.OAuthToken.createApply
POST /account/oauth/token/:id/delete controllers.OAuthToken.delete(id)
POST /api/token/admin-challenge controllers.OAuth.challengeTokens
POST /api/token/test controllers.OAuth.testTokens
GET /.well-known/openid-configuration controllers.OAuth.openIdConfiguration

# Events
GET /event/$id<\w{8}> controllers.Event.show(id)
Expand Down

0 comments on commit ae71cbf

Please sign in to comment.