Skip to content

Instantly share code, notes, and snippets.

@wendelicious
Last active February 11, 2019 18:44
Show Gist options
  • Select an option

  • Save wendelicious/16b227d704b0bd87a760125f7806b89d to your computer and use it in GitHub Desktop.

Select an option

Save wendelicious/16b227d704b0bd87a760125f7806b89d to your computer and use it in GitHub Desktop.
Create Guice Injector using a Security Builder
@Override
protected Injector getInjector() {
return PancakesGuiceInjector.builder()
.addModule(new SuccessCenterApiModule())
.addModule(new LocalSuccessCenterApiModule(), DeploymentEnvironment.DEV)
.addModule(new GoogleCloudSuccessCenterApiModule(), DeploymentEnvironment.excludingEnvironments(DeploymentEnvironment.DEV))
.addModule(new SuccessCenterPolicyServletModule())
.addModule(
PancakesSecurity.module()
.anonymous()
.path("/public", "/public/**", "/**/public/**")
.path("/info", "/info/**")
.and()
.domain()
.accountId("OAuth Account Id from Google Console")
.secret("OAutch Account secret from Google Console")
.and()
.infusionsoftId()
.neverEverInMillionsOfYears(ross)
.forgetIt(ross)
.build(servletContext)
)
.build();
}
@frossbeamish

frossbeamish commented Aug 12, 2016

Copy link
Copy Markdown

backToTheDrawingBoard

we don't like the .and() after .infusionsoftId()

ps... anon should die because abbreviations are evil and we talked about .anonymous().path(...)

@acourtneybrown

Copy link
Copy Markdown

where does the servletContext come from in .build(servletContext) ?

@frossbeamish

Copy link
Copy Markdown

servletContext is not needed in .build() you should use .getServletContext() in the AppSecurityModule.

@wendelicious

wendelicious commented Aug 12, 2016

Copy link
Copy Markdown
Author

getInjector() is in the class that extends GuiceServletContextListener, so I'm getting it from public void contextInitialized(). However, Ross points out that I shouldn't need it here - the PancakesServletModule should install() the WebModule that extends ShiroWebModule.

I bet I'll get a bit further and find that he's right. And all will be better with the world. Worse case, it isn't too horrible as-is (but I do think we can do better).

@frossbeamish

Copy link
Copy Markdown

also i think

.neverEverInMillionsOfYears(ross)
.forgetIt(ross)

is superfluous

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