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 am developing a web app which requires a username and password to be
In a web-app I'm writing, the user is supposed to enter the path in
My C# web app requires the user to enter automobile information. The user can
Maybe theres another solution to this. I built a web app that requires 5-10
I have a huge web app that is having issues with memory leak in
In my (PHP) web app, I have a part of my site that keeps
we're developing a web app to cover all aspects of a printing company from
I've got a web app that sends out emails in response to a user-initaited
In my web app, I submit some form fields with jQuery's $.getJSON() method. I
I'm writing a web app that points to external links. I'm looking to create

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.