package Ġcom . ba ul supp . ok url . services . basic auth Ċ Ċ import Ġcom . ba ul supp . sch output . handler . Output Handler Ċ import Ġcom . ba ul supp . ok url . auth enticator . Auth Interceptor Ċ import Ġcom . ba ul supp . ok url . auth enticator . Basic Credentials Ċ import Ġcom . ba ul supp . ok url . completion . Completion Variable Cache Ċ import Ġcom . ba ul supp . ok url . completion . Url Comp leter Ċ import Ġcom . ba ul supp . ok url . credentials . Credentials Store Ċ import Ġcom . ba ul supp . ok url . credentials . Token Ċ import Ġcom . ba ul supp . ok url . secrets . Secrets Ċ import Ġcom . ba ul supp . ok url . services . Abstract Service Definition Ċ import Ġokhttp 3 . Http Url Ċ import Ġokhttp 3 . Interceptor Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . Response Ċ Ċ class ĠBasic Auth Interceptor Ġ: ĠAuth Interceptor < Filtered Basic Credentials >() Ġ{ ĊĠ Ġoverride Ġval Ġservice Definition Ġ= Ġobject Ġ: ĠAbstract Service Definition < Filtered Basic Credentials >( ĊĠĠĠ Ġ" basic ", Ġ" Basic ĠAuth ", Ġ" basic ", ĊĠĠĠ Ġ" https :// en . wikipedia . org / wiki / Basic _ access _ authentication " ĊĠ Ġ) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġparse Credentials String ( s : ĠString ): ĠFilter ed Basic Credentials Ġ{ ĊĠĠĠĠĠ Ġval Ġ( user , Ġpassword , Ġhost Pattern ) Ġ= Ġs . split (" :" . to Regex (), Ġ 3 ). to Typed Array () ĊĠĠĠĠĠ Ġreturn ĠFilter ed Basic Credentials ( Basic Credentials ( user , Ġpassword ), Ġhost Pattern ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġformat Credentials String ( credentials : ĠFilter ed Basic Credentials ) Ġ= ĊĠĠĠĠĠ Ġ"${ credentials . basic Credentials . user }:${ credentials . basic Credentials . password }:${ credentials . host Pattern }" ĊĠ Ġ} ĊĊĠ Ġoverride Ġsuspend Ġfun Ġintercept ( chain : ĠInter ceptor . Chain , Ġcredentials : ĠFilter ed Basic Credentials ): ĠResponse Ġ{ ĊĠĠĠ Ġval Ġrequest Ġ= Ġchain . request (). newBuilder (). add Header (" Authorization ", Ġcredentials . basic Credentials . header ()). build () ĊĠĠĠ Ġreturn Ġchain . proceed ( request ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġsuspend Ġfun Ġintercept ( ĊĠĠĠ Ġchain : ĠInter ceptor . Chain , ĊĠĠĠ Ġcredentials : ĠFilter ed Basic Credentials ?, ĊĠĠĠ Ġcredentials Store : ĠCredentials Store ĊĠ Ġ): ĠResponse Ġ{ ĊĠĠĠ Ġvar Ġrequest Ġ= Ġchain . request () ĊĠĠĠ Ġval Ġurl Ġ= Ġchain . call (). request (). url ĊĊĠĠĠ Ġval Ġmatching Credentials : ĠFilter ed Basic Credentials ? ĊĊĠĠĠ Ġmatching Credentials Ġ= Ġif Ġ( credentials ?. matches ( url ) Ġ== Ġtrue ) Ġ{ ĊĠĠĠĠĠ Ġcredentials ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ ĠFilter ed Basic Credentials . first Match ( all Stored Credentials ( credentials Store ), Ġurl ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġif Ġ( matching Credentials Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġrequest Ġ= Ġrequest . newBuilder (). add Header (" Authorization ", Ġmatching Credentials . basic Credentials . header ()). build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġchain . proceed ( request ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġsuspend Ġfun Ġsupports Url ( url : ĠHttp Url , Ġcredentials Store : ĠCredentials Store ): ĠBoolean Ġ= ĊĠĠĠ ĠFilter ed Basic Credentials . matches ( all Stored Credentials ( credentials Store ), Ġurl ) ĊĊĠ Ġsuspend Ġfun Ġall Stored Credentials ( credentials Store : ĠCredentials Store ) Ġ= ĊĠĠĠ Ġcredentials Store . findAll Named ( service Definition ). values ĊĊĠ Ġoverride Ġsuspend Ġfun Ġauthorize ( ĊĠĠĠ Ġclient : ĠOk HttpClient , ĊĠĠĠ Ġoutput Handler : ĠOutput Handler < Response >, ĊĠĠĠ Ġauth Arguments : ĠList < String > ĊĠ Ġ): ĠFilter ed Basic Credentials Ġ{ ĊĠĠĠ Ġval Ġuser Ġ= ĠSec rets . prompt (" Basic ĠAuth ĠUser ", Ġ" basic . user ", Ġ"", Ġfalse ) ĊĠĠĠ Ġval Ġpassword Ġ= ĠSec rets . prompt (" Basic ĠAuth ĠPassword ", Ġ" basic . password ", Ġ"", Ġtrue ) ĊĠĠĠ Ġval Ġhost Pattern Ġ= ĠSec rets . prompt (" Matching ĠHost s Ġ* | *. site . com | app . site . com ", Ġ" basic . host pattern ", Ġ"", Ġfalse ) ĊĊĠĠĠ Ġreturn ĠFilter ed Basic Credentials ( Basic Credentials ( user , Ġpassword ), Ġhost Pattern ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġsuspend Ġfun Ġapi Comp leter ( ĊĠĠĠ Ġprefix : ĠString , ĊĠĠĠ Ġclient : ĠOk HttpClient , ĊĠĠĠ Ġcredentials Store : ĠCredentials Store , ĊĠĠĠ Ġcompletion Variable Cache : ĠCompletion Variable Cache , ĊĠĠĠ Ġtoken Set : ĠToken ĊĠ Ġ) Ġ= ĠUrl Comp leter . Null Comp leter ĊĊĠ Ġoverride Ġfun Ġhosts ( credentials Store : ĠCredentials Store ): ĠSet < String > Ġ= Ġset Of (" basic ") ĊĊĠ Ġ// Ġlower Ġpriority Ġthan Ġany Ġsite Ġspecific Ġauth ĊĠ Ġoverride Ġval Ġpriority : ĠInt ĊĠĠĠ Ġget () Ġ= Ġ- 1 0 0 Ċ } Ċ