package Ġk g . j edi . four angle . web . security . config Ċ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġk g . j edi . four angle . common . Endpoints Ċ import Ġk g . j edi . four angle . web . security . Rest Authentication EntryPoint Ċ import Ġk g . j edi . four angle . web . security . auth . ajax . Ajax Authentication Provider Ċ import Ġk g . j edi . four angle . web . security . auth . ajax . Ajax Login Processing Filter Ċ import Ġk g . j edi . four angle . web . security . auth . jwt . Jwt Authentication Provider Ċ import Ġk g . j edi . four angle . web . security . auth . jwt . Jwt Token Authentication Processing Filter Ċ import Ġk g . j edi . four angle . web . security . auth . jwt . Skip Path Request Matcher Ċ import Ġk g . j edi . four angle . web . security . auth . jwt . extractor . Token Extractor Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . beans . factory . annotation . Qualifier Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . security . authentication . Authentication Manager Ċ import Ġorg . springframework . security . config . annotation . authentication . builders . Authentication Manager Builder Ċ import Ġorg . springframework . security . config . annotation . web . builders . Http Security Ċ import Ġorg . springframework . security . config . annotation . web . builders . Web Security Ċ import Ġorg . springframework . security . config . annotation . web . configuration . Enable Web Security Ċ import Ġorg . springframework . security . config . annotation . web . configuration . Web Security Configurer Adapter Ċ import Ġorg . springframework . security . config . http . Session Creation Policy Ċ import Ġorg . springframework . security . web . access . channel . Channel Processing Filter Ċ import Ġorg . springframework . security . web . authentication . Authentication Failure Handler Ċ import Ġorg . springframework . security . web . authentication . Authentication Success Handler Ċ import Ġorg . springframework . security . web . authentication . Username Password Authentication Filter ĊĊ Ċ @ Configuration Ċ @ Enable Web Security Ċ class ĠWeb Security Config Ġ: ĠWeb Security Configurer Adapter () Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġauthentication EntryPoint : ĠRest Authentication EntryPoint ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġsuccess Handler : ĠAuthentication Success Handler ĊĊĠĠĠ Ġ@ Qualifier (" jwt ") ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġjwt Failure Handler : ĠAuthentication Failure Handler ĊĊĠĠĠ Ġ@ Qualifier (" ajax ") ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġajax Failure Handler : ĠAuthentication Failure Handler ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġajax Authentication Provider : ĠAjax Authentication Provider ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġjwt Authentication Provider : ĠJwt Authentication Provider ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġtoken Extractor : ĠToken Extractor ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġauthentication Manager : ĠAuthentication Manager ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar ĠobjectMapper : ĠObjectMapper ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġcross Origin Filter : ĠCross Origin Filter ĊĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠFORM _ BASE D _ LOGIN _ ENTRY _ POINT Ġ= Ġ"$ Endpoints . API _ V 1 / login " ĊĠĠĠĠĠĠĠ Ġval ĠTOKEN _ BASE D _ AUTH _ ENTRY _ POINT Ġ= Ġ"${ Endpoints . SECURE _ API _ V 1 } /** " ĊĠĠĠĠĠĠĠ Ġval ĠSW AG GER _ ENDPOINT S Ġ= ĠarrayOf ("/ v 2 / api - docs ", Ġ"/ configuration / ui /** ", Ġ"/ swagger - resources /** ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"/ configuration / security /** ", Ġ"/ swagger - ui . html ", Ġ"/ web j ars /** ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġprotected Ġfun Ġbuild Ajax Login Processing Filter (): ĠAjax Login Processing Filter Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= ĠAjax Login Processing Filter ( FORM _ BASE D _ LOGIN _ ENTRY _ POINT , Ġsuccess Handler , Ġajax Failure Handler , ĠobjectMapper ) ĊĠĠĠĠĠĠĠ Ġfilter . set Authentication Manager ( this . authentication Manager ) ĊĠĠĠĠĠĠĠ Ġreturn Ġfilter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġprotected Ġfun Ġbuild Jwt Token Authentication Processing Filter (): ĠJwt Token Authentication Processing Filter Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpaths To Skip Ġ= ĠlistOf ( FORM _ BASE D _ LOGIN _ ENTRY _ POINT ) ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= ĠSkip Path Request Matcher ( paths To Skip , ĠTOKEN _ BASE D _ AUTH _ ENTRY _ POINT ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= ĠJwt Token Authentication Processing Filter ( this . jwt Failure Handler , Ġthis . token Extractor , Ġmatcher ) ĊĠĠĠĠĠĠĠ Ġfilter . set Authentication Manager ( this . authentication Manager ) ĊĠĠĠĠĠĠĠ Ġreturn Ġfilter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġoverride Ġfun Ġauthentication Manager Bean (): ĠAuthentication Manager Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsuper . authentication Manager Bean () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġconfigure ( auth : ĠAuthentication Manager Builder ) Ġ{ ĊĠĠĠĠĠĠĠ Ġauth . authentication Provider ( ajax Authentication Provider ) ĊĠĠĠĠĠĠĠ Ġauth . authentication Provider ( jwt Authentication Provider ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġoverride Ġfun Ġconfigure ( http : ĠHttp Security ) Ġ{ ĊĠĠĠĠĠĠĠ Ġhttp . add Filter Before ( cross Origin Filter , ĠChannel Processing Filter :: class . java ). cors (). and () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. csrf (). disable () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. exception Handling () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. authentication EntryPoint ( this . authentication EntryPoint ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. and () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. session Management () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. session Creation Policy ( Session Creation Policy . IF _ REQUIRED ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. and () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. authorize Requests () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ant Matchers ( FORM _ BASE D _ LOGIN _ ENTRY _ POINT ). permit All () ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. and () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. authorize Requests () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ant Matchers ( TOKEN _ BASE D _ AUTH _ ENTRY _ POINT ). authenticated () Ġ// ĠProtected ĠAPI ĠEnd - points ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. and () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Filter Before ( build Ajax Login Processing Filter (), ĠUsername Password Authentication Filter :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Filter Before ( build Jwt Token Authentication Processing Filter (), ĠUsername Password Authentication Filter :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġconfigure ( web : ĠWeb Security ) Ġ{ ĊĠĠĠĠĠĠĠ Ġweb . ign oring (). ant Matchers (* SW AG GER _ ENDPOINT S ) ĊĠĠĠ Ġ} Ċ } Ċ