Skip to content

Commit b89fb84

Browse files
committed
prepare v0.1.0
1 parent d22f0aa commit b89fb84

File tree

30 files changed

+1006
-1
lines changed

30 files changed

+1006
-1
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
*.class
22
*.log
3+
.idea
4+
*.iml
5+
sbt.json
6+
target
7+
.metals

.scalafmt.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version=3.0.2
2+
style = defaultWithAlign
3+
align.openParenCallSite = false
4+
align.openParenDefnSite = false
5+
align.tokens = [{code = "->"}, {code = "<-"}, {code = "=>", owner = "Case"}]
6+
continuationIndent.callSite = 2
7+
continuationIndent.defnSite = 2
8+
danglingParentheses = true
9+
indentOperator = spray
10+
maxColumn = 100
11+
indentOperator.preset = "spray"
12+
danglingParentheses.preset = true
13+
project.excludeFilters = [".*\\.sbt"]
14+
rewrite.rules = [RedundantParens, SortImports]
15+
spaces.inImportCurlyBraces = false
16+
unindentTopLevelOperators = true
17+
project.git = true

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
# generic-session-api
1+
<!---
2+
This file is auto-generate by a github hook please modify r.md if you don't want to loose your work
3+
-->
4+
![Build Status](https://github.com/SOFTNETWORK-APP/generic-session-api/workflows/Build/badge.svg)
5+
[![codecov](https://codecov.io/gh/SOFTNETWORK-APP/generic-session-api/branch/main/graph/badge.svg)](https://codecov.io/gh/SOFTNETWORK-APP/generic-session-api/)
6+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9df226d8704d4a1d9b89e6d135b164a2)](https://www.codacy.com/gh/SOFTNETWORK-APP/generic-session-api/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=SOFTNETWORK-APP/generic-session-api&amp;utm_campaign=Badge_Grade)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8+
9+
# generic-session-api

build.sbt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import sbt.Resolver
2+
3+
import Common._
4+
import app.softnetwork.sbt.build._
5+
6+
/////////////////////////////////
7+
// Defaults
8+
/////////////////////////////////
9+
10+
app.softnetwork.sbt.build.Publication.settings
11+
12+
/////////////////////////////////
13+
// Useful aliases
14+
/////////////////////////////////
15+
16+
addCommandAlias("cd", "project") // navigate the projects
17+
18+
addCommandAlias("cc", ";clean;compile") // clean and compile
19+
20+
addCommandAlias("pl", ";clean;publishLocal") // clean and publish locally
21+
22+
addCommandAlias("pr", ";clean;publish") // clean and publish globally
23+
24+
addCommandAlias("pld", ";clean;local:publishLocal;dockerComposeUp") // clean and publish/launch the docker environment
25+
26+
addCommandAlias("dct", ";dockerComposeTest") // navigate the projects
27+
28+
ThisBuild / shellPrompt := prompt
29+
30+
ThisBuild / organization := "app.softnetwork"
31+
32+
name := "session"
33+
34+
ThisBuild / version := "0.1.0"
35+
36+
ThisBuild / scalaVersion := "2.12.15"
37+
38+
ThisBuild / scalacOptions ++= Seq("-deprecation", "-feature", "-target:jvm-1.8")
39+
40+
ThisBuild / javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
41+
42+
ThisBuild / resolvers ++= Seq(
43+
"Softnetwork Server" at "https://softnetwork.jfrog.io/artifactory/releases/",
44+
"Maven Central Server" at "https://repo1.maven.org/maven2",
45+
"Typesafe Server" at "https://repo.typesafe.com/typesafe/releases"
46+
)
47+
48+
ThisBuild / versionScheme := Some("early-semver")
49+
50+
val scalatest = Seq(
51+
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
52+
)
53+
54+
ThisBuild / libraryDependencies ++= Seq(
55+
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf",
56+
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.1"
57+
) ++ scalatest
58+
59+
Test / parallelExecution := false
60+
61+
lazy val common = project.in(file("common"))
62+
.configs(IntegrationTest)
63+
.settings(Defaults.itSettings)
64+
.enablePlugins(AkkaGrpcPlugin)
65+
66+
lazy val core = project.in(file("core"))
67+
.configs(IntegrationTest)
68+
.settings(Defaults.itSettings, BuildInfoSettings.settings)
69+
.enablePlugins(BuildInfoPlugin)
70+
.dependsOn(
71+
common % "compile->compile;test->test;it->it"
72+
)
73+
74+
lazy val testkit = project.in(file("testkit"))
75+
.configs(IntegrationTest)
76+
.settings(Defaults.itSettings)
77+
.enablePlugins(BuildInfoPlugin)
78+
.dependsOn(
79+
core % "compile->compile;test->test;it->it"
80+
)
81+
82+
lazy val root = project.in(file("."))
83+
.aggregate(common, core, testkit)
84+
.configs(IntegrationTest)
85+
.settings(Defaults.itSettings)

common/build.sbt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import app.softnetwork.sbt.build._
2+
3+
organization := "app.softnetwork.session"
4+
5+
name := "session-common"
6+
7+
val akkaHttpSession: Seq[ModuleID] = Seq(
8+
"com.softwaremill.akka-http-session" %% "core" % Versions.akkaHttpSession,
9+
"com.softwaremill.akka-http-session" %% "jwt" % Versions.akkaHttpSession
10+
)
11+
12+
libraryDependencies ++= Seq(
13+
"app.softnetwork.api" %% "generic-server-api" % Versions.server,
14+
"app.softnetwork.protobuf" %% "scalapb-extensions" % "0.1.5"
15+
) ++ akkaHttpSession
16+
17+
Compile / unmanagedResourceDirectories += baseDirectory.value / "src/main/protobuf"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
syntax = "proto3";
2+
3+
import "scalapb/scalapb.proto";
4+
5+
package org.softnetwork.session.model;
6+
7+
option (scalapb.options) = {
8+
single_file: true
9+
flat_package: true
10+
import: "app.softnetwork.persistence.model._"
11+
import: "app.softnetwork.serialization._"
12+
import: "app.softnetwork.session.model._"
13+
preserve_unknown_fields: false
14+
};
15+
16+
message Session {
17+
option (scalapb.message).extends = "SessionData";
18+
option (scalapb.message).extends = "SessionDecorator";
19+
option (scalapb.message).companion_extends = "SessionCompanion";
20+
map<string, string> data = 1 [(scalapb.field).map_type="collection.mutable.Map"];
21+
bool refreshable = 2;
22+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
akka {
2+
http {
3+
session{
4+
server-secret = ";C5/n}5K&/AX<8SO`nNuGl*^>w[hOD7uuhFLt*y`QNTL8vqHDK9te+Pd+.,,'njk"
5+
server-secret = ${?HTTP_SESSION_SERVER_SECRET}
6+
7+
cookie {
8+
name = "_sessiondata"
9+
name = ${?HTTP_SESSION_COOKIE_NAME}
10+
domain = none
11+
domain = ${?HTTP_SESSION_COOKIE_DOMAIN}
12+
path = /
13+
path = ${?HTTP_SESSION_COOKIE_PATH}
14+
secure = false
15+
secure = ${?HTTP_SESSION_COOKIE_SECURE}
16+
http-only = true
17+
http-only = ${?HTTP_SESSION_COOKIE_HTTP_ONLY}
18+
}
19+
20+
encrypt-data = true
21+
encrypt-data = ${?HTTP_SESSION_ENCRYPT_DATA}
22+
23+
csrf {
24+
cookie {
25+
secure = false
26+
secure = ${?HTTP_SESSION_CSRF_COOKIE_SECURE}
27+
}
28+
}
29+
30+
refresh-token {
31+
cookie {
32+
secure = false
33+
secure = ${?HTTP_SESSION_REFRESH_TOKEN_COOKIE_SECURE}
34+
}
35+
}
36+
}
37+
}
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package app.softnetwork.session.config
2+
3+
/** Created by smanciot on 21/03/2018.
4+
*/
5+
import com.typesafe.config.{Config, ConfigFactory}
6+
import configs.ConfigError
7+
8+
object Settings {
9+
lazy val config: Config = ConfigFactory.load()
10+
11+
def configErrorsToException(err: ConfigError) =
12+
new IllegalStateException(err.entries.map(_.messageWithPath).mkString(","))
13+
14+
object Session {
15+
val CookieName: String = config getString "akka.http.session.cookie.name"
16+
17+
val CookieSecret: String = config getString "akka.http.session.server-secret"
18+
19+
require(CookieName.nonEmpty, "akka.http.session.cookie.name must be non-empty")
20+
require(CookieSecret.nonEmpty, "akka.http.session.server-secret must be non-empty")
21+
}
22+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package app.softnetwork.session
2+
3+
import com.softwaremill.session.{RefreshTokenData, RefreshTokenLookupResult}
4+
import app.softnetwork.persistence.message.{CommandResult, EntityCommand, Event}
5+
6+
/** Created by smanciot on 16/05/2020.
7+
*/
8+
package object message {
9+
10+
/** Commands * */
11+
12+
sealed trait RefreshTokenCommand extends EntityCommand {
13+
def selector: String
14+
override val id: String = selector
15+
}
16+
17+
@SerialVersionUID(0L)
18+
case class LookupRefreshToken(selector: String) extends RefreshTokenCommand
19+
20+
@SerialVersionUID(0L)
21+
case class StoreRefreshToken[T](data: RefreshTokenData[T]) extends RefreshTokenCommand {
22+
override val selector: String = data.selector
23+
}
24+
25+
@SerialVersionUID(0L)
26+
case class RemoveRefreshToken(selector: String) extends RefreshTokenCommand
27+
28+
/** Commands Result * */
29+
30+
sealed trait RefreshTokenResult extends CommandResult
31+
32+
@SerialVersionUID(0L)
33+
case class LookupRefreshTokenResult[T](data: Option[RefreshTokenLookupResult[T]])
34+
extends RefreshTokenResult
35+
36+
sealed trait RefreshTokenEvent extends Event
37+
38+
@SerialVersionUID(0L)
39+
case class RefreshTokenStored[T](data: RefreshTokenData[T])
40+
extends RefreshTokenEvent
41+
with RefreshTokenResult
42+
43+
@SerialVersionUID(0L)
44+
case class RefreshTokenRemoved(selector: String) extends RefreshTokenEvent with RefreshTokenResult
45+
}

0 commit comments

Comments
 (0)