-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
207 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,21 @@ | ||
module Authly | ||
# Security Configuration | ||
class SecurityConfiguration | ||
# Configuration class using Singleton and Builder Pattern | ||
class Configuration | ||
class_getter instance : Configuration = Configuration.new | ||
|
||
property owners : AuthorizableOwner = Owners.new | ||
property clients : AuthorizableClient = Clients.new | ||
property token_store : TokenStoreProvider = InMemoryTokenStore.new | ||
property secret_key : String = Random::Secure.hex(16) | ||
property public_key : String = Random::Secure.hex(16) | ||
property algorithm : JWT::Algorithm = JWT::Algorithm::HS256 | ||
end | ||
|
||
# Time-To-Live Configuration | ||
class TTLConfiguration | ||
property issuer : String = "The Authority Server Provider" | ||
property refresh_ttl : Time::Span = 1.day | ||
property code_ttl : Time::Span = 5.minutes | ||
property access_ttl : Time::Span = 1.hour | ||
end | ||
|
||
# Providers Configuration | ||
class ProvidersConfiguration | ||
property owners : AuthorizableOwner = Owners.new | ||
property clients : AuthorizableClient = Clients.new | ||
property jti_provider : JTIProvider = InMemoryJTIProvider.new | ||
end | ||
|
||
# Configuration class using Singleton and Builder Pattern | ||
class Configuration | ||
property issuer : String = "The Authority Server Provider" | ||
property security : SecurityConfiguration = SecurityConfiguration.new | ||
property ttl : TTLConfiguration = TTLConfiguration.new | ||
property providers : ProvidersConfiguration = ProvidersConfiguration.new | ||
property token_type : String = "jwt" | ||
|
||
# Singleton instance | ||
@@instance : Configuration? | ||
|
||
def self.instance : Configuration | ||
@@instance ||= Configuration.new | ||
end | ||
|
||
def initialize | ||
end | ||
|
||
# Builder for Configuration | ||
class Builder | ||
def initialize | ||
@configuration = Configuration.new | ||
end | ||
|
||
def issuer(issuer : String) : self | ||
@configuration.issuer = issuer | ||
self | ||
end | ||
|
||
def security(security : SecurityConfiguration) : self | ||
@configuration.security = security | ||
self | ||
end | ||
|
||
def ttl(ttl : TTLConfiguration) : self | ||
@configuration.ttl = ttl | ||
self | ||
end | ||
|
||
def owner_client(owner_client : ProvidersConfiguration) : self | ||
@configuration.owner_client = owner_client | ||
self | ||
end | ||
|
||
def build : Configuration | ||
Configuration.instance | ||
end | ||
getter token_strategy : TokenStrategy do | ||
TokenFactory.create | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.