-
Notifications
You must be signed in to change notification settings - Fork 0
/
saml.go
47 lines (37 loc) · 1.06 KB
/
saml.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
39
40
41
42
43
44
45
46
47
package credentials
import (
"fmt"
"path"
"github.com/versent/saml2aws/pkg/creds"
)
// LookupCredentials lookup an existing set of credentials and validate it.
func LookupCredentials(loginDetails *creds.LoginDetails, provider string) error {
username, password, err := CurrentHelper.Get(fmt.Sprintf("%s", loginDetails.URL))
if err != nil {
return err
}
loginDetails.Username = username
loginDetails.Password = password
if provider == "OneLogin" {
id, secret, err := CurrentHelper.Get(path.Join(loginDetails.URL, "/auth/oauth2/v2/token"))
if err != nil {
return err
}
loginDetails.ClientID = id
loginDetails.ClientSecret = secret
}
return nil
}
// SaveCredentials save the user credentials.
func SaveCredentials(url, username, password string) error {
creds := &Credentials{
ServerURL: fmt.Sprintf("%s", url),
Username: username,
Secret: password,
}
return CurrentHelper.Add(creds)
}
// SupportsStorage will return true or false if storage is supported.
func SupportsStorage() bool {
return CurrentHelper.SupportsCredentialStorage()
}