-
Notifications
You must be signed in to change notification settings - Fork 0
/
hid.go
34 lines (28 loc) · 971 Bytes
/
hid.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
package hid
import (
"net/http"
"os"
"github.com/hafslundnett/hn-config-lib-go/service"
)
// IDManager represents a service that is able to provide clients with authoriation tokens with the GetToken function,
// and is capable of authorizing these incoming tokens for the server with the AuthorizeRequest function.
type IDManager interface {
GetToken(user, secret string) (token *Token, err error)
AuthorizeRequest(r *http.Request, audience, scope string) error
}
// HID holds the configurations and keys neccessary to communicate with the HID service.
type HID struct {
Config
PKS
}
// New creates a new HID, performs neccessary setup, and returns it as an IDManager
func New() (IDManager, error) {
hid := new(HID)
cert := os.Getenv(envars["cert"])
err := service.Setup(hid, cert)
return hid, err
}
// ConnectToServer performs neccessary setup for connections to the external HID service
func (hid *HID) ConnectToServer() error {
return hid.newPKS()
}