-
Notifications
You must be signed in to change notification settings - Fork 556
/
model.go
54 lines (43 loc) · 1.2 KB
/
model.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
48
49
50
51
52
53
54
package authentik
import (
"fmt"
"net/url"
"strings"
"github.com/pkg/errors"
"github.com/versent/saml2aws/v2/pkg/creds"
)
type authentikContext struct {
loginDetails *creds.LoginDetails
samlResponse string
}
type authentikPayload struct {
Attrs map[string]string
Component string
Type string
HasPassowrdField bool `json:"password_fields"`
RedirectTo string `json:"to"`
Errors map[string][]map[string]string `json:"response_errors"`
}
func (ctx *authentikContext) updateURL(s string) error {
if strings.Index(s, "/") == 0 {
u, err := url.Parse(ctx.loginDetails.URL)
if err != nil {
return errors.New("Invalid url")
}
s = fmt.Sprintf("%s://%s%s", u.Scheme, u.Host, s)
}
ctx.loginDetails.URL = s
return nil
}
func (ctx *authentikContext) setSAMLResponse(val string) {
ctx.samlResponse = val
}
func (payload *authentikPayload) isTypeNative() bool {
return payload.Type == "native"
}
func (payload *authentikPayload) isTypeRedirect() bool {
return payload.Type == "redirect"
}
func (payload *authentikPayload) isComponentStageAutosubmit() bool {
return payload.Component == "ak-stage-autosubmit"
}