This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this is with POC (plain old curry) | |
| // () => Filter | |
| val loginPostService = new ExceptionFilter andThen | |
| new ServiceFilter(serviceMatcher) andThen | |
| new SessionIdFilter(sessionStore) andThen | |
| new KeymasterLoginFilter(sessionStore) andThen | |
| new KeymasterIdentityProvider(keymasterClient, Path(keymasterIdentityProviderPath)) | |
| // (ServerConfig) => Filter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private def secretTryFromString(s: String): Try[Secret] = { | |
| Parse.parseOptions(s) match { | |
| case Some(json) => SecretEncoder.EncodeJson.decode(json) | |
| case None => Failure(s"unable to decode secret from string $s") | |
| } | |
| } | |
| def getValue[A,B](k: String): Future[Try[String]] = { | |
| getConsulResponse(k).map(str => | |
| str.decodeOption[ConsulResponse] match { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def secrets: Secrets ={ | |
| val s = cacheBuffer.last | |
| if (s.current.expired) rotateSecrets.last | |
| else s | |
| } | |
| /** | |
| *Checks if the secret is knows. Rotates if the secret is the new secret. | |
| **/ | |
| def find(f: Secret=>Boolean): Option[Secret] = { | |
| val lastSecrets = cacheBuffer.last |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # the Request protocol is simple: | |
| # | |
| # [Method] [Path] [Version] | |
| # Host: [Hostname] | |
| # <new line> | |
| # [Body] | |
| # <new lines> | |
| # | |
| # here is an example of GET (which has an empty body, because GET usually means retrieve something from the server): | |
| GET / HTTP/1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ServiceRouter1[ServiceIdentifier] => ... | |
| // Map[ServiceIdentifier, Httpx.Client] | |
| // (ServiceRouter / SessionIdRouter / IdentityRouter / AccessRouter) {(service, session, identity, access) => ...} | |
| // | |
| // ServiceRouter2[UpstreamService] | |
| // case class UpstreamService(id: ServiceIdentifier) { | |
| // val service = Httpx.newClient() | |
| // val endpoint = authFilterChain andThen service | |
| // } | |
| // authFilterChain = SessionIdFilter andThen IdentityFilter andThen ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| service(req) handle { | |
| case AccessDenied => ??? | |
| case SessionStoreError(msg) => ??? | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.twitter.finagle.memcached | |
| case object FailingMock extends memcached.MockClient { | |
| override def add(key: String, flags: Int, expiry: Time, value: Buf): Future[Boolean] = | |
| Future.exception(new Exception("oopsie")) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object SecretEncoder { | |
| import io.circe._ | |
| import io.circe.generic.semiauto._ | |
| /** | |
| * Helper method for creating new [[com.lookout.borderpatrol.sessionx.SecretEncoder SecretEncoder]] instances | |
| */ | |
| def apply[A](f: Secret => A, g: A => Try[Secret]): SecretEncoder[A] = | |
| new SecretEncoder[A] { | |
| def encode(secret: Secret): A = f(secret) | |
| def decode(a: A): Try[Secret] = g(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| in/prepare-boot-drive-from-iso ~/Downloads/nixos-minimal-15.09.431.52a8811-x86_64-linux.iso /dev/disk2 | |
| This will replace all your data on /dev/disk2. Are you sure you want to proceed? (yes|no) yes | |
| Reading Master Boot Record (MBR : 0)… | |
| Reading NIXOS_ISO (Apple_ISO : 1)… | |
| .................................................................................................................................................. | |
| Reading (Type EF : 2)… | |
| ....................................................................................................................................................... | |
| Reading NIXOS_ISO (Apple_ISO : 3)… | |
| ............................................................................................................................................................. | |
| Elapsed Time: 3.591s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.twitter.app._ | |
| import java.net.InetSocketAddress | |
| object Main extends App { | |
| // set default values for this flag, if it isn't passed in at command line | |
| val memcachedF = flag("memcached", Seq(new InetSocketAddress(0)), "memcached addresses") | |
| // print out the current value of the memcached flag (at this point, it's just the default value) | |
| println(s"1. memcacheds from defaults: ${memcachedF()}") | |