package Ġnl . kr ash na . app . auth Ċ Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . security . config . annotation . authentication . builders . Authentication Manager Builder Ċ import Ġorg . springframework . security . config . annotation . method . configuration . Enable Global Method Security Ċ import Ġorg . springframework . security . config . annotation . web . builders . Http 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 . crypto . bcrypt . BC rypt Password Encoder Ċ import Ġorg . springframework . web . cors . Cors Configuration Ċ import Ġorg . springframework . web . cors . Cors Configuration Source Ċ import Ġorg . springframework . web . cors . Url Based Cors Configuration Source Ċ Ċ @ Enable Web Security Ċ class ĠWeb Security ( ĊĠĠĠ Ġprivate Ġval Ġuser Details Service : ĠUser Details Service , ĊĠĠĠ Ġprivate Ġval Ġb Crypt Password Encoder : ĠBC rypt Password Encoder Ċ ) Ġ: ĠWeb Security Configurer Adapter () Ġ{ ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġoverride Ġfun Ġconfigure ( http : ĠHttp Security ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġauthentication Filter Ġ= ĠJWT Authentication Filter ( authentication Manager ()) ĊĠĠĠĠĠĠĠ Ġauthentication Filter . set Filter Processes Url ("/ api / auth / login ") ĊĊĠĠĠĠĠĠĠ Ġhttp . cors (). and (). csrf (). disable (). authorize Requests () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. ant Matchers ("/ api / auth /** "). permit All () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. ant Matchers ("/ api /** "). authenticated () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. any Request (). permit All () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Filter ( authentication Filter ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Filter ( JWT Authorization Filter ( authentication Manager ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. session Management (). session Creation Policy ( Session Creation Policy . STATE LESS ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġpublic Ġoverride Ġfun Ġconfigure ( auth : ĠAuthentication Manager Builder ) Ġ{ ĊĠĠĠĠĠĠĠ Ġauth . user Details Service < UserDetails Service >( user Details Service ). password Encoder ( b Crypt Password Encoder ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġinternal Ġfun Ġcors Configuration Source (): ĠC ors Configuration Source Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsource Ġ= ĠUrl Based Cors Configuration Source () ĊĠĠĠĠĠĠĠ Ġsource . register Cors Configuration (" /** ", ĠC ors Configuration (). apply Permit Default Values ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġsource ĊĠĠĠ Ġ} Ċ } Ċ