Class: StandardId::ClientSecretCredential

Inherits:
ApplicationRecord show all
Includes:
Credentiable
Defined in:
app/models/standard_id/client_secret_credential.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/standard_id/client_secret_credential.rb', line 24

def active?
  active && revoked_at.nil?
end

#default_redirect_uriObject



32
33
34
# File 'app/models/standard_id/client_secret_credential.rb', line 32

def default_redirect_uri
  redirect_uris&.split(" ")&.first
end

#effective_default_redirect_uriObject



47
48
49
# File 'app/models/standard_id/client_secret_credential.rb', line 47

def effective_default_redirect_uri
  effective_redirect_uris_array.first
end

#effective_redirect_uris_arrayObject



42
43
44
45
# File 'app/models/standard_id/client_secret_credential.rb', line 42

def effective_redirect_uris_array
  return redirect_uris.to_s.split(/\s+/).map(&:strip).reject(&:blank?) if redirect_uris.present?
  client_application.redirect_uris_array
end

#effective_scopes_arrayObject

Effective configuration with per-secret override fallback



37
38
39
40
# File 'app/models/standard_id/client_secret_credential.rb', line 37

def effective_scopes_array
  return scopes_array if scopes.present?
  client_application.scopes_array
end

#revoke!Object



19
20
21
22
# File 'app/models/standard_id/client_secret_credential.rb', line 19

def revoke!
  update!(active: false, revoked_at: Time.current)
  emit_revoked_event
end

#scopes_arrayObject



28
29
30
# File 'app/models/standard_id/client_secret_credential.rb', line 28

def scopes_array
  (scopes || "").split(" ").map(&:strip).reject(&:blank?)
end