Skip to content

Commit

Permalink
Add consent page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Jul 15, 2023
1 parent a6c9782 commit 745a123
Show file tree
Hide file tree
Showing 38 changed files with 653 additions and 700 deletions.
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ dependencies {
implementation(enforcedPlatform("com.vaadin:vaadin-bom:${vaadinVersion}"))
implementation(enforcedPlatform("io.quarkus.platform:quarkus-bom:${quarkusVersion}"))

implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.quarkus:quarkus-rest-client-reactive-jackson")
implementation("io.quarkus:quarkus-config-yaml")
implementation("io.quarkus:quarkus-hibernate-validator")
implementation("io.quarkus:quarkus-resteasy-reactive-qute")
implementation("io.quarkus:quarkus-resteasy-reactive-jackson")
implementation("io.quarkus:quarkus-hibernate-orm-panache-kotlin")
implementation("io.quarkus:quarkus-qute")
implementation("io.quarkus:quarkus-csrf-reactive")
implementation("io.quarkus:quarkus-jdbc-mariadb")
implementation("io.quarkus:quarkus-kotlin")
implementation("io.quarkus:quarkus-container-image-jib")
Expand Down
150 changes: 23 additions & 127 deletions frontend/themes/faforever/styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@import "theme-editor.css";
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css');

html {
--lumo-font-family: 'Source Sans Pro', sans-serif
--lumo-font-family: 'Source Sans Pro', sans-serif;
--lumo-primary-color: #ea2f10;
--lumo-primary-text-color: var(--lumo-primary-color);
}

.background {
Expand All @@ -15,16 +20,20 @@ html {
height: auto !important;
}

::part(input-field) {
background-color: white;
}

input {
outline: none;
}

.error {
text-align: center;
background-color: white;
border: 1px solid #ea2f10;
border: 1px solid var(--lumo-primary-color);
font-weight: bold;
color: #ea2f10;
color: var(--lumo-primary-color);
padding: 0.5rem;
margin: 1rem 0;
}
Expand Down Expand Up @@ -73,16 +82,10 @@ header {
.main-card {
border-radius: 2px;
max-width: 30rem;
width: 90%;
margin: 5rem auto;
padding: 1rem;
margin: 3rem auto;
background-color: rgba(220, 220, 220, 0.8);
box-shadow: 3px 4px 5px 5px rgba(0, 0, 0, 0.2);
}

.main-card .main-card-inner {
width: 80%;
margin: 0 auto;
padding: 25px 50px;
}

#form-header {
Expand All @@ -101,6 +104,7 @@ header {
#form-header img {
width: 100px;
height: 100px;
padding: 0 10%;
}

#form-header-right {
Expand All @@ -111,32 +115,6 @@ header {
margin: auto 0;
}

#client-header {
border-bottom: 1px solid black;
margin: 0;
}

footer {
margin-top: 1rem;
text-align: center;
font-size: 0.9rem;
}

footer a {
text-decoration: none;
}

footer p, ul {
margin: 1rem 0 0 0;
padding: 0;
list-style-type: none;
}

li {
display: inline-block;
padding: 0;
}

a, a:visited {
color: black;
}
Expand All @@ -145,88 +123,14 @@ a:hover {
color: #d32a0e;
}

.oauth-scopes li {
display: grid;
.oauth-scope {
width: 100%;
background-color: white;
border: 1px solid #ea2f10;
border-left: 5px solid #ea2f10;
border: 1px solid var(--lumo-primary-color);
border-left: 5px solid var(--lumo-primary-color);
padding: 0.5rem;
margin: 0.5rem 0;
}

.oauth-scopes div {
grid-column: 1;
}

.oauth-scopes i {
grid-column: 2;
margin: auto 0 auto auto;
}


.flex-container {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
}

.flex-container form {
margin-top: 1rem;
flex-basis: 50%;
}

#denial-form {
margin-right: 0.5rem;
}

#confirmation-form {
margin-left: 0.5rem;
}

#denial-form input[type=submit] {
background-color: white;
color: #f04124;
}

#client-details {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
}

#client-header {
text-align: center;
font-weight: bolder;
font-size: 1.8rem;
}

#client-logo {
flex-basis: 30%;
align-self: center;
text-align: right;
}

#client-logo img {
width: 40px;
padding: 0.5rem 0.5rem;
}

#client-urls {
flex-basis: 70%;
align-self: center;
}

#client-url {
margin: 0.5rem 0;
}

#legal {
font-size: 0.7rem;
margin: 0.5rem 0;
}

#legal li {
padding: 0;
margin: 5px 0;
border-radius: 5px;
}

.pipe-separated li {
Expand All @@ -238,17 +142,9 @@ a:hover {
border: 0;
}

#legal a, #client-url a {
padding: 0 0.5rem;
}

