forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log all authorization errors (digital-asset#6857)
* Log all authorization errors CHANGELOG_BEGIN - [Ledger API Server] The ledger API server now prints detailed log messages whenever a request was rejected due to a failed authorization. CHANGELOG_END
- Loading branch information
1 parent
36a4b8a
commit 46b87c3
Showing
4 changed files
with
182 additions
and
55 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
.../ledger-api-auth/src/main/scala/com/digitalasset/ledger/api/auth/AuthorizationError.scala
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,56 @@ | ||
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.ledger.api.auth | ||
|
||
import java.time.Instant | ||
|
||
sealed abstract class AuthorizationError { | ||
def reason: String | ||
} | ||
|
||
object AuthorizationError { | ||
|
||
final case class Expired(authorizedUntil: Instant, currentTime: Instant) | ||
extends AuthorizationError { | ||
override val reason = | ||
s"Claims were valid until $authorizedUntil, current time is $currentTime." | ||
} | ||
|
||
case object ExpiredOnStream extends AuthorizationError { | ||
override val reason = "Claims have expired after the result stream has started." | ||
} | ||
|
||
final case class InvalidLedger(authorized: String, actual: String) extends AuthorizationError { | ||
override val reason = | ||
s"Claims are only valid for ledgerId $authorized, actual ledgerId is $actual." | ||
} | ||
|
||
final case class InvalidParticipant(authorized: String, actual: String) | ||
extends AuthorizationError { | ||
override val reason = | ||
s"Claims are only valid for participantId $authorized, actual participantId is $actual." | ||
} | ||
|
||
final case class InvalidApplication(authorized: String, actual: String) | ||
extends AuthorizationError { | ||
override val reason = | ||
s"Claims are only valid for applicationId $authorized, actual applicationId is $actual." | ||
} | ||
|
||
case object MissingPublicClaim extends AuthorizationError { | ||
override val reason = "Claims do not authorize the use of public services." | ||
} | ||
|
||
case object MissingAdminClaim extends AuthorizationError { | ||
override val reason = "Claims do not authorize the use of administrative services." | ||
} | ||
|
||
final case class MissingReadClaim(party: String) extends AuthorizationError { | ||
override val reason = s"Claims do not authorize to read data for party $party" | ||
} | ||
|
||
final case class MissingActClaim(party: String) extends AuthorizationError { | ||
override val reason = s"Claims do not authorize to act as party $party" | ||
} | ||
} |
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
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