@@ -13,6 +13,7 @@ import no.nav.security.mock.oauth2.http.Route
13
13
import no.nav.security.mock.oauth2.http.json
14
14
import no.nav.security.mock.oauth2.token.OAuth2TokenProvider
15
15
import okhttp3.Headers
16
+ import java.util.Date
16
17
17
18
private val log = KotlinLogging .logger { }
18
19
@@ -26,21 +27,20 @@ internal fun Route.Builder.introspect(tokenProvider: OAuth2TokenProvider) =
26
27
}
27
28
28
29
request.verifyToken(tokenProvider)?.let {
29
- val claims = it.claims
30
30
json(
31
31
IntrospectResponse (
32
32
true ,
33
- claims[ " scope" ].toString( ),
34
- claims[ " client_id" ].toString( ),
35
- claims[ " username" ].toString( ),
36
- claims[ " token_type" ].toString() ,
37
- claims[ " exp " ] as ? Long ,
38
- claims[ " iat " ] as ? Long ,
39
- claims[ " nbf " ] as ? Long ,
40
- claims[ " sub " ].toString() ,
41
- claims[ " aud " ].toString() ,
42
- claims[ " iss " ].toString() ,
43
- claims[ " jti " ].toString() ,
33
+ it.getStringClaim( " scope" ),
34
+ it.getStringClaim( " client_id" ),
35
+ it.getStringClaim( " username" ),
36
+ it.getStringClaim( " token_type" ) ? : " Bearer " ,
37
+ it.expirationTime?.time?.div( 1000 ) ,
38
+ it.issueTime?.time?.div( 1000 ) ,
39
+ it.notBeforeTime?.time?.div( 1000 ) ,
40
+ it.subject ,
41
+ it.audience ,
42
+ it.issuer ,
43
+ it.jwtid ,
44
44
),
45
45
)
46
46
} ? : json(IntrospectResponse (false ))
@@ -91,7 +91,7 @@ data class IntrospectResponse(
91
91
@JsonProperty(" sub" )
92
92
val sub : String? = null ,
93
93
@JsonProperty(" aud" )
94
- val aud : String? = null ,
94
+ val aud : List < String > ? = null ,
95
95
@JsonProperty(" iss" )
96
96
val iss : String? = null ,
97
97
@JsonProperty(" jti" )
0 commit comments