-
Notifications
You must be signed in to change notification settings - Fork 3
/
auth.go
38 lines (35 loc) 路 928 Bytes
/
auth.go
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
package main
import (
"context"
"errors"
"github.com/spf13/viper"
"github.com/vx-labs/wasp/rpc"
"github.com/vx-labs/wasp/wasp/auth"
)
func getAuthHandler(ctx context.Context, rpcDialer rpc.Dialer, config *viper.Viper) (auth.AuthenticationHandler, error) {
provider := config.GetString("authentication-provider")
switch provider {
case "none":
return auth.NoopHandler(), nil
case "static":
return auth.StaticHandler(
config.GetString("authentication-provider-static-username"),
config.GetString("authentication-provider-static-password"),
)
case "file":
return auth.FileHandler(
config.GetString("authentication-provider-file-path"),
)
case "grpc":
host := config.GetString("authentication-provider-grpc-address")
conn, err := rpcDialer(host)
if err != nil {
return nil, err
}
return auth.GRPC(
conn,
)
default:
return nil, errors.New("unknown authentication provided")
}
}