Questions tagged [scopes]

An OAuth Scope is a permission setting that limits the permissiveness of a given OAuth Token. Clients therefore provide a list of desired Scopes when obtaining a Token (alongside standard OAuth ClientId and Client Authentication details). The Token will then be granted (or not) according to the Authentication process and the Scopes granted for the given Client Id

383 questions
53
votes
2 answers

ActiveRecord Rails 3 scope vs class method

I'm new to the new query interface of ActiveRecord so I'm still figuring things out. I was hoping someone could explain the difference between using a scope in an ActiveRecord model and just using a class method (ie self.some_method) From what I…
brad
  • 31,987
  • 28
  • 102
  • 155
37
votes
6 answers

Laravel Passport Scopes

I am a bit confused on the laravel scopes part. I have a user model and table. How can I assign a user the role of user, customer and/or admin. I have a SPA with vue and laravel api backend. I use…
36
votes
3 answers

How do I pass an argument to a has_many association scope in Rails 4?

Rails 4 lets you scope a has_many relationship like so: class Customer < ActiveRecord::Base has_many :orders, -> { where processed: true } end So anytime you do customer.orders you only get processed orders. But what if I need to make the where…
Rob Sobers
  • 20,737
  • 24
  • 82
  • 111
33
votes
6 answers

rails scope to check if association does NOT exist

I am looking toward writing a scope that returns all records that do not have a particular association. foo.rb class Foo < ActiveRecord::Base has_many :bars end bar.rb class Bar < ActiveRecord::Base belongs_to :foo end I want a scope…
Julio G Medina
  • 692
  • 1
  • 7
  • 17
24
votes
1 answer

OAuth-2.0/JWT - guidance about when to use scope vs roles

One thing related to OAuth 2.0 and JWTs that's still a bit confusing is when to use scopes vs. roles. I think some of the confusion is coming from how role-based authorization works in ASP.NET Core (which is the primary language/framework at my…
Ryan.Bartsch
  • 3,698
  • 1
  • 26
  • 52
21
votes
2 answers

slack bot scope missing while making api request

I have made a slack app in which I have a bot. I have selected channels:history, channels:read, channels:write under my permission scope, and also I have passed scopes "scope":"bot channel:history channel:read channel:write" while doing my oauth2…
saf1
  • 960
  • 3
  • 9
  • 21
17
votes
1 answer

How do I make an ActiveRecord scope that doesn't affect the query in Rails 3 using Arel (presumably)?

Essentially I am looking for a no-op type of relation to apply to a chain of scopes. Lets say I have a chain of scopes: Post.approved.published.all Now, for debugging purposes, I wish to make the published scope do nothing at all, so that the chain…
jakeonrails
  • 1,885
  • 15
  • 37
16
votes
1 answer

Ruby scopes, constants precedence: lexical scope or inheritance tree

I'll show your the code snippet from rubykoans tutorial. Consider the next code: class MyAnimals LEGS = 2 class Bird < Animal def legs_in_bird LEGS end end end def test_who_wins_with_both_nested_and_inherited_constants …
Paul Osadchiy
  • 169
  • 1
  • 6
11
votes
1 answer

Why using merge method with scopes isn't working anymore on Rails 3.1?

I stumbled upon a wonderful article about scopes on Rails 3+ : http://edgerails.info/articles/what-s-new-in-edge-rails/2010/02/23/the-skinny-on-scopes-formerly-named-scope/index.html You can read there (in 'Crazy Town' section) that it's possible to…
Jeremy F.
  • 1,346
  • 12
  • 30
10
votes
1 answer

Can Keycloak include scopes in JWT access tokens as an array?

I am wanting to use Keycloak to authorise access for my API. I have got the relevant scopes defined, and these are coming back in the access token as expected: { ... claims ... "scope": "openid profile user/Patient.write user/Patient.read", …
10
votes
3 answers

Autowiring request scoped beans into application scoped beans

Is it possible to autowire a request scoped bean into an application scoped bean. i.e I have a class RequestScopedBean: class RequestScopedBean { .... .... .... } and a class Application scoped bean in which the request scoped bean is…
Lydwin
  • 103
  • 1
  • 1
  • 4
9
votes
2 answers

Adding documentation for model scopes in rails

I'm not sure if this is actually possible or not but I'm trying to make the documentation of our rails app more complete by adding documentation for the scopes in our app/models files. What I'm looking to try and do is: # This is a description of…
Chris Bailey
  • 4,126
  • 24
  • 28
9
votes
2 answers

How to write scope with belongs_to object?

I have the following models Models Job belongs_to :company Company has_many :jobs Right now I select all the Jobs which have an accepted Company using the following method: def self.with_accepted_company Job.all.reject {|job|…
tomekfranek
  • 6,852
  • 8
  • 45
  • 80
8
votes
2 answers

Google Oauth pre-select scopes

My app invokes Google Oauth (the app was set up in Google Cloud console). When user is presented with a Google Oauth consent screen, for example, to approve access to adwords api, is there a way of controlling the scopes pre-selection? Desirable…
NenadP
  • 585
  • 7
  • 24
8
votes
1 answer

local scopes in Julia

I understand that the for loops are now local in Julia. But there is something I do not understand. Please consider the following two examples. Example 1 a = 0 for i = 1:3 a += 1 end Example 2 a = [0] for i = 1:3 a[1] += 1 end Example 1…
SJ Jun
  • 81
  • 2
1
2 3
25 26