Sha256: b2d004071b006902785f71a98c99f2a53c2b36386c8895a1b7dfc19ba2a0f001
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
module ShibbolethAuth class ShibbolethUser attr_reader :username, :common_name, :groups, :affiliations def strip_group_prefix groups groups = groups.split(';') if group.class == String return groups.select do |s| s[0...ShibbolethAuth::GroupPrefixField.length] == ShibbolethAuth::GroupPrefixField end.map do |s| s[ShibbolethAuth::GroupPrefixField.length+1..-1] end end def is_admin? #return true if ["cucumber", "test"].include? Rails.env return true if ShibbolethAuth::AdminUsers.include?(username) return true unless (ShibbolethAuth::AdminGroups & groups).empty? false end def initialize(env) # Development Settings if env["HTTP_HOST"] && ["localhost", "127.0.0.1"].any? {|url| env["HTTP_HOST"].include? url } @username = ShibbolethAuth::DevelopmentUsername @common_name = ShibbolethAuth::DevelopmentCommonName @groups = strip_group_prefix ShibbolethAuth::DevelopmentGroups @affiliations = ShibbolethAuth::DevelopmentAffiliation else env = env[:shibboleth_debug_env] || env @username = env[ShibbolethAuth::UsernameField] @common_name = env[ShibbolethAuth::CommonNameField] # strip the group prefix from groups @groups = strip_group_prefix(env[ShibbolethAuth::GroupsField] || '') @affiliations = (env[ShibbolethAuth::AffiliationField] || '').split(';') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shibboleth_auth-0.3.1 | app/models/shibboleth_user.rb |