#legal a:nth-child(2) {
border-left: 1px solid black;
}

#scope-header {
padding: 0.5rem 0;
border-bottom: 1px solid black;
padding: 1rem 0 0 0 ;
margin: 0;
font-weight: bold;
font-size: 1.2rem;
}
Expand Down
43 changes: 24 additions & 19 deletions src/main/kotlin/com/faforever/userservice/backend/domain/Ban.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.faforever.domain

import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntityBase
import io.quarkus.hibernate.orm.panache.kotlin.PanacheRepository
import jakarta.enterprise.context.ApplicationScoped
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.Id
import jakarta.persistence.*
import java.time.OffsetDateTime

enum class BanLevel {
Expand All @@ -14,27 +13,33 @@ enum class BanLevel {
}

@Entity(name = "ban")
data class Ban(
@field:Id
@field:GeneratedValue
val id: Long,
val playerId: Long,
val authorId: Long,
val level: BanLevel,
val reason: String,
val expiresAt: OffsetDateTime?,
val revokeTime: OffsetDateTime?,
val reportId: Long?,
val revokeReason: String?,
val revokeAuthorId: Long?,
) {
class Ban : PanacheEntityBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Int = 0
@Column(name = "player_id")
var playerId: Long = 0
@Column(name = "author_id")
val authorId: Int = 0
lateinit var level: BanLevel
lateinit var reason: String
@Column(name = "expires_at")
var expiresAt: OffsetDateTime? = null
@Column(name = "revoke_time")
var revokeTime: OffsetDateTime? = null
@Column(name = "report_id")
var reportId: Long? = null
@Column(name = "revoke_reason")
var revokeReason: String? = null
@Column(name = "revoke_author_id")
var revokeAuthorId: Long? = null

val isActive: Boolean
get() = revokeTime == null && (expiresAt?.isAfter(OffsetDateTime.now()) == true)
}

@ApplicationScoped
class BanRepository : PanacheRepository<Ban> {
fun findGlobalBansByPlayerId(playerId: Long) =
find("playerId = ?1 and level = BanLevel.GLOBAL").list()
fun findGlobalBansByPlayerId(playerId: Int) =
find("playerId = ?1 and level = BanLevel.GLOBAL", playerId).list()
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
package com.faforever.userservice.backend.domain

import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntityBase
import io.quarkus.hibernate.orm.panache.kotlin.PanacheRepository
import io.quarkus.runtime.annotations.RegisterForReflection
import jakarta.enterprise.context.ApplicationScoped
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.Id
import jakarta.persistence.*
import org.hibernate.annotations.CreationTimestamp
import java.time.LocalDateTime

@Entity(name = "login_log")
data class LoginLog(
@field:Id
@field:GeneratedValue
val id: Long,
@field:Column(name = "login_id")
val userId: Long?,
@field:Column(name = "login_string")
val loginString: String?,
val ip: String,
val success: Boolean,
@field:CreationTimestamp
val createTime: LocalDateTime = LocalDateTime.now(),
)
class LoginLog() : PanacheEntityBase {

constructor(
id: Long,
userId: Int?,
loginString: String?,
ip: String,
success: Boolean
) : this() {
this.id = id
this.userId = userId
this.loginString = loginString
this.ip = ip
this.success = success
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long = 0
@Column(name = "login_id")
var userId: Int? = null
@Column(name = "login_string")
var loginString: String? = null
lateinit var ip: String
var success: Boolean = false
@CreationTimestamp
@Column(name = "create_time")
lateinit var createTime: LocalDateTime
}

@RegisterForReflection
data class FailedAttemptsSummary(
Expand All @@ -37,17 +51,19 @@ data class FailedAttemptsSummary(
class LoginLogRepository : PanacheRepository<LoginLog> {

fun findFailedAttemptsByIpAfterDate(ip: String, date: LocalDateTime): FailedAttemptsSummary? =
getEntityManager().createNativeQuery(
getEntityManager().createQuery(
"""
SELECT
count(*) as totalAttempts,
count(DISTINCT login_id) as accountsAffected,
min(create_time) as firstAttemptAt,
max(create_time) as lastAttemptAt
FROM login_log WHERE ip = :ip AND success = 0 AND create_time >= :date
SELECT new com.faforever.userservice.backend.domain.FailedAttemptsSummary(
count(e.id),
count(DISTINCT e.userId),
min(e.createTime),
max(e.createTime)
) FROM com.faforever.userservice.backend.domain.LoginLog e WHERE e.ip = :ip AND e.success = false AND e.createTime >= :date
""",
FailedAttemptsSummary::class.java
)
.setParameter("ip", ip)
.setParameter("date", date)
.resultStream
.findFirst()
.orElse(null) as? FailedAttemptsSummary
Expand Down
Loading

0 comments on commit 745a123

Please sign in to comment.