Skip to content

Commit 6ceb6d8

Browse files
committed
Formatting
1 parent daf7c57 commit 6ceb6d8

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/main/kotlin/no/java/cupcake/plugins/Security.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package no.java.cupcake.plugins
1+
package no.java.cupcake.plugins
22

33
import com.auth0.jwk.JwkProviderBuilder
44
import io.ktor.client.HttpClient
@@ -84,8 +84,10 @@ fun Application.configureAuth(oidcConfig: OidcConfig): String {
8484
}
8585

8686
validate { cred ->
87-
val groups = cred.payload.getClaim("cognito:groups")
88-
?.asList(String::class.java) ?: emptyList()
87+
val groups =
88+
cred.payload
89+
.getClaim("cognito:groups")
90+
?.asList(String::class.java) ?: emptyList()
8991
if (groups.contains("helter")) JWTPrincipal(cred.payload) else null
9092
}
9193

@@ -113,16 +115,20 @@ fun Application.configureUserInfoRoute(userInfoEndpoint: String) {
113115
authenticate("javaBin") {
114116
get("/api/me") {
115117
val p = call.principal<JWTPrincipal>()!!
116-
val token = call.request.headers[HttpHeaders.Authorization]
117-
?.removePrefix("Bearer ") ?: ""
118+
val token =
119+
call.request.headers[HttpHeaders.Authorization]
120+
?.removePrefix("Bearer ") ?: ""
118121

119-
val groups = p.payload.getClaim("cognito:groups")
120-
?.asList(String::class.java) ?: emptyList()
122+
val groups =
123+
p.payload
124+
.getClaim("cognito:groups")
125+
?.asList(String::class.java) ?: emptyList()
121126

122127
val userInfo =
123-
http.get(userInfoEndpoint) {
124-
header(HttpHeaders.Authorization, "Bearer $token")
125-
}.body<UserInfoResponse>()
128+
http
129+
.get(userInfoEndpoint) {
130+
header(HttpHeaders.Authorization, "Bearer $token")
131+
}.body<UserInfoResponse>()
126132

127133
call.respond(
128134
UserInfo(

0 commit comments

Comments
 (0)