Skip to content

Commit

Permalink
Merge pull request #33 from biocad/shevchenkod/ABSCAN-1481-ghc9
Browse files Browse the repository at this point in the history
Check key for aeson 2.
  • Loading branch information
maksbotan authored Jan 23, 2023
2 parents 2e4758c + 64b3fe9 commit 68b3332
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.3.13] - 2023-01-23
### Changed
- Add check for aeson 2, for GHC 9.2.5.

## [0.1.3.12] - 2022-07-17
### Changed
- Update imports to support `lens-aeson` >=1.2.
Expand Down
10 changes: 10 additions & 0 deletions src/Web/Template/Servant/Auth.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
Expand Down Expand Up @@ -37,6 +38,11 @@ import Crypto.JWT (ClaimsSet, JWTError, JWTValidat
defaultJWTValidationSettings, issuerPredicate,
string, unregisteredClaims, uri, verifyClaims)
import Data.Aeson (Value)

#if MIN_VERSION_aeson(2, 0, 0)
import Data.Aeson.Key (fromText)
#endif

import Data.Aeson.Lens (_String, key, values)
import Data.ByteString (ByteString, stripPrefix)
import qualified Data.ByteString.Lazy as LB
Expand Down Expand Up @@ -347,7 +353,11 @@ instance ( HasServer api context
let haveRoles = claims
^.. unregisteredClaims
. ix "resource_access"
#if MIN_VERSION_aeson(2, 0, 0)
. key (fromText oidcClientId)
#else
. key oidcClientId
#endif
. key "roles"
. values . _String

Expand Down
2 changes: 1 addition & 1 deletion web-template.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: web-template
version: 0.1.3.12
version: 0.1.3.13
synopsis: Web template
description:
Web template includes:
Expand Down

0 comments on commit 68b3332

Please sign in to comment.