Skip to content

Commit

Permalink
🔧 delete unnecesary extention
Browse files Browse the repository at this point in the history
  • Loading branch information
mreyes committed Jul 1, 2024
1 parent de65c75 commit 3b55fb9
Show file tree
Hide file tree
Showing 49 changed files with 534 additions and 672 deletions.
10 changes: 4 additions & 6 deletions source/Stargate-Model/AllowAnyOriginPolicy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
I'm a policy configuring a CORS filter in such a way that sets Access-Control-Allow-Origin header to allow any origin.
"
Class {
#name : 'AllowAnyOriginPolicy',
#superclass : 'AllowOriginPolicy',
#category : 'Stargate-Model-CORS',
#package : 'Stargate-Model',
#tag : 'CORS'
#name : #AllowAnyOriginPolicy,
#superclass : #AllowOriginPolicy,
#category : 'Stargate-Model-CORS'
}

{ #category : 'configuring headers' }
{ #category : #'configuring headers' }
AllowAnyOriginPolicy >> applyOn: aResponse for: aRequest using: aHandler [

aHandler setAnyOriginAllowedOn: aResponse
Expand Down
10 changes: 4 additions & 6 deletions source/Stargate-Model/AllowOriginPolicy.class.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Class {
#name : 'AllowOriginPolicy',
#superclass : 'Object',
#category : 'Stargate-Model-CORS',
#package : 'Stargate-Model',
#tag : 'CORS'
#name : #AllowOriginPolicy,
#superclass : #Object,
#category : 'Stargate-Model-CORS'
}

{ #category : 'configuring headers' }
{ #category : #'configuring headers' }
AllowOriginPolicy >> applyOn: aResponse for: aRequest using: aHandler [

self subclassResponsibility
Expand Down
14 changes: 6 additions & 8 deletions source/Stargate-Model/AllowSpecifiedOriginsPolicy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
I'm a policy configuring a CORS filter in such a way that sets Access-Control-Allow-Origin header to a specified set of origins.
"
Class {
#name : 'AllowSpecifiedOriginsPolicy',
#superclass : 'AllowOriginPolicy',
#name : #AllowSpecifiedOriginsPolicy,
#superclass : #AllowOriginPolicy,
#instVars : [
'allowedOrigins'
],
#category : 'Stargate-Model-CORS',
#package : 'Stargate-Model',
#tag : 'CORS'
#category : 'Stargate-Model-CORS'
}

{ #category : 'instance creation' }
{ #category : #'instance creation' }
AllowSpecifiedOriginsPolicy class >> onlyFrom: anUrlCollection [

^ self new initializeOnlyFrom: ( anUrlCollection collect: #asWebOrigin )
]

{ #category : 'configuring headers' }
{ #category : #'configuring headers' }
AllowSpecifiedOriginsPolicy >> applyOn: aResponse for: aRequest using: aHandler [

| requestOrigin |
Expand All @@ -34,7 +32,7 @@ AllowSpecifiedOriginsPolicy >> applyOn: aResponse for: aRequest using: aHandler
ifNone: [ aRequest abort: TeaResponse noContent ]
]

{ #category : 'initialization' }
{ #category : #initialization }
AllowSpecifiedOriginsPolicy >> initializeOnlyFrom: origins [

allowedOrigins := origins
Expand Down
24 changes: 11 additions & 13 deletions source/Stargate-Model/AuthenticationFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
I'm an abstract class representing an authentication filter to be applied as a before filter and perform an auth validation. I will take into consideration the Authorization header on the request and return a 401 / Unauthorized in case the credentials are invalid.
"
Class {
#name : 'AuthenticationFilter',
#superclass : 'Object',
#category : 'Stargate-Model-Auth',
#package : 'Stargate-Model',
#tag : 'Auth'
#name : #AuthenticationFilter,
#superclass : #Object,
#category : 'Stargate-Model-Auth'
}

{ #category : 'instance creation' }
{ #category : #'instance creation' }
AuthenticationFilter class >> basedOn: configuration [

^ self allSubclasses
Expand All @@ -18,37 +16,37 @@ AuthenticationFilter class >> basedOn: configuration [
ifNone: [ self signalMissingConfiguration ]
]

{ #category : 'private' }
{ #category : #private }
AuthenticationFilter class >> canHandle: configuration [

^ self subclassResponsibility
]

{ #category : 'private' }
{ #category : #private }
AuthenticationFilter class >> configuredBy: configuration [

^ self subclassResponsibility
]

{ #category : 'private' }
{ #category : #private }
AuthenticationFilter class >> signalMissingConfiguration [

^ ObjectNotFound signal: 'Missing authentication configuration'
]

{ #category : 'accessing' }
{ #category : #accessing }
AuthenticationFilter >> authChallenge [

^ self subclassResponsibility
]

{ #category : 'private' }
{ #category : #private }
AuthenticationFilter >> checkCredentials: authorization for: httpRequest within: requestContext ifInvalid: aBlock [

self subclassResponsibility
]

{ #category : 'evaluating' }
{ #category : #evaluating }
AuthenticationFilter >> evaluateActionOnRequest: httpRequest within: requestContext [

| authorization |
Expand All @@ -63,7 +61,7 @@ AuthenticationFilter >> evaluateActionOnRequest: httpRequest within: requestCont
ifInvalid: [ httpRequest abort: ( ZnResponse unauthorized: self authChallenge ) ]
]

{ #category : 'evaluating' }
{ #category : #evaluating }
AuthenticationFilter >> teaEvalActionOnRequest: httpRequest [

self evaluateActionOnRequest: httpRequest within: HttpRequestContext new
Expand Down
58 changes: 28 additions & 30 deletions source/Stargate-Model/CachingDirectivesBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
I'm a builder of caching headers, translating a Smalltalk expression inside a block into a command that adds a cache-control header (and the expires header) to the response before being sent.
"
Class {
#name : 'CachingDirectivesBuilder',
#superclass : 'Object',
#name : #CachingDirectivesBuilder,
#superclass : #Object,
#instVars : [
'directives',
'currentCondition'
],
#category : 'Stargate-Model-Caching',
#package : 'Stargate-Model',
#tag : 'Caching'
#category : 'Stargate-Model-Caching'
}

{ #category : 'private' }
{ #category : #private }
CachingDirectivesBuilder >> addCacheControlNamed: aName [

| condition |
Expand All @@ -24,25 +22,25 @@ CachingDirectivesBuilder >> addCacheControlNamed: aName [
[ :response :context :resource | ( condition cull: response cull: resource ) then: [ response addCachingDirective: aName ] ]
]

{ #category : 'private' }
{ #category : #private }
CachingDirectivesBuilder >> addCacheControlNamed: aName withString: aString [

self addCacheControlNamed: ( '<1s>="<2s>"' expandMacrosWith: aName with: aString )
]

{ #category : 'private' }
{ #category : #private }
CachingDirectivesBuilder >> addCacheControlNamed: aName withToken: aValue [

self addCacheControlNamed: ( '<1s>=<2p>' expandMacrosWith: aName with: aValue )
]

{ #category : 'private' }
{ #category : #private }
CachingDirectivesBuilder >> alwaysApplyDirectives [

currentCondition := [ :response | true ]
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> beAvailableFor: aDuration [

^ self
Expand All @@ -51,19 +49,19 @@ CachingDirectivesBuilder >> beAvailableFor: aDuration [
expireIn: aDuration
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> beImmutable [

self addCacheControlNamed: 'immutable'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> bePrivate [

self addCacheControlNamed: 'private'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> bePrivateRestrictedTo: aFieldNameCollection [

| fieldsString |
Expand All @@ -72,37 +70,37 @@ CachingDirectivesBuilder >> bePrivateRestrictedTo: aFieldNameCollection [
self addCacheControlNamed: 'private' withString: fieldsString
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> bePublic [

self addCacheControlNamed: 'public'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> beStaleAfter: aDuration [

self addCacheControlNamed: 'Max-Age' withToken: aDuration asSeconds
]

{ #category : 'building' }
{ #category : #building }
CachingDirectivesBuilder >> build [

^ directives
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> configureUsing: aBlock [

aBlock cull: self
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> doNotCache [

self addCacheControlNamed: 'no-cache'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> doNotCacheRestrictedTo: aFieldNameCollection [

| fieldsString |
Expand All @@ -111,27 +109,27 @@ CachingDirectivesBuilder >> doNotCacheRestrictedTo: aFieldNameCollection [
self addCacheControlNamed: 'no-cache' withString: fieldsString
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> doNotExpire [

^ self
beImmutable;
beAvailableFor: 365000000 seconds
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> doNotStore [

self addCacheControlNamed: 'no-store'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> doNotTransform [

self addCacheControlNamed: 'no-transform'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> expireIn: aDuration [

| condition |
Expand All @@ -144,7 +142,7 @@ CachingDirectivesBuilder >> expireIn: aDuration [
]
]

{ #category : 'private' }
{ #category : #private }
CachingDirectivesBuilder >> fieldStringFor: aFieldNameCollection [

^ String
Expand All @@ -158,29 +156,29 @@ CachingDirectivesBuilder >> fieldStringFor: aFieldNameCollection [
]
]

{ #category : 'initialization' }
{ #category : #initialization }
CachingDirectivesBuilder >> initialize [

super initialize.
directives := OrderedCollection new.
self alwaysApplyDirectives
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> mustRevalidate [

self addCacheControlNamed: 'must-revalidate'
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> requireRevalidation [

self
doNotCache;
beStaleAfter: 0 seconds
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> when: aResponseCondition apply: aDirectiveConfiguration [

[ currentCondition := aResponseCondition.
Expand All @@ -189,13 +187,13 @@ CachingDirectivesBuilder >> when: aResponseCondition apply: aDirectiveConfigurat
ensure: [ self alwaysApplyDirectives ]
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> whenSharedBeStaleAfter: aDuration [

self addCacheControlNamed: 'S-MaxAge' withToken: aDuration asSeconds
]

{ #category : 'configuring' }
{ #category : #configuring }
CachingDirectivesBuilder >> whenSharedMustRevalidate [

self addCacheControlNamed: 'proxy-revalidate'
Expand Down
Loading

0 comments on commit 3b55fb9

Please sign in to comment.