Sha256: 8b4869a25b45a328c57bda517844abf8d8affa216c21450c18ba3ebf7de7b9d4
Contents?: true
Size: 1.32 KB
Versions: 5
Compression:
Stored size: 1.32 KB
Contents
require 'active_support/concern' module GDS module SSO class ApiUser def uid 0 end def name 'API User' end def has_permission?(scope, permission) true end end module User def included(base) attr_accessible :uid, :email, :name, :permissions, as: :oauth end def has_permission?(scope, permission) if permissions && permissions.has_key?(scope) permissions[scope].include?(permission) || permissions[scope].include?("admin") end end def self.user_params_from_auth_hash(auth_hash) { 'uid' => auth_hash['uid'], 'email' => auth_hash['info']['email'], 'name' => auth_hash['info']['name'], 'permissions' => auth_hash['extra']['user']['permissions'] } end extend ActiveSupport::Concern module ClassMethods def find_for_gds_oauth(auth_hash) if user = self.find_by_uid(auth_hash["uid"]) user.update_attributes(GDS::SSO::User.user_params_from_auth_hash(auth_hash.to_hash), as: :oauth) user else # Create a new user. self.create!(GDS::SSO::User.user_params_from_auth_hash(auth_hash.to_hash), as: :oauth) end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
gds-sso-1.0.0 | lib/gds-sso/user.rb |
gds-sso-0.8.0 | lib/gds-sso/user.rb |
gds-sso-0.7.9 | lib/gds-sso/user.rb |
gds-sso-0.7.8 | lib/gds-sso/user.rb |
gds-sso-0.7.7 | lib/gds-sso/user.rb |