Class: Authn::Tokens::OauthApplicationSecret
- Inherits:
-
Object
- Object
- Authn::Tokens::OauthApplicationSecret
- Defined in:
- lib/authn/tokens/oauth_application_secret.rb
Instance Attribute Summary collapse
-
#revocable ⇒ Object
readonly
Returns the value of attribute revocable.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(plaintext, source) ⇒ OauthApplicationSecret
constructor
A new instance of OauthApplicationSecret.
- #present_with ⇒ Object
- #revoke!(current_user) ⇒ Object
Constructor Details
#initialize(plaintext, source) ⇒ OauthApplicationSecret
Returns a new instance of OauthApplicationSecret.
20 21 22 23 |
# File 'lib/authn/tokens/oauth_application_secret.rb', line 20 def initialize(plaintext, source) @revocable = ::Authn::OauthApplication.find_by_plaintext_token(:secret, plaintext) @source = source end |
Instance Attribute Details
#revocable ⇒ Object (readonly)
Returns the value of attribute revocable.
18 19 20 |
# File 'lib/authn/tokens/oauth_application_secret.rb', line 18 def revocable @revocable end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
18 19 20 |
# File 'lib/authn/tokens/oauth_application_secret.rb', line 18 def source @source end |
Class Method Details
.prefix?(plaintext) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/authn/tokens/oauth_application_secret.rb', line 6 def self.prefix?(plaintext) # Extract the token type prefix from both the default and custom prefix formats. We use uniq to handle the case # that the prefix has not been changed and thus prefix_for_oauth_application_secret and # OAUTH_APPLICATION_SECRET_PREFIX_FORMAT are the same prefixes = [ ::Gitlab::DoorkeeperSecretStoring::Token::UniqueApplicationToken.prefix_for_oauth_application_secret, ::Gitlab::DoorkeeperSecretStoring::Token::UniqueApplicationToken::OAUTH_APPLICATION_SECRET_PREFIX_FORMAT ].uniq.map { |prefix_format| prefix_format.delete_suffix('-%{token}') } plaintext.start_with?(*prefixes) end |
Instance Method Details
#present_with ⇒ Object
25 26 27 |
# File 'lib/authn/tokens/oauth_application_secret.rb', line 25 def present_with ::API::Entities::Application end |
#revoke!(current_user) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/authn/tokens/oauth_application_secret.rb', line 29 def revoke!(current_user) raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank? Authz::Applications::ResetSecretService.new( application: revocable, current_user: current_user ).execute end |