-
Notifications
You must be signed in to change notification settings - Fork 100
/
Auth.scala
49 lines (41 loc) · 1.23 KB
/
Auth.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Copyright 2018-2022 OVO Energy Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
package fs2.kafka.vulcan
/**
* The available options for [[SchemaRegistryClientSettings#withAuth]].
*
* Available options include:<br>
* - [[Auth.Basic]] to authenticate with username and password,<br>
* - [[Auth.Bearer]] to authenticate with an authentication token,<br>
* - [[Auth.None]] to not provide any authentication details.
*/
sealed abstract class Auth
object Auth {
private[vulcan] final case class BasicAuth(username: String, password: String) extends Auth {
override def toString: String = s"Basic($username)"
}
private[vulcan] final case class BearerAuth(token: String) extends Auth {
override def toString: String = "Bearer"
}
private[vulcan] case object NoAuth extends Auth {
override def toString: String = "None"
}
/**
* Option to authenticate with username and password.
*/
def Basic(username: String, password: String): Auth =
BasicAuth(username, password)
/**
* Option to authenticate with an authentication token.
*/
def Bearer(token: String): Auth =
BearerAuth(token)
/**
* Option to not provide any authentication details.
*/
val None: Auth =
NoAuth
}