11package com .uid2 .admin .auth ;
22
33import com .okta .jwt .IdTokenVerifier ;
4+ import com .uid2 .shared .audit .Audit ;
5+ import com .uid2 .shared .audit .AuditParams ;
6+ import io .vertx .core .Handler ;
47import io .vertx .core .Vertx ;
58import io .vertx .core .json .JsonObject ;
69import io .vertx .ext .auth .oauth2 .OAuth2Auth ;
710import io .vertx .ext .auth .oauth2 .OAuth2Options ;
811import io .vertx .ext .web .Route ;
12+ import io .vertx .ext .web .RoutingContext ;
913import io .vertx .ext .web .handler .AuthenticationHandler ;
1014import io .vertx .ext .web .handler .OAuth2AuthHandler ;
1115import com .okta .jwt .AccessTokenVerifier ;
@@ -24,8 +28,11 @@ public class OktaAuthProvider implements AuthProvider {
2428 private final List <String > scopes = List .of ("openid" , "email" , "uid2.admin.human" );
2529 private final AccessTokenVerifier accessTokenVerifier ;
2630 private final IdTokenVerifier idTokenVerifier ;
31+ private final Audit audit ;
32+
2733 public OktaAuthProvider (JsonObject config ) {
2834 this .config = config ;
35+ this .audit = new Audit (OktaAuthProvider .class .getPackage ().getName ());
2936 if (isAuthDisabled (config )) {
3037 this .accessTokenVerifier = null ;
3138 this .idTokenVerifier = null ;
@@ -66,6 +73,9 @@ public AuthenticationHandler createAuthHandler(Vertx vertx, Route callbackRoute)
6673 OAuth2AuthHandler authHandler = OAuth2AuthHandler .create (vertx , oktaAuth , this .config .getString (OKTA_CALLBACK ));
6774 authHandler .extraParams (new JsonObject (String .format ("{\" scope\" :\" %s\" }" , String .join (" " , this .scopes ))));
6875 authHandler .setupCallback (callbackRoute );
76+ callbackRoute .handler (ctx -> {
77+ ctx .addBodyEndHandler (v -> this .audit .log (ctx , new AuditParams ()));
78+ });
6979 return authHandler ;
7080 }
7181
0 commit comments