-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogout.go
49 lines (38 loc) · 1.05 KB
/
logout.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
package cwhydra
type Logout struct {
Api Api
}
type LogoutInterface interface {
Get(challenge string) (LogoutResponse, error)
Accept(challenge string) (string, error)
Reject(challenge string, request RejectRequest) (string, error)
}
func LogoutManager(a Api) Logout {
return Logout{
Api: a,
}
}
func (c Logout) Get(challenge string) (LogoutResponse, error) {
var res LogoutResponse
err := c.Api.Get("/oauth2/auth/requests/logout?logout_challenge="+challenge, &res)
if err != nil {
return res, err
}
return res, err
}
func (c Logout) Accept(challenge string) (string, error) {
var res Redirect
err := c.Api.Put("/oauth2/auth/requests/logout/accept?logout_challenge="+challenge, nil, &res)
if err != nil {
return res.RedirectTo, err
}
return res.RedirectTo, err
}
func (c Logout) Reject(challenge string, request RejectRequest) (string, error) {
var res Redirect
err := c.Api.Put("/oauth2/auth/requests/logout/reject?logout_challenge="+challenge, request, &res)
if err != nil {
return res.RedirectTo, err
}
return res.RedirectTo, err
}