|
1 | | - package no.java.cupcake.plugins |
| 1 | +package no.java.cupcake.plugins |
2 | 2 |
|
3 | 3 | import com.auth0.jwk.JwkProviderBuilder |
4 | 4 | import io.ktor.client.HttpClient |
@@ -84,8 +84,10 @@ fun Application.configureAuth(oidcConfig: OidcConfig): String { |
84 | 84 | } |
85 | 85 |
|
86 | 86 | 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() |
89 | 91 | if (groups.contains("helter")) JWTPrincipal(cred.payload) else null |
90 | 92 | } |
91 | 93 |
|
@@ -113,16 +115,20 @@ fun Application.configureUserInfoRoute(userInfoEndpoint: String) { |
113 | 115 | authenticate("javaBin") { |
114 | 116 | get("/api/me") { |
115 | 117 | 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 ") ?: "" |
118 | 121 |
|
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() |
121 | 126 |
|
122 | 127 | 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>() |
126 | 132 |
|
127 | 133 | call.respond( |
128 | 134 | UserInfo( |
|
0 commit comments