Skip to content

Instantly share code, notes, and snippets.

View craigplummer's full-sized avatar

Craig Plummer craigplummer

View GitHub Profile
@craigplummer
craigplummer / gist:2624217
Created May 6, 2012 20:25
Apache config required to setup Coldfusion 10 under MAMP Pro
# Load mod_jk module
LoadModule jk_module "/Applications/ColdFusion10/config/wsconfig/1/mod_jk.so"
# Where to find workers.properties
JkWorkersFile "/Applications/ColdFusion10/config/wsconfig/1/workers.properties"
JkMountFile "/Applications/ColdFusion10/config/wsconfig/1/uriworkermap.properties"
# Where to put jk logs
JkLogFile "/Applications/ColdFusion10/config/wsconfig/1/mod_jk.log"
@craigplummer
craigplummer / keybase.md
Created October 25, 2014 14:17
Keybase

Keybase proof

I hereby claim:

  • I am CraigPlummer on github.
  • I am craigplummer (https://keybase.io/craigplummer) on keybase.
  • I have a public key whose fingerprint is 857C 5E9E 11F8 8A7D AA0B 74FB 5013 21FF 2AF6 66F2

To claim this, I am signing this object:

@craigplummer
craigplummer / FederationMetadata.xml
Last active May 7, 2020 06:46
FederationMetadata Example
<?xml version="1.0" encoding="utf-8"?>
<EntityDescriptor ID="_271f377f-78d8-4133-8c46-a73c4936bb1f" entityID="https://example.com" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
<RoleDescriptor xsi:type="fed:ApplicationServiceType" xmlns:fed="http://docs.oasis-open.org/wsfed/federation/200706" protocolSupportEnumeration="http://docs.oasis-open.org/wsfed/federation/200706" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fed:TargetScopes>
<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>https://example.com/</wsa:Address>
</wsa:EndpointReference>
</fed:TargetScopes>
<fed:PassiveRequestorEndpoint>
<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
@craigplummer
craigplummer / Gemfile
Last active February 21, 2022 08:43
Azure AD API Auth Setup
gem 'jwt', '~> 1.5.0'
gem 'warden', '~> 1.2.0'
@craigplummer
craigplummer / Gemfile
Created July 29, 2016 15:39
Using Microsoft Azure AD for API Authentication with Rails and Warden - Gemfile
gem 'jwt', '~> 1.5.0'
gem 'warden', '~> 1.2.0'
@craigplummer
craigplummer / azure_ad_json_web_token.rb
Created July 29, 2016 15:41
Using Microsoft Azure AD for API Authentication with Rails and Warden - azure_ad_json_web_token.rb
class AzureAdJsonWebToken
def self.rsa_key
url = URI.parse('https://login.windows.net/common/discovery/keys')
key_file = JSON.parse(Net::HTTP.get(url))
x5c = Base64.decode64(key_file['keys'][0]['x5c'][0])
OpenSSL::X509::Certificate.new(x5c).public_key
end
def self.aud
ENV['aud']
@craigplummer
craigplummer / azure_ad_json_web_token_strategy.rb
Created July 29, 2016 15:43
Using Microsoft Azure AD for API Authentication with Rails and Warden - azure_ad_json_web_token_strategy.rb
require 'azure_ad_json_web_token'
class AzureAdJsonWebTokenStrategy < ::Warden::Strategies::Base
def valid?
token
end
def authenticate!
if claims
success! claims
@craigplummer
craigplummer / application.rb
Created July 29, 2016 15:44
Using Microsoft Azure AD for API Authentication with Rails and Warden - application.rb
config.middleware.insert_after ActionDispatch::ParamsParser, Warden::Manager do |manager|
manager.default_strategies :azure_ad_json_web_token
manager.failure_app = UnauthorizedController
end
@craigplummer
craigplummer / warden.rb
Created July 29, 2016 15:45
Using Microsoft Azure AD for API Authentication with Rails and Warden - warden.rb
require Rails.root.join('lib/strategies/azure_ad_json_web_token_strategy')
Warden::Strategies.add(:azure_ad_json_web_token, AzureAdJsonWebTokenStrategy)
@craigplummer
craigplummer / warden_helper.rb
Created July 29, 2016 15:46
Using Microsoft Azure AD for API Authentication with Rails and Warden - warden_helper.rb
module WardenHelper
extend ActiveSupport::Concern
included do
helper_method :warden, :current_user
prepend_before_filter :authenticate!
end
def current_user