Skip to content

Commit c281025

Browse files
committed
Add UsernamePassAuth
This type of auth isn't/shouldn't be used very much. However, it is still useful for things like the initial creating of an access token.
1 parent c6e69bb commit c281025

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/utils/auth.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44

55
abstract type Authorization end
66

7+
# TODO: SecureString on 0.7
78
struct OAuth2 <: Authorization
89
token::String
910
end
1011

12+
struct UsernamePassAuth <: Authorization
13+
username::String
14+
password::String
15+
end
16+
1117
struct AnonymousAuth <: Authorization end
1218

1319
struct JWTAuth <: Authorization
@@ -68,6 +74,10 @@ function authenticate_headers!(headers, auth::JWTAuth)
6874
return headers
6975
end
7076

77+
function authenticate_headers!(headers, auth::UsernamePassAuth)
78+
headers["Authorization"] = "Basic $(base64encode(string(auth.username, ':', auth.password)))"
79+
return headers
80+
end
7181

7282
###################
7383
# Pretty Printing #

0 commit comments

Comments
 (0)