Sha256: 67727e8206e9c88bc10721c330d3888647b89374a0f2f056730663b4a23ebeb2

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'keratin/client'
require 'net/http'

module Keratin::AuthN
  class Issuer < Keratin::Client
    def lock(account_id)
      patch(path: "/accounts/#{account_id}/lock").result
    end

    def unlock(account_id)
      patch(path: "/accounts/#{account_id}/unlock").result
    end

    def archive(account_id)
      delete(path: "/accounts/#{account_id}").result
    end

    # returns account_id or raises exception
    def import(username:, password:, locked: false)
      post(path: '/accounts/import', body: {
        username: username,
        password: password,
        locked: locked
      }).result['id']
    end

    def expire_password(account_id)
      patch(path: "/accounts/#{account_id}/expire_password")
    end

    def signing_key(kid)
      keys.find{|k| k['use'] == 'sig' && (kid.blank? || kid == k['kid']) }
    end

    private def configuration
      @configuration ||= get(path: '/configuration').data
    end

    private def keys
      JSON::JWK::Set.new(
        get(path: URI.parse(configuration['jwks_uri']).path).data
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
keratin-authn-0.4.0 lib/keratin/authn/issuer.rb