-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to latest Play version - addresses #92
Moves session storage to cookie instead of cache.
- Loading branch information
Showing
4 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package auth; | ||
|
||
import com.nimbusds.oauth2.sdk.pkce.CodeVerifier; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CustomCodeVerifier extends CodeVerifier implements Serializable { | ||
public CustomCodeVerifier(String value) { | ||
super(value); | ||
} | ||
|
||
public static CustomCodeVerifier from(CodeVerifier codeVerifier) { | ||
return new CustomCodeVerifier(codeVerifier.getValue()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package auth; | ||
|
||
import com.nimbusds.oauth2.sdk.pkce.CodeVerifier; | ||
import org.pac4j.play.PlayWebContext; | ||
import org.pac4j.play.store.NoOpDataEncrypter; | ||
import org.pac4j.play.store.PlayCookieSessionStore; | ||
|
||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class CustomCookieSessionStore extends PlayCookieSessionStore { | ||
|
||
public CustomCookieSessionStore() { | ||
super(new NoOpDataEncrypter()); | ||
} | ||
|
||
@Override | ||
public void set(PlayWebContext context, String key, Object value) { | ||
Object cleanedValue = value; | ||
if (key.endsWith("$codeVerifierSessionParameter") && value instanceof CodeVerifier) { | ||
cleanedValue = CustomCodeVerifier.from((CodeVerifier) value); | ||
} | ||
|
||
super.set(context, key, cleanedValue); | ||
} | ||
} |
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
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