Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdedetrich/censored-raw-header
A RawHeader which can be used for akka-http that allows you to censor the .toString method
https://github.com/mdedetrich/censored-raw-header
actors akka akka-http http logging oauth2 token
Last synced: 26 days ago
JSON representation
A RawHeader which can be used for akka-http that allows you to censor the .toString method
- Host: GitHub
- URL: https://github.com/mdedetrich/censored-raw-header
- Owner: mdedetrich
- License: other
- Created: 2017-05-23T15:28:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-15T14:01:01.000Z (over 3 years ago)
- Last Synced: 2024-05-02T02:29:36.056Z (6 months ago)
- Topics: actors, akka, akka-http, http, logging, oauth2, token
- Language: Scala
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://img.shields.io/github/workflow/status/mdedetrich/censored-raw-header/Continuous%20Integration.svg)](https://github.com/mdedetrich/censored-raw-header/actions)
[![Latest version](https://index.scala-lang.org/mdedetrich/censored-raw-header/censored-raw-header/latest.svg?color=orange)](https://index.scala-lang.org/mdedetrich/censored-raw-header)
[![BSD License](https://img.shields.io/badge/license-BSD-green.svg)](https://opensource.org/licenses/BSD-2-Clause)## Censored Raw Header
Censored raw header is a simple implementation of `RawHeader` which allows you to provide
a custom `.toString` method. This is useful when it comes to censoring log output of headers of
sensitive information, such as OAuth2 tokens.## Usage
Put this into your `build.sbt`
```scala
libraryDependencies ++= Seq(
"org.mdedetrich" %% "censored-raw-header" % "0.7.0"
)
```Then simply created your own custom `CensoredRawHeader`, i.e. if you want to store an OAuth2
token with implicit flow you might do the following```scala
import akka.http.scaladsl.model.headers.CensoredRawHeaderval token: String = ??? // Some Token
CensoredRawHeader("Authorization",
s"Bearer $token",
s"Bearer ${token.take(3)}...${token.takeRight(3)}")
```This means that when someone accesses the raw value from within the `CensoredRawHeader` they will
get the actual value, however if they call `.toString` on the `CensoredRawHeader` (or any data
structure containing the `CensoredRawHeader`) it will print the first 3 characters of the token, then `...` and then
the last 3 values of the token