Skip to content

Instantly share code, notes, and snippets.

@philippeback
Created June 20, 2017 14:03
Show Gist options
  • Save philippeback/267f95b1e5716339f9fc22824b438111 to your computer and use it in GitHub Desktop.
Save philippeback/267f95b1e5716339f9fc22824b438111 to your computer and use it in GitHub Desktop.
|application secureApp removeHandlers secureTools handlersToKeep filesHandlerName toolHandlerNames keepDevTools |
secureApp := true.
removeHandlers := true.
secureTools := true.
keepDevTools := false.
Author fullName: 'PhilippeBack'.
" =========== Patches start ======== "
#(
'Somefileout.st'
) do: [ :patch |
Transcript show: ' Patching with: ', patch; cr.
(FileLocator imageDirectory / 'patches' / patch) readStreamDo: [ :s | s fileIn ].
Transcript show: ' Patched.', patch; cr.
].
" =========== Patches end ======== "
filesHandlerName := 'files'.
toolHandlerNames := { 'tools'. 'status'. 'browse' } asOrderedCollection.
handlersToKeep := toolHandlerNames copy add: filesHandlerName; yourself.
"Set Jira Account"
JiraSettings
jiraUrl: '<something>.atlassian.net';
jiraUsername: '<someuser>';
jiraPassword: '<somepassord>'.
"Remove all handlers not for keeps"
(WADispatcher default handlers keys difference: handlersToKeep)
do:[ :name | WAAdmin unregister:name ].
"Dev tools or not"
keepDevTools ifFalse: [
WAAdmin applicationDefaults
removeParent: WADevelopmentConfiguration instance ].
"
Register application handler
and start the server on port 8082,
including serving static files
"
HOWebApplication declareApplicationAndStartServer.
"Secure app handler if needed"
secureApp ifTrue: [
application := WADispatcher default handlerAt: 'smartweb'.
application configuration addParent: WAAuthConfiguration instance.
application
preferenceAt: #login put: '<someweblogin>';
preferenceAt: #passwordHash put: (GRPlatform current secureHashFor: '<somewebpassword>').
application
addFilter: WAAuthenticationFilter new ].
"Secure other apps if needed - no need to secure files"
secureTools ifTrue: [
toolHandlerNames do: [ :toolHandlerName |
application := WADispatcher default handlerAt: toolHandlerName.
application configuration addParent: WAAuthConfiguration instance.
application
preferenceAt: #login put: 'admin';
preferenceAt: #passwordHash put: (GRPlatform current secureHashFor: '<someadminpassword>').
application
addFilter: WAAuthenticationFilter new
]
].
@philippeback
Copy link
Author

With the declareApplicationAndStartServer doing something like:

declareApplicationAndStartServer
	<script>
	| adaptor |
	HOSmartWebApplication registerToDevelopment: self defaultAppUri.
	
	adaptor := ZnZincStaticServerAdaptor
		startOn: self defaultServerPort
		andServeFilesFrom: HOSmartWebApplication reportsDirectory pathString.
		
	adaptor default server maximumEntitySize: 150 * 1024 * 1024.

and

registerToDevelopment: aName
	| app |
	WAAdmin applicationDefaults
		addParent: WADevelopmentConfiguration instance.
	WAAdmin unregister: aName.
	app := WAAdmin register: self asApplicationAt: aName.
	app preferenceAt: #sessionClass put: HOCustomWebSession.
	app
		addLibrary: JQDeploymentLibrary;
		addLibrary: JQUiDeploymentLibrary;
		addLibrary: MDLLibrary.
	^ app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment