...
1
21
22 package fosite
23
24 import jose "gopkg.in/square/go-jose.v2"
25
26
27 type Client interface {
28
29 GetID() string
30
31
32 GetHashedSecret() []byte
33
34
35 GetRedirectURIs() []string
36
37
38 GetGrantTypes() Arguments
39
40
41
42
43 GetResponseTypes() Arguments
44
45
46 GetScopes() Arguments
47
48
49 IsPublic() bool
50
51
52 GetAudience() Arguments
53 }
54
55
56 type ClientWithSecretRotation interface {
57 Client
58
59 GetRotatedHashes() [][]byte
60 }
61
62
63 type OpenIDConnectClient interface {
64
65
66
67
68 GetRequestURIs() []string
69
70
71 GetJSONWebKeys() *jose.JSONWebKeySet
72
73
74
75 GetJSONWebKeysURI() string
76
77
78
79 GetRequestObjectSigningAlgorithm() string
80
81
82
83 GetTokenEndpointAuthMethod() string
84
85
86
87 GetTokenEndpointAuthSigningAlgorithm() string
88 }
89
90
91 type ResponseModeClient interface {
92
93 GetResponseModes() []ResponseModeType
94 }
95
96
97 type DefaultClient struct {
98 ID string `json:"id"`
99 Secret []byte `json:"client_secret,omitempty"`
100 RotatedSecrets [][]byte `json:"rotated_secrets,omitempty"`
101 RedirectURIs []string `json:"redirect_uris"`
102 GrantTypes []string `json:"grant_types"`
103 ResponseTypes []string `json:"response_types"`
104 Scopes []string `json:"scopes"`
105 Audience []string `json:"audience"`
106 Public bool `json:"public"`
107 }
108
109 type DefaultOpenIDConnectClient struct {
110 *DefaultClient
111 JSONWebKeysURI string `json:"jwks_uri"`
112 JSONWebKeys *jose.JSONWebKeySet `json:"jwks"`
113 TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
114 RequestURIs []string `json:"request_uris"`
115 RequestObjectSigningAlgorithm string `json:"request_object_signing_alg"`
116 TokenEndpointAuthSigningAlgorithm string `json:"token_endpoint_auth_signing_alg"`
117 }
118
119 type DefaultResponseModeClient struct {
120 *DefaultClient
121 ResponseModes []ResponseModeType `json:"response_modes"`
122 }
123
124 func (c *DefaultClient) GetID() string {
125 return c.ID
126 }
127
128 func (c *DefaultClient) IsPublic() bool {
129 return c.Public
130 }
131
132 func (c *DefaultClient) GetAudience() Arguments {
133 return c.Audience
134 }
135
136 func (c *DefaultClient) GetRedirectURIs() []string {
137 return c.RedirectURIs
138 }
139
140 func (c *DefaultClient) GetHashedSecret() []byte {
141 return c.Secret
142 }
143
144 func (c *DefaultClient) GetRotatedHashes() [][]byte {
145 return c.RotatedSecrets
146 }
147
148 func (c *DefaultClient) GetScopes() Arguments {
149 return c.Scopes
150 }
151
152 func (c *DefaultClient) GetGrantTypes() Arguments {
153
154
155
156
157
158 if len(c.GrantTypes) == 0 {
159 return Arguments{"authorization_code"}
160 }
161 return Arguments(c.GrantTypes)
162 }
163
164 func (c *DefaultClient) GetResponseTypes() Arguments {
165
166
167
168
169
170 if len(c.ResponseTypes) == 0 {
171 return Arguments{"code"}
172 }
173 return Arguments(c.ResponseTypes)
174 }
175
176 func (c *DefaultOpenIDConnectClient) GetJSONWebKeysURI() string {
177 return c.JSONWebKeysURI
178 }
179
180 func (c *DefaultOpenIDConnectClient) GetJSONWebKeys() *jose.JSONWebKeySet {
181 return c.JSONWebKeys
182 }
183
184 func (c *DefaultOpenIDConnectClient) GetTokenEndpointAuthSigningAlgorithm() string {
185 if c.TokenEndpointAuthSigningAlgorithm == "" {
186 return "RS256"
187 } else {
188 return c.TokenEndpointAuthSigningAlgorithm
189 }
190 }
191
192 func (c *DefaultOpenIDConnectClient) GetRequestObjectSigningAlgorithm() string {
193 return c.RequestObjectSigningAlgorithm
194 }
195
196 func (c *DefaultOpenIDConnectClient) GetTokenEndpointAuthMethod() string {
197 return c.TokenEndpointAuthMethod
198 }
199
200 func (c *DefaultOpenIDConnectClient) GetRequestURIs() []string {
201 return c.RequestURIs
202 }
203
204 func (c *DefaultResponseModeClient) GetResponseModes() []ResponseModeType {
205 return c.ResponseModes
206 }
207
View as plain text