Module: Oauth2::AccessTokenValidationService

Defined in:
app/services/oauth2/access_token_validation_service.rb

Constant Summary collapse

VALID =

Results:

:valid
EXPIRED =
:expired
REVOKED =
:revoked
INSUFFICIENT_SCOPE =
:insufficient_scope

Class Method Summary collapse

Class Method Details

.validate(token, scopes: []) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/oauth2/access_token_validation_service.rb', line 9

def validate(token, scopes: [])
  if token.expired?
    return EXPIRED

  elsif token.revoked?
    return REVOKED

  elsif !self.sufficient_scope?(token, scopes)
    return INSUFFICIENT_SCOPE

  else
    return VALID
  end
end