Last active
February 11, 2019 18:44
-
-
Save wendelicious/16b227d704b0bd87a760125f7806b89d to your computer and use it in GitHub Desktop.
Create Guice Injector using a Security Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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(); | |
} |
where does the servletContext
come from in .build(servletContext)
?
servletContext
is not needed in .build() you should use .getServletContext()
in the AppSecurityModule.
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).
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
backToTheDrawingBoard
we don't like the .and() after .infusionsoftId()
ps... anon should die because abbreviations are evil and we talked about .anonymous().path(...)