-
Notifications
You must be signed in to change notification settings - Fork 0
/
cas.go
85 lines (71 loc) · 2.3 KB
/
cas.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package cashew
import (
"net/http"
"net/url"
)
// Deliver delivery interface
type Deliver interface {
Mount()
}
// Executor is an interface as cli processor
type Executor interface {
Execute()
}
// TicketUseCase define behaviors about finding and generating ticket
type TicketUseCase interface {
Find(id string) (*Ticket, error)
NewLogin(r *http.Request) (*Ticket, error)
NewProxyGranting(r *http.Request, callbackURL *url.URL, st *Ticket) (*Ticket, error)
NewService(r *http.Request, service *url.URL, tgt *Ticket, primary bool) (*Ticket, error)
NewGranting(r *http.Request, username string, extraAttributes interface{}) (*Ticket, error)
NewProxy(r *http.Request, service string, grantedBy *Ticket) (*Ticket, error)
Consume(*Ticket) error
}
// TerminateUseCase define behaviors for terminate ticket
type TerminateUseCase interface {
Terminate(*Ticket) error
}
// LogoutUseCase define behaviors for logout by tgt
type LogoutUseCase interface {
Terminate(*Ticket) error
}
// ValidateUseCase define behaviors for validation
type ValidateUseCase interface {
ValidateLogin(ticket *Ticket) error
ValidateGranting(ticket *Ticket) error
ValidateService(ticket *Ticket, service *url.URL, renew bool) error
ValidateProxy(ticket *Ticket, service *url.URL) error
ValidateProxyGranting(ticket *Ticket) error
}
// TicketRepository repository for ticket
type TicketRepository interface {
Find(id string) (*Ticket, error)
Delete(*Ticket) error
DeleteRelatedTicket(*Ticket) error
Create(*Ticket) error
Consume(*Ticket) error
}
// IDRepository is an interface to issue an ID
type IDRepository interface {
Issue(t TicketType) string
}
// ClientHostNameRepository is an interface to find real-ip/hostname
type ClientHostNameRepository interface {
Ensure(r *http.Request) string
}
// ProxyCallBackRepository is an interface to dial proxy-callback-url
type ProxyCallBackRepository interface {
Dial(u *url.URL, pgt, iou string) error
}
// AuthenticateUseCase interface for authenticate
type AuthenticateUseCase interface {
Authenticate(id, pass string) (map[string]interface{}, error)
}
// ExpirationUseCase interface for expiration check
type ExpirationUseCase interface {
RevokeAll() error
}
// ExpirationRepository repository interface that find all expired items
type ExpirationRepository interface {
FindAll() ([]*Ticket, error)
}