heimdall_auth 1.1.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e3721e30f22989c4876279dc3fcebb5882c2fa362d4f8216262f71f4f34049f
4
- data.tar.gz: 60846d0138bc2d23728fa359a441a181e8d689beb45331ce0348c43436a15cd1
3
+ metadata.gz: 5538f6cfc7a18364ba8f0212ccef6666ddc54aedecb5e98431ab696ae00201ad
4
+ data.tar.gz: fe36860b89bb61c225be5204f4522d77d96a87cf07ec9b05c9694f4333780383
5
5
  SHA512:
6
- metadata.gz: 5dc68c45755eecb2ada5e51358e1d211c2f40e9ae8751973c0a9d9b39d05c98e4356e12fe86c586a2a645ac0a59385d6b6fac3059b69f123d31ba1947f45d293
7
- data.tar.gz: c211021081fff2c8219fcccd9dcd5ab95c3ab78a72d088692cefed9dee0459a334fbd22645124ea8aecf511a565a5620432255fa9da76a7498b50ef51af6b758
6
+ metadata.gz: ea5fc9d268377f56cc01eb8a00339331430f417181394b453d0350b146f2af14eea8d6a8f99e1fbe6048bd24d02a9bac357d67328c2a5d0f245fdf28349c97b8
7
+ data.tar.gz: 3a05fcd17f9ab05663de6761468b11b83c0be6b748f1a2b83011a02e272d9d807c015095d756908e858bfec2edc343e7993154c89ff3e7b25bccae6f0533e2c0
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
  This makes it easy to equip an empty rails application with our Heimdall Auth features.
3
3
 
4
4
  ## Installation and Usage
5
+
6
+ Example: https://gitlab.vesputi.com/netzmap/nanna
7
+
5
8
  0) Commit the empty rails application (and mention the command you used for generating the app)
6
9
 
7
10
  1) Add this line to your application's Gemfile:
@@ -67,3 +70,13 @@ Parameters:
67
70
  -h"https://heimdall.vesp" (Optional) - Protocol and Domain the heimdall is found at
68
71
  -s"https://foo.vesputi-abc.de" # (Optional) - Protocol and Domain the Service is found at
69
72
  ```
73
+
74
+ ## RSpec
75
+ If you want to test your Applications controller than you have to give it a User
76
+ You do so by mocking `current_user` in ApplicationController
77
+
78
+ ```
79
+ RSpec.describe "/foobar", type: :request do
80
+ before { allow_any_instance_of(ApplicationController).to receive(:current_user) { HeimdallAuth::User.new(is_editor: true) } }
81
+ end
82
+ ```
@@ -7,7 +7,7 @@ module HeimdallAuth
7
7
  module ControllerAdditions
8
8
 
9
9
  def self.included(base)
10
- base.helper_method :current_user, :current_access_token, :user_signed_in? if base.respond_to? :helper_method
10
+ base.helper_method :current_user, :current_access_token, :current_environment, :user_signed_in? if base.respond_to? :helper_method
11
11
  base.before_action :store_location_in_session
12
12
 
13
13
  base.rescue_from CanCan::AccessDenied do |exception|
@@ -57,6 +57,14 @@ module HeimdallAuth
57
57
  end
58
58
  end
59
59
 
60
+ def current_environment
61
+ begin
62
+ @current_environment ||= current_user.key_environment || params[:environment]
63
+ rescue NoMethodError, Exception => e
64
+ nil
65
+ end
66
+ end
67
+
60
68
  def get_user_from_auth_server(access_token)
61
69
  client = OAuth2::Client.new(ENV['HEIMDALL_APPLICATION_ID'], ENV['HEIMDALL_APPLICATION_SECRET'], :site => ENV['HEIMDALL_SERVER_URL'])
62
70
  user_data = OAuth2::AccessToken.new(client,access_token).get('/me.json').parsed
@@ -3,7 +3,7 @@ class HeimdallAuth::User
3
3
  extend ActiveModel::Naming
4
4
 
5
5
  attr_accessor :is_invalid
6
- attr_accessor :id, :name, :email, :is_editor, :is_operator, :is_admin, :is_user_admin
6
+ attr_accessor :id, :name, :key_type, :key_environment, :email, :is_editor, :is_operator, :is_admin, :is_user_admin, :is_police, :is_ride_on_demand_provider, :is_ride_on_demand_accounting
7
7
 
8
8
  def initialize(attributes = {})
9
9
  attributes.each do |name, value|
@@ -1,3 +1,3 @@
1
1
  module HeimdallAuth
2
- VERSION = '1.1.0'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -2,7 +2,7 @@ namespace :puma_dev do
2
2
  desc 'Fast linking to puma dev'
3
3
  task :link do
4
4
 
5
- application_name = Rails.application.class.parent_name
5
+ application_name = Rails.application.class.try(:parent_name) || Rails.application.class.try(:module_parent_name)
6
6
  puma_dev_app_name = "#{application_name.underscore.dasherize}.vesputi-abc"
7
7
  command = "ln -s #{Rails.root} ~/.puma-dev/#{puma_dev_app_name}"
8
8
 
@@ -7,7 +7,7 @@ namespace :heimdall do
7
7
  desc 'Register application at a Heimdall Application'
8
8
  task :register do
9
9
 
10
- application_name = Rails.application.class.parent_name
10
+ application_name = Rails.application.class.try(:parent_name) || Rails.application.class.try(:module_parent_name)
11
11
 
12
12
  options = {
13
13
  application_name: application_name,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heimdall_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Meye
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,7 +122,7 @@ homepage: https://vesputi.com
122
122
  licenses:
123
123
  - MIT
124
124
  metadata: {}
125
- post_install_message:
125
+ post_install_message:
126
126
  rdoc_options: []
127
127
  require_paths:
128
128
  - lib
@@ -137,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubygems_version: 3.0.3
141
- signing_key:
140
+ rubygems_version: 3.1.6
141
+ signing_key:
142
142
  specification_version: 4
143
143
  summary: Summary of HeimdallAuth.
144
144
  test_files: []