Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:52:40+00:00 2026-05-23T01:52:40+00:00

In my web app, I require users to re-enter their password after five minutes

  • 0

In my web app, I require users to re-enter their password after five minutes of inactivity, similar to how sudo works on Linux. Their password is used to decrypt information.

FWIW, the app is heavily Javascript and AJAX-driven, just like a desktop app, using ExtJS.

So, I’ve built a class which provides access to a decryption key based on the password they enter. This class expires the key after five minutes.

My question is: what design pattern does this follow or what would be a better name than ‘Sentry’? I’m trying to name my class appropriately. Here’s the class thus far:

class SecureResourceSentry
  include Singleton

  def initialize
    # Set a default number of seconds for access to expire.
    set_access_expiration_interval(300)

    @key = nil
    @time_last_accessed = 0
  end

  def set_access_expiration_interval(seconds)
    @access_expiration_interval = seconds
  end

  def set_raw_key(raw_key)
    @key = Digest::SHA256.hexdigest(raw_key)
  end

  def getKey
    if @key.nil?
      raise SecureResourceError, 'No key has been set.'
    end

    if access_is_expired
      @key = nil
      raise SecureResourceError, 'Access has expired.'
    end

    return @key
  end

  private
    def access_is_expired
      return Time.now.to_i - @time_last_accessed > @access_expiration_interval
    end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:52:41+00:00Added an answer on May 23, 2026 at 1:52 am

    It looks similar to the revocable accessor described in this secure design patterns talk : “The Lazy Programmer’s Guide to Secure Computing”

    Maybe call it an expiring accessor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to build a web app that allows users to post THEIR
I have simple Sinatra app. web.rb: require 'sinatra' get '/' do Hello end Gemfile:*
My web App prepares out of a db for one or two minutes a
My C# web app requires the user to enter automobile information. The user can
We have a web app that has a built-in search feature that our users
Lets say you have a web app related Android app that requires the user
A web app I'm working on requires frequent parsing of diverse web resources (HTML,
Scenario: WCF client app, calling a web-service (JAVA) operation, wich requires a complex object
WEB APP not native, no Objective-C This is so simple it hurts. <input type=date
Our web app uses SystemPropertyPlaceholder to load property files depending on the value of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.