auth
2014-09-01
auth/config.go.old
Deprecate old implementations. Let's remove all of the osin stuff altogether, in favour of a more testable, unit-based approach. Leave all the old files around, for easy reference, but add the .old suffix so the go tools don't pick them up.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config.go.old Mon Sep 01 09:13:52 2014 -0400 1.3 @@ -0,0 +1,79 @@ 1.4 +package auth 1.5 + 1.6 +import "time" 1.7 + 1.8 +// AllowedAuthorizeType is a collection of allowed auth request types 1.9 +type AllowedAuthorizeType []AuthorizeRequestType 1.10 + 1.11 +// Exists returns true if the auth type exists in the list 1.12 +func (t AllowedAuthorizeType) Exists(rt AuthorizeRequestType) bool { 1.13 + for _, k := range t { 1.14 + if k == rt { 1.15 + return true 1.16 + } 1.17 + } 1.18 + return false 1.19 +} 1.20 + 1.21 +// AllowedAccessType is a collection of allowed access request types 1.22 +type AllowedAccessType []GrantType 1.23 + 1.24 +// Exists returns true if the access type exists in the list 1.25 +func (t AllowedAccessType) Exists(rt GrantType) bool { 1.26 + for _, k := range t { 1.27 + if k == rt { 1.28 + return true 1.29 + } 1.30 + } 1.31 + return false 1.32 +} 1.33 + 1.34 +// ServerConfig contains server configuration information 1.35 +type ServerConfig struct { 1.36 + // Authorization token expiration in seconds (default 5 minutes) 1.37 + AuthorizationExpiration int32 1.38 + 1.39 + // Access token expiration in seconds (default 1 hour) 1.40 + AccessExpiration int32 1.41 + 1.42 + // Token type to return 1.43 + TokenType string 1.44 + 1.45 + // List of allowed authorize types (only CodeAuthRT by default) 1.46 + AllowedAuthorizeTypes AllowedAuthorizeType 1.47 + 1.48 + // List of allowed access types (only AUTHORIZATION_CodeAuthRT by default) 1.49 + AllowedAccessTypes AllowedAccessType 1.50 + 1.51 + // HTTP status code to return for errors - default 200 1.52 + // Only used if response was created from server 1.53 + ErrorStatusCode int 1.54 + 1.55 + // If true allows client secret also in params, else only in 1.56 + // Authorization header - default false 1.57 + AllowClientSecretInParams bool 1.58 + 1.59 + // If true allows access request using GET, else only POST - default false 1.60 + AllowGetAccessRequest bool 1.61 + 1.62 + // The base path of documentation 1.63 + DocumentationDomain string 1.64 + 1.65 + SessionLength time.Duration 1.66 + RequestIPHeader string 1.67 + LoginRedirectDomain string 1.68 +} 1.69 + 1.70 +// NewServerConfig returns a new ServerConfig with default configuration 1.71 +func NewServerConfig() ServerConfig { 1.72 + return ServerConfig{ 1.73 + AuthorizationExpiration: 250, 1.74 + AccessExpiration: 3600, 1.75 + TokenType: "bearer", 1.76 + AllowedAuthorizeTypes: AllowedAuthorizeType{CodeAuthRT}, 1.77 + AllowedAccessTypes: AllowedAccessType{AuthorizationCodeGrant}, 1.78 + ErrorStatusCode: 200, 1.79 + AllowClientSecretInParams: false, 1.80 + AllowGetAccessRequest: false, 1.81 + } 1.82 +}