| 
									
										
										
										
											2024-12-13 17:46:27 +08:00
										 |  |  | package setting | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type AnonymousSettings struct { | 
					
						
							|  |  |  | 	Enabled     bool | 
					
						
							|  |  |  | 	OrgName     string | 
					
						
							|  |  |  | 	OrgRole     string | 
					
						
							|  |  |  | 	HideVersion bool | 
					
						
							|  |  |  | 	DeviceLimit int64 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (cfg *Cfg) readAnonymousSettings() { | 
					
						
							|  |  |  | 	anonSection := cfg.Raw.Section("auth.anonymous") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	anonSettings := AnonymousSettings{} | 
					
						
							|  |  |  | 	anonSettings.Enabled = anonSection.Key("enabled").MustBool(false) | 
					
						
							|  |  |  | 	anonSettings.OrgName = valueAsString(anonSection, "org_name", "") | 
					
						
							| 
									
										
										
										
											2025-02-27 23:34:15 +08:00
										 |  |  | 	// Deprecated:
 | 
					
						
							|  |  |  | 	// only viewer role is supported
 | 
					
						
							| 
									
										
										
										
											2024-12-13 17:46:27 +08:00
										 |  |  | 	anonSettings.OrgRole = valueAsString(anonSection, "org_role", "") | 
					
						
							| 
									
										
										
										
											2025-02-27 23:34:15 +08:00
										 |  |  | 	if anonSettings.OrgRole != "Viewer" { | 
					
						
							|  |  |  | 		cfg.Logger.Warn("auth.anonymous.org_role is deprecated, only viewer role is supported") | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-12-13 17:46:27 +08:00
										 |  |  | 	anonSettings.HideVersion = anonSection.Key("hide_version").MustBool(false) | 
					
						
							|  |  |  | 	anonSettings.DeviceLimit = anonSection.Key("device_limit").MustInt64(0) | 
					
						
							|  |  |  | 	cfg.Anonymous = anonSettings | 
					
						
							|  |  |  | } |