Skip to content

Additional advanced options for parsers, encoders and url builders

Compare
Choose a tag to compare
@KtorZ KtorZ released this 30 Jun 19:36
· 2 commits to master since this release
f61dc89
  • Allow more advanced control for tweaking parsers, decoders and url builders. This is particularly useful for applications integrating with systems which are either not strictly following the OAuth2.0 specifications, or, systems who introduce custom fields of some importance for the underlying application. (see #29, #23, #21)

  • Update dependencies for base64 encoding

Diff

OAuth - MINOR

  • Added:

    type GrantType
        = AuthorizationCode
        | Password
        | ClientCredentials
        | RefreshToken
        | CustomGrant String
    
    grantTypeToString : GrantType -> String
    type ResponseType
        = Code
        | Token
        | CustomResponse String
    
    responseTypeToString : ResponseType -> String

OAuth.Implicit - MAJOR

  • Added:

    makeAuthorizationUrlWith :
        ResponseType
        -> Dict String String
        -> Authorization
        -> Url
  • Changed:

    -- type alias Parsers =
    --     { tokenParser :
    --           Query.Parser (Maybe Token)
    --     , errorParser :
    --           Query.Parser (Maybe ErrorCode)
    --     , authorizationSuccessParser :
    --           String -> Query.Parser AuthorizationSuccess
    --     , authorizationErrorParser :
    --           ErrorCode -> Query.Parser AuthorizationError
    --     }
    
    type alias Parsers error success =
        { tokenParser :
              Query.Parser (Maybe Token)
        , errorParser :
              Query.Parser (Maybe ErrorCode)
        , authorizationSuccessParser :
              String -> Query.Parser success
        , authorizationErrorParser :
              ErrorCode -> Query.Parser error
        }
    -- defaultParsers : Parsers
    defaultParsers : Parsers AuthorizationError AuthorizationSuccess
    -- parseTokenWith : Parsers -> Url -> AuthorizationResult
    parseTokenWith : Parsers error success -> Url -> AuthorizationResultWith error success

OAuth.AuthorizationCode - MAJOR

  • Added:

    makeAuthorizationUrlWith :
        ResponseType
        -> Dict String String
        -> Authorization
        -> Url
    makeTokenRequestWith :
        OAuth.GrantType
        -> Json.Decoder success
        -> Dict String String
        -> (Result Http.Error success -> msg)
        -> Authentication
        -> RequestParts msg
  • Changed:

    -- type AuthorizationResult
    --     = Empty
    --     | Error AuthorizationError
    --     | Success AuthorizationSuccess
    
    type alias AuthorizationResult =
        AuthorizationResultWith AuthorizationError AuthorizationSuccess
    
    type AuthorizationResultWith error success
        = Empty
        | Error error
        | Success success
    -- type alias Parsers =
    --     { codeParser :
    --           Query.Parser (Maybe String)
    --     , errorParser :
    --           Query.Parser (Maybe ErrorCode)
    --     , authorizationSuccessParser :
    --           String -> Query.Parser AuthorizationSuccess
    --     , authorizationErrorParser :
    --           ErrorCode -> Query.Parser AuthorizationError
    --     }
    
    type alias Parsers error success =
        { codeParser :
              Query.Parser (Maybe String)
        , errorParser :
              Query.Parser (Maybe ErrorCode)
        , authorizationSuccessParser :
              String -> Query.Parser success
        , authorizationErrorParser :
              ErrorCode -> Query.Parser error
        }
    -- defaultParsers : Parsers
    defaultParsers : Parsers AuthorizationError AuthorizationSuccess
    -- parseCodeWith : Parsers -> Url -> AuthorizationResult
    parseCodeWith : Parsers error success -> Url -> AuthorizationResultWith error success

OAuth.AuthorizationCode.PKCE - MAJOR

  • Added:

    makeAuthorizationUrlWith :
        ResponseType
        -> Dict String String
        -> Authorization
        -> Url
    makeTokenRequestWith :
        OAuth.GrantType
        -> Json.Decoder success
        -> Dict String String
        -> (Result Http.Error success -> msg)
        -> Authentication
        -> RequestParts msg
  • Changed:

    -- type AuthorizationResult
    --     = Empty
    --     | Error AuthorizationError
    --     | Success AuthorizationSuccess
    
    type alias AuthorizationResult =
        AuthorizationResultWith AuthorizationError AuthorizationSuccess
    
    type AuthorizationResultWith error success
        = Empty
        | Error error
        | Success success
    -- type alias Parsers =
    --     { codeParser :
    --           Query.Parser (Maybe String)
    --     , errorParser :
    --           Query.Parser (Maybe ErrorCode)
    --     , authorizationSuccessParser :
    --           String -> Query.Parser AuthorizationSuccess
    --     , authorizationErrorParser :
    --           ErrorCode -> Query.Parser AuthorizationError
    --     }
    
    type alias Parsers error success =
        { codeParser :
              Query.Parser (Maybe String)
        , errorParser :
              Query.Parser (Maybe ErrorCode)
        , authorizationSuccessParser :
              String -> Query.Parser success
        , authorizationErrorParser :
              ErrorCode -> Query.Parser error
        }
    -- defaultParsers : Parsers
    defaultParsers : Parsers AuthorizationError AuthorizationSuccess
    -- parseCodeWith : Parsers -> Url -> AuthorizationResult
    parseCodeWith : Parsers error success -> Url -> AuthorizationResultWith error success

OAuth.ClientCredentials - MINOR

  • Added:

    makeTokenRequestWith :
        GrantType
        -> Json.Decoder success
        -> Dict String String
        -> (Result Http.Error success -> msg)
        -> Authentication
        -> RequestParts msg

OAuth.Password - MINOR

  • Added:

    makeTokenRequestWith :
        GrantType
        -> Json.Decoder success
        -> Dict String String
        -> (Result Http.Error success -> msg)
        -> Authentication
        -> RequestParts msg

OAuth.Refresh - MINOR

  • Added:

    makeTokenRequestWith :
        GrantType
        -> Json.Decoder success
        -> Dict String String
        -> (Result Http.Error success -> msg)
        -> Authentication
        -> RequestParts msg