mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
32bb44c8a1
commit
78622b5827
|
@ -22,9 +22,13 @@ constructor(
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other !is Person) return false
|
if (javaClass != other?.javaClass) return false
|
||||||
if (!super.equals(other)) return false
|
if (!super.equals(other)) return false
|
||||||
|
|
||||||
|
other as Person
|
||||||
|
|
||||||
|
if (name != other.name) return false
|
||||||
|
if (id != other.id) return false
|
||||||
if (preferredUsername != other.preferredUsername) return false
|
if (preferredUsername != other.preferredUsername) return false
|
||||||
if (summary != other.summary) return false
|
if (summary != other.summary) return false
|
||||||
if (inbox != other.inbox) return false
|
if (inbox != other.inbox) return false
|
||||||
|
@ -33,20 +37,26 @@ constructor(
|
||||||
if (icon != other.icon) return false
|
if (icon != other.icon) return false
|
||||||
if (publicKey != other.publicKey) return false
|
if (publicKey != other.publicKey) return false
|
||||||
if (endpoints != other.endpoints) return false
|
if (endpoints != other.endpoints) return false
|
||||||
|
if (followers != other.followers) return false
|
||||||
|
if (following != other.following) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
var result = super.hashCode()
|
var result = super.hashCode()
|
||||||
|
result = 31 * result + name.hashCode()
|
||||||
|
result = 31 * result + id.hashCode()
|
||||||
result = 31 * result + (preferredUsername?.hashCode() ?: 0)
|
result = 31 * result + (preferredUsername?.hashCode() ?: 0)
|
||||||
result = 31 * result + (summary?.hashCode() ?: 0)
|
result = 31 * result + (summary?.hashCode() ?: 0)
|
||||||
result = 31 * result + inbox.hashCode()
|
result = 31 * result + inbox.hashCode()
|
||||||
result = 31 * result + outbox.hashCode()
|
result = 31 * result + outbox.hashCode()
|
||||||
result = 31 * result + url.hashCode()
|
result = 31 * result + url.hashCode()
|
||||||
result = 31 * result + (icon?.hashCode() ?: 0)
|
result = 31 * result + (icon?.hashCode() ?: 0)
|
||||||
result = 31 * result + (publicKey?.hashCode() ?: 0)
|
result = 31 * result + publicKey.hashCode()
|
||||||
result = 31 * result + endpoints.hashCode()
|
result = 31 * result + endpoints.hashCode()
|
||||||
|
result = 31 * result + (followers?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (following?.hashCode() ?: 0)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ class InboxJobProcessor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("TooGenericExceptionCaught")
|
||||||
val verify = try {
|
val verify = try {
|
||||||
signatureVerifier.verify(
|
signatureVerifier.verify(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
|
|
|
@ -95,15 +95,13 @@ class APUserServiceImpl(
|
||||||
name = person.preferredUsername
|
name = person.preferredUsername
|
||||||
?: throw IllegalActivityPubObjectException("preferredUsername is null"),
|
?: throw IllegalActivityPubObjectException("preferredUsername is null"),
|
||||||
domain = id.substringAfter("://").substringBefore("/"),
|
domain = id.substringAfter("://").substringBefore("/"),
|
||||||
screenName = person.name
|
screenName = person.name,
|
||||||
?: throw IllegalActivityPubObjectException("preferredUsername is null"),
|
|
||||||
description = person.summary.orEmpty(),
|
description = person.summary.orEmpty(),
|
||||||
inbox = person.inbox,
|
inbox = person.inbox,
|
||||||
outbox = person.outbox,
|
outbox = person.outbox,
|
||||||
url = id,
|
url = id,
|
||||||
publicKey = person.publicKey?.publicKeyPem
|
publicKey = person.publicKey.publicKeyPem,
|
||||||
?: throw IllegalActivityPubObjectException("publicKey is null"),
|
keyId = person.publicKey.id,
|
||||||
keyId = person.publicKey?.id ?: throw IllegalActivityPubObjectException("publicKey keyId is null"),
|
|
||||||
following = person.following,
|
following = person.following,
|
||||||
followers = person.followers,
|
followers = person.followers,
|
||||||
sharedInbox = person.endpoints["sharedInbox"]
|
sharedInbox = person.endpoints["sharedInbox"]
|
||||||
|
|
|
@ -84,7 +84,9 @@ class SecurityConfig {
|
||||||
http {
|
http {
|
||||||
securityMatcher("/users/*/posts/*")
|
securityMatcher("/users/*/posts/*")
|
||||||
addFilterAt<RequestCacheAwareFilter>(httpSignatureFilter)
|
addFilterAt<RequestCacheAwareFilter>(httpSignatureFilter)
|
||||||
addFilterBefore<HttpSignatureFilter>(ExceptionTranslationFilter(HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)))
|
addFilterBefore<HttpSignatureFilter>(
|
||||||
|
ExceptionTranslationFilter(HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
|
||||||
|
)
|
||||||
authorizeHttpRequests {
|
authorizeHttpRequests {
|
||||||
authorize(anyRequest, permitAll)
|
authorize(anyRequest, permitAll)
|
||||||
}
|
}
|
||||||
|
@ -160,7 +162,6 @@ class SecurityConfig {
|
||||||
}
|
}
|
||||||
oauth2ResourceServer {
|
oauth2ResourceServer {
|
||||||
jwt {
|
jwt {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +173,6 @@ class SecurityConfig {
|
||||||
fun defaultSecurityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
fun defaultSecurityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
authorizeHttpRequests {
|
authorizeHttpRequests {
|
||||||
|
|
||||||
authorize("/error", permitAll)
|
authorize("/error", permitAll)
|
||||||
authorize("/login", permitAll)
|
authorize("/login", permitAll)
|
||||||
authorize(GET, "/.well-known/**", permitAll)
|
authorize(GET, "/.well-known/**", permitAll)
|
||||||
|
@ -200,7 +200,6 @@ class SecurityConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
formLogin {
|
formLogin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
csrf {
|
csrf {
|
||||||
|
|
|
@ -27,13 +27,10 @@ class HttpSignatureUserDetailsService(
|
||||||
) :
|
) :
|
||||||
AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> {
|
AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> {
|
||||||
override fun loadUserDetails(token: PreAuthenticatedAuthenticationToken): UserDetails = runBlocking {
|
override fun loadUserDetails(token: PreAuthenticatedAuthenticationToken): UserDetails = runBlocking {
|
||||||
if (token.principal !is String) {
|
check(token.principal is String) { "Token is not String" }
|
||||||
throw IllegalStateException("Token is not String")
|
|
||||||
}
|
|
||||||
val credentials = token.credentials
|
val credentials = token.credentials
|
||||||
if (credentials !is HttpRequest) {
|
|
||||||
throw IllegalStateException("Credentials is not HttpRequest")
|
check(credentials is HttpRequest) { "Credentials is not HttpRequest" }
|
||||||
}
|
|
||||||
|
|
||||||
val keyId = token.principal as String
|
val keyId = token.principal as String
|
||||||
val findByKeyId = transaction.transaction {
|
val findByKeyId = transaction.transaction {
|
||||||
|
|
|
@ -29,6 +29,7 @@ class InMemoryCacheManager : CacheManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needRunBlock) {
|
if (needRunBlock) {
|
||||||
|
@Suppress("TooGenericExceptionCaught")
|
||||||
val processed = try {
|
val processed = try {
|
||||||
block()
|
block()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.security.web.access.intercept.RequestAuthorizationCon
|
||||||
fun AuthorizeHttpRequestsDsl.hasScope(scope: String): AuthorizationManager<RequestAuthorizationContext> =
|
fun AuthorizeHttpRequestsDsl.hasScope(scope: String): AuthorizationManager<RequestAuthorizationContext> =
|
||||||
hasAuthority("SCOPE_$scope")
|
hasAuthority("SCOPE_$scope")
|
||||||
|
|
||||||
|
@Suppress("SpreadOperator")
|
||||||
fun AuthorizeHttpRequestsDsl.hasAnyScope(vararg scopes: String): AuthorizationManager<RequestAuthorizationContext> =
|
fun AuthorizeHttpRequestsDsl.hasAnyScope(vararg scopes: String): AuthorizationManager<RequestAuthorizationContext> =
|
||||||
hasAnyAuthority(
|
hasAnyAuthority(*scopes.map { "SCOPE_$it" }.toTypedArray())
|
||||||
*scopes.map { "SCOPE_$it" }.toTypedArray()
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue