auth

Paddy 2014-08-13 Parent:3423c552e249 Child:9fe684b33b3d

12:63e86d129238 Go to Latest

auth/config.go

Consistently handle context in client storage interface. Let's at least be consistent about passing or not passing context to the client storage interface. Most our methods don't take the context, so let's just remove it.

History
1 package auth
3 // AllowedAuthorizeType is a collection of allowed auth request types
4 type AllowedAuthorizeType []AuthorizeRequestType
6 // Exists returns true if the auth type exists in the list
7 func (t AllowedAuthorizeType) Exists(rt AuthorizeRequestType) bool {
8 for _, k := range t {
9 if k == rt {
10 return true
11 }
12 }
13 return false
14 }
16 // AllowedAccessType is a collection of allowed access request types
17 type AllowedAccessType []GrantType
19 // Exists returns true if the access type exists in the list
20 func (t AllowedAccessType) Exists(rt GrantType) bool {
21 for _, k := range t {
22 if k == rt {
23 return true
24 }
25 }
26 return false
27 }
29 // ServerConfig contains server configuration information
30 type ServerConfig struct {
31 // Authorization token expiration in seconds (default 5 minutes)
32 AuthorizationExpiration int32
34 // Access token expiration in seconds (default 1 hour)
35 AccessExpiration int32
37 // Token type to return
38 TokenType string
40 // List of allowed authorize types (only CodeAuthRT by default)
41 AllowedAuthorizeTypes AllowedAuthorizeType
43 // List of allowed access types (only AUTHORIZATION_CodeAuthRT by default)
44 AllowedAccessTypes AllowedAccessType
46 // HTTP status code to return for errors - default 200
47 // Only used if response was created from server
48 ErrorStatusCode int
50 // If true allows client secret also in params, else only in
51 // Authorization header - default false
52 AllowClientSecretInParams bool
54 // If true allows access request using GET, else only POST - default false
55 AllowGetAccessRequest bool
57 // The base path of documentation
58 DocumentationDomain string
59 }
61 // NewServerConfig returns a new ServerConfig with default configuration
62 func NewServerConfig() ServerConfig {
63 return ServerConfig{
64 AuthorizationExpiration: 250,
65 AccessExpiration: 3600,
66 TokenType: "bearer",
67 AllowedAuthorizeTypes: AllowedAuthorizeType{CodeAuthRT},
68 AllowedAccessTypes: AllowedAccessType{AuthorizationCodeGrant},
69 ErrorStatusCode: 200,
70 AllowClientSecretInParams: false,
71 AllowGetAccessRequest: false,
72 }
73 }