forked from openshift/osin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.go
86 lines (68 loc) · 1.81 KB
/
client.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
86
package osin
// Client information
type Client interface {
// Client id
GetId() string
// Client secret
GetSecret() string
// Base client uri
GetRedirectUri() string
// get client app name
GetAppName() string
// get image url
GetImageUrl() string
// External Client
IsExternal() bool
// Data to be passed to storage. Not used by the library.
GetUserData() interface{}
}
// ClientSecretMatcher is an optional interface clients can implement
// which allows them to be the one to determine if a secret matches.
// If a Client implements ClientSecretMatcher, the framework will never call GetSecret
type ClientSecretMatcher interface {
// SecretMatches returns true if the given secret matches
ClientSecretMatches(secret string) bool
}
// DefaultClient stores all data in struct variables
type DefaultClient struct {
Id string
Secret string
RedirectUri string
AppName string
ImageUrl string
External bool
UserData interface{}
}
func (d *DefaultClient) GetId() string {
return d.Id
}
func (d *DefaultClient) GetSecret() string {
return d.Secret
}
func (d *DefaultClient) GetRedirectUri() string {
return d.RedirectUri
}
func (d *DefaultClient) GetAppName() string {
return d.AppName
}
func (d *DefaultClient) GetImageUrl() string {
return d.ImageUrl
}
func (d *DefaultClient) IsExternal() bool {
return d.External
}
func (d *DefaultClient) GetUserData() interface{} {
return d.UserData
}
// Implement the ClientSecretMatcher interface
func (d *DefaultClient) ClientSecretMatches(secret string) bool {
return d.Secret == secret
}
func (d *DefaultClient) CopyFrom(client Client) {
d.Id = client.GetId()
d.Secret = client.GetSecret()
d.RedirectUri = client.GetRedirectUri()
d.AppName = client.GetAppName()
d.ImageUrl = client.GetImageUrl()
d.UserData = client.GetUserData()
}