jwt_auth_cognito 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +78 -0
- data/BITBUCKET-DEPLOYMENT.md +290 -0
- data/CHANGELOG.md +76 -0
- data/CLAUDE.md +189 -9
- data/Gemfile +5 -5
- data/README.md +147 -1
- data/Rakefile +108 -5
- data/VERSIONING.md +244 -0
- data/bitbucket-pipelines.yml +266 -0
- data/jwt_auth_cognito.gemspec +43 -36
- data/lib/generators/jwt_auth_cognito/install_generator.rb +25 -25
- data/lib/jwt_auth_cognito/api_key_validator.rb +79 -0
- data/lib/jwt_auth_cognito/configuration.rb +38 -21
- data/lib/jwt_auth_cognito/error_utils.rb +110 -0
- data/lib/jwt_auth_cognito/jwks_service.rb +46 -50
- data/lib/jwt_auth_cognito/jwt_validator.rb +169 -91
- data/lib/jwt_auth_cognito/railtie.rb +3 -3
- data/lib/jwt_auth_cognito/redis_service.rb +90 -51
- data/lib/jwt_auth_cognito/ssm_service.rb +109 -0
- data/lib/jwt_auth_cognito/token_blacklist_service.rb +10 -12
- data/lib/jwt_auth_cognito/user_data_service.rb +332 -0
- data/lib/jwt_auth_cognito/version.rb +2 -2
- data/lib/jwt_auth_cognito.rb +42 -10
- data/lib/tasks/jwt_auth_cognito.rake +69 -70
- metadata +68 -27
data/CLAUDE.md
CHANGED
@@ -23,9 +23,12 @@ bundle exec rspec spec/jwt_auth_cognito/configuration_spec.rb
|
|
23
23
|
|
24
24
|
# Test basic functionality
|
25
25
|
ruby examples/simple_test.rb
|
26
|
+
|
27
|
+
# Test SSM certificate functionality
|
28
|
+
ruby examples/test_installation.rb
|
26
29
|
```
|
27
30
|
|
28
|
-
### Gem Management
|
31
|
+
### Gem Management and Versioning
|
29
32
|
```bash
|
30
33
|
# Build the gem
|
31
34
|
gem build jwt_auth_cognito.gemspec
|
@@ -34,7 +37,22 @@ gem build jwt_auth_cognito.gemspec
|
|
34
37
|
bundle exec rake install
|
35
38
|
|
36
39
|
# Test gem packaging
|
37
|
-
gem contents jwt_auth_cognito-0.
|
40
|
+
gem contents jwt_auth_cognito-0.2.0.gem
|
41
|
+
|
42
|
+
# Version management (Git Flow compatible)
|
43
|
+
rake version:alpha # Create alpha version from feature branches
|
44
|
+
rake version:beta # Create beta version from develop branch
|
45
|
+
rake version:rc # Create release candidate from release branches
|
46
|
+
|
47
|
+
# Full release process
|
48
|
+
rake release:develop # Beta release (develop branch)
|
49
|
+
rake release:rc # Release candidate
|
50
|
+
rake release:stable # Stable release (requires confirmation)
|
51
|
+
|
52
|
+
# Direct publishing
|
53
|
+
rake publish:beta # Build and publish beta version
|
54
|
+
rake publish:rc # Build and publish RC version
|
55
|
+
rake publish:stable # Build and publish stable (requires confirmation)
|
38
56
|
```
|
39
57
|
|
40
58
|
### Configuration Generation
|
@@ -52,33 +70,75 @@ rake jwt_auth_cognito:test_cognito # Test Cognito connection
|
|
52
70
|
## Architecture Overview
|
53
71
|
|
54
72
|
### Core Components
|
55
|
-
- **JwtValidator**: Main validation orchestrator that coordinates JWKS validation and
|
73
|
+
- **JwtValidator**: Main validation orchestrator that coordinates JWKS validation, blacklist checking, and user data retrieval
|
56
74
|
- **JwksService**: Handles AWS Cognito JWKS fetching, caching, and signature validation
|
57
75
|
- **RedisService**: Low-level Redis operations with comprehensive TLS support and retry logic
|
58
76
|
- **TokenBlacklistService**: High-level token revocation and blacklist management
|
77
|
+
- **UserDataService**: User data retrieval from Redis with caching and auth-service compatibility
|
78
|
+
- **ErrorUtils**: Centralized error handling and categorization system
|
79
|
+
- **SSMService**: AWS Parameter Store integration for secure certificate management (auth-service compatible)
|
59
80
|
- **Configuration**: Centralized configuration with environment variable fallbacks
|
60
81
|
|
61
82
|
### Key Design Patterns
|
62
83
|
|
63
|
-
**Service Layer Architecture**: Each major functionality (JWT validation, JWKS handling, Redis operations, blacklisting) is isolated into dedicated service classes that can be used independently or orchestrated through JwtValidator.
|
84
|
+
**Service Layer Architecture**: Each major functionality (JWT validation, JWKS handling, Redis operations, blacklisting, user data retrieval) is isolated into dedicated service classes that can be used independently or orchestrated through JwtValidator.
|
64
85
|
|
65
86
|
**Configuration Management**: Dual configuration approach supporting both programmatic configuration and environment variables, with automatic fallback chain for maximum flexibility.
|
66
87
|
|
67
|
-
**Error Hierarchy**: Comprehensive error types
|
88
|
+
**Error Hierarchy**: Comprehensive error types with centralized ErrorUtils for consistent error handling and user-friendly messages.
|
68
89
|
|
69
90
|
**Compatibility Layer**: Designed to match the API and behavior of the Node.js auth package, ensuring consistent functionality across language implementations.
|
70
91
|
|
92
|
+
**Caching Strategy**: Multi-layer caching (JWKS cache + UserData cache) with configurable TTL and intelligent cache invalidation.
|
93
|
+
|
71
94
|
### Redis Architecture
|
72
95
|
- **Connection Management**: Single connection with comprehensive TLS support including certificate validation
|
96
|
+
- **Certificate Loading**: Multi-source certificate loading (SSM → File → Environment) for maximum flexibility
|
73
97
|
- **Retry Logic**: Exponential backoff for failed operations
|
74
98
|
- **Blacklist Strategy**: Uses Redis sets with automatic TTL management for token revocation
|
75
99
|
- **User Token Tracking**: Maintains user-to-tokens mapping for bulk revocation capabilities
|
76
100
|
|
101
|
+
### ✅ **SSM Parameter Store Integration** - NEW December 2024
|
102
|
+
|
103
|
+
**Complete auth-service compatibility for certificate management:**
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
# Priority order for certificate loading:
|
107
|
+
# 1. AWS SSM Parameter Store (for auth-service compatibility)
|
108
|
+
# 2. Local file system
|
109
|
+
# 3. Environment variable
|
110
|
+
|
111
|
+
# SSM configuration (matching auth-service pattern)
|
112
|
+
config.redis_ca_cert_ssm_path = "certificates" # SSM path segment
|
113
|
+
config.redis_ca_cert_ssm_name = "redis-ca.pem" # Certificate name
|
114
|
+
# Results in SSM parameter: /certificates/redis-ca.pem
|
115
|
+
|
116
|
+
# Automatic fallback to file system
|
117
|
+
config.redis_ca_cert_path = "/path/to/certs"
|
118
|
+
config.redis_ca_cert_name = "ca.pem"
|
119
|
+
|
120
|
+
# Environment variable fallback
|
121
|
+
ENV['REDIS_CA_CERT'] = "-----BEGIN CERTIFICATE-----..."
|
122
|
+
```
|
123
|
+
|
77
124
|
### JWT Validation Flow
|
78
125
|
1. **Structure Validation**: Basic JWT format and claims validation
|
79
126
|
2. **Blacklist Check**: Fast Redis lookup for revoked tokens
|
80
127
|
3. **JWKS Validation**: Signature verification against Cognito public keys (secure mode only)
|
81
128
|
4. **Claims Validation**: Audience, issuer, expiration, and custom claims validation
|
129
|
+
5. **User Data Enrichment** (optional): Retrieval of user permissions, organizations, and applications
|
130
|
+
|
131
|
+
### UserDataService Architecture
|
132
|
+
- **Redis Key Patterns**: Compatible with auth-service patterns
|
133
|
+
- `user:permissions:{userId}` - User permission data
|
134
|
+
- `app:{appId}` - Application metadata
|
135
|
+
- `org:{appId}:{organizationId}` - Organization data
|
136
|
+
- `app:roles:{appId}:{organizationId}` - Role definitions
|
137
|
+
- `app-schemas` - Application schema definitions
|
138
|
+
- `permissions:cache:{userId}:{appId}:{orgId}` - Effective permissions cache
|
139
|
+
- **Caching Strategy**: In-memory cache with configurable TTL per data type
|
140
|
+
- **Data Composition**: Intelligent composition of user organizations with role and permission data
|
141
|
+
- **Graceful Degradation**: Service continues operation even if user data retrieval fails
|
82
142
|
|
83
143
|
### Client Secret Support
|
84
144
|
- **Optional Enhancement**: HMAC-SHA256 secret hash calculation matching AWS Cognito requirements
|
@@ -89,9 +149,69 @@ rake jwt_auth_cognito:test_cognito # Test Cognito connection
|
|
89
149
|
|
90
150
|
The gem supports extensive environment variable configuration for deployment flexibility:
|
91
151
|
|
92
|
-
|
93
|
-
|
94
|
-
-
|
152
|
+
### AWS Cognito Configuration
|
153
|
+
```bash
|
154
|
+
COGNITO_REGION=us-east-1
|
155
|
+
COGNITO_USER_POOL_ID=us-east-1_AbCdEfGhI
|
156
|
+
COGNITO_CLIENT_ID=your-client-id
|
157
|
+
COGNITO_CLIENT_SECRET=your-client-secret # Optional for enhanced security
|
158
|
+
```
|
159
|
+
|
160
|
+
### Redis Configuration
|
161
|
+
```bash
|
162
|
+
REDIS_HOST=localhost
|
163
|
+
REDIS_PORT=6379
|
164
|
+
REDIS_PASSWORD=your-password
|
165
|
+
REDIS_DB=0
|
166
|
+
REDIS_TLS=true # Enable TLS connection
|
167
|
+
REDIS_TIMEOUT=5
|
168
|
+
REDIS_CONNECT_TIMEOUT=10
|
169
|
+
REDIS_READ_TIMEOUT=10
|
170
|
+
```
|
171
|
+
|
172
|
+
### TLS/SSL Certificate Configuration
|
173
|
+
```bash
|
174
|
+
# AWS SSM Parameter Store (recommended for auth-service compatibility)
|
175
|
+
REDIS_CA_CERT_SSM_PATH=certificates
|
176
|
+
REDIS_CA_CERT_SSM_NAME=redis-ca.pem
|
177
|
+
|
178
|
+
# Local file system fallback
|
179
|
+
REDIS_CA_CERT_PATH=/path/to/certs
|
180
|
+
REDIS_CA_CERT_NAME=ca.pem
|
181
|
+
|
182
|
+
# Direct certificate content fallback
|
183
|
+
REDIS_CA_CERT="-----BEGIN CERTIFICATE-----..."
|
184
|
+
|
185
|
+
# TLS settings
|
186
|
+
REDIS_VERIFY_MODE=peer # 'peer' or 'none'
|
187
|
+
REDIS_TLS_MIN_VERSION=TLSv1.2
|
188
|
+
REDIS_TLS_MAX_VERSION=TLSv1.3
|
189
|
+
```
|
190
|
+
|
191
|
+
### AWS Configuration (for SSM)
|
192
|
+
```bash
|
193
|
+
AWS_REGION=us-east-1
|
194
|
+
AWS_ACCESS_KEY_ID=your-access-key
|
195
|
+
AWS_SECRET_ACCESS_KEY=your-secret-key
|
196
|
+
# Or use IAM roles/instance profiles
|
197
|
+
```
|
198
|
+
|
199
|
+
### User Data Service Configuration
|
200
|
+
```bash
|
201
|
+
# User data retrieval settings
|
202
|
+
ENABLE_USER_DATA_RETRIEVAL=true
|
203
|
+
INCLUDE_APPLICATIONS=true
|
204
|
+
INCLUDE_ORGANIZATIONS=true
|
205
|
+
INCLUDE_ROLES=true
|
206
|
+
INCLUDE_EFFECTIVE_PERMISSIONS=false
|
207
|
+
USER_DATA_CACHE_TIMEOUT=300 # 5 minutes
|
208
|
+
```
|
209
|
+
|
210
|
+
### Caching and Performance
|
211
|
+
```bash
|
212
|
+
JWKS_CACHE_TTL=3600 # 1 hour
|
213
|
+
```
|
214
|
+
|
95
215
|
- Automatic Rails environment detection for validation mode selection
|
96
216
|
|
97
217
|
## Rails Integration
|
@@ -121,6 +241,17 @@ The gem supports extensive environment variable configuration for deployment fle
|
|
121
241
|
|
122
242
|
## Version Compatibility
|
123
243
|
|
244
|
+
### ✅ **Updated January 2025 - Version 0.3.0**
|
245
|
+
|
246
|
+
**Major feature expansion with UserDataService and deployment automation**
|
247
|
+
|
248
|
+
- ✅ UserDataService with auth-service compatibility
|
249
|
+
- ✅ Enhanced error handling with ErrorUtils
|
250
|
+
- ✅ Enriched token validation with user context
|
251
|
+
- ✅ Automated CI/CD pipeline with Bitbucket
|
252
|
+
- ✅ Synchronized feature set with Node.js package (maintaining independent versioning)
|
253
|
+
- ✅ Maintains consistent API across language implementations
|
254
|
+
|
124
255
|
Designed for compatibility with legacy Rails applications:
|
125
256
|
- **Ruby**: >= 2.7.0 (compatible with llegando-neo Ruby 2.7.5)
|
126
257
|
- **Rails**: >= 5.0 (compatible with llegando-neo Rails 5.2.6)
|
@@ -128,8 +259,57 @@ Designed for compatibility with legacy Rails applications:
|
|
128
259
|
|
129
260
|
## Publishing and Distribution
|
130
261
|
|
262
|
+
### Automated CI/CD Pipeline
|
263
|
+
|
264
|
+
The gem uses Bitbucket Pipelines for automated deployment to RubyGems.org:
|
265
|
+
|
266
|
+
#### Pipeline Configuration
|
267
|
+
- **Beta releases** (`v*-beta.*`): Automatic deployment
|
268
|
+
- **RC releases** (`v*-rc.*`): Automatic deployment
|
269
|
+
- **Stable releases** (`v[0-9]*.*`): Manual deployment with confirmation
|
270
|
+
- **Testing**: Automated on all branches with comprehensive test suite
|
271
|
+
|
272
|
+
#### Deployment Commands
|
273
|
+
|
274
|
+
#### Automatic Beta Deployment (Recommended)
|
275
|
+
```bash
|
276
|
+
# Simply merge/push to develop - automatic beta deployment
|
277
|
+
git checkout develop
|
278
|
+
git merge feature/your-feature
|
279
|
+
git push origin develop
|
280
|
+
# → Pipeline automatically creates and publishes beta version
|
281
|
+
```
|
282
|
+
|
283
|
+
#### Manual Tag Deployment (Alternative)
|
284
|
+
```bash
|
285
|
+
# Beta release
|
286
|
+
git tag v0.3.0-beta.1 && git push origin v0.3.0-beta.1
|
287
|
+
|
288
|
+
# RC release
|
289
|
+
git tag v0.3.0-rc.1 && git push origin v0.3.0-rc.1
|
290
|
+
|
291
|
+
# Stable release
|
292
|
+
git tag v0.3.0 && git push origin v0.3.0
|
293
|
+
```
|
294
|
+
|
295
|
+
#### Helper Scripts
|
296
|
+
- `scripts/generate_rubygems_token.rb`: Generate RubyGems API key instructions
|
297
|
+
- `scripts/test_rubygems_token.rb`: Validate local token configuration
|
298
|
+
- `scripts/deployment_helper.rb`: Complete deployment assistant
|
299
|
+
- `scripts/setup_rubygems_deployment.md`: Detailed deployment documentation
|
300
|
+
|
301
|
+
#### Manual Pipelines (Bitbucket)
|
302
|
+
- `full-release-beta`: Complete beta release with versioning
|
303
|
+
- `full-release-rc`: Complete RC release with versioning
|
304
|
+
- `full-release-stable`: Complete stable release (requires confirmation)
|
305
|
+
- `test-build`: Build testing without deployment
|
306
|
+
|
307
|
+
### Gem Metadata
|
131
308
|
The gem is prepared for RubyGems.org publication with:
|
132
309
|
- Complete gemspec with metadata
|
133
310
|
- Proper file inclusion patterns
|
134
311
|
- Version compatibility constraints
|
135
|
-
- MIT license and documentation
|
312
|
+
- MIT license and comprehensive documentation
|
313
|
+
- Automated deployment pipeline
|
314
|
+
- Security best practices for token management
|
315
|
+
- actualiza los archivos de documentación cada vez que se haga un cambio si es necesario
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
7
|
+
gem 'rake', '~> 13.0'
|
8
|
+
gem 'rspec', '~> 3.0'
|
9
|
+
gem 'rubocop', '~> 1.21'
|
10
|
+
gem 'webmock', '~> 3.0'
|
data/README.md
CHANGED
@@ -10,7 +10,9 @@ Una gema Ruby para validar tokens JWT de AWS Cognito de forma offline con funcio
|
|
10
10
|
- **Configuración Flexible**: Soporte para modos de validación seguro (producción) y básico (desarrollo)
|
11
11
|
- **Gestión de Tokens de Usuario**: Rastrear e invalidar todos los tokens de un usuario específico
|
12
12
|
- **Múltiples Tipos de Token**: Soporte para access tokens e ID tokens
|
13
|
-
- **
|
13
|
+
- **UserDataService**: Recuperación de datos de usuario, permisos y organizaciones desde Redis
|
14
|
+
- **Validación Enriquecida**: Validación de tokens con datos contextuales del usuario
|
15
|
+
- **Manejo Integral de Errores**: Degradación elegante y manejo consistente de errores
|
14
16
|
- **Soporte TLS Avanzado**: Configuración completa de TLS para Redis con certificados CA
|
15
17
|
|
16
18
|
## Instalación
|
@@ -120,6 +122,81 @@ result = validator.validate_access_token(jwt_token)
|
|
120
122
|
result = validator.validate_id_token(jwt_token)
|
121
123
|
```
|
122
124
|
|
125
|
+
### Validación Enriquecida con UserDataService (Nuevo v0.3.0)
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
# Configurar UserDataService
|
129
|
+
JwtAuthCognito.configure do |config|
|
130
|
+
# ... configuración básica ...
|
131
|
+
config.enable_user_data_retrieval = true
|
132
|
+
end
|
133
|
+
|
134
|
+
validator = JwtAuthCognito::JwtValidator.new
|
135
|
+
validator.initialize! # Inicializar servicios
|
136
|
+
|
137
|
+
# Validación enriquecida con datos de usuario desde Redis
|
138
|
+
result = validator.validate_token_enriched(jwt_token)
|
139
|
+
|
140
|
+
if result[:valid]
|
141
|
+
puts "Token válido!"
|
142
|
+
puts "Usuario: #{result[:sub]}"
|
143
|
+
|
144
|
+
# Datos adicionales del usuario
|
145
|
+
if result[:user_permissions]
|
146
|
+
puts "Apps con permisos: #{result[:user_permissions]['permissions'].keys}"
|
147
|
+
end
|
148
|
+
|
149
|
+
if result[:user_organizations]&.any?
|
150
|
+
puts "Organizaciones activas:"
|
151
|
+
result[:user_organizations].each do |org|
|
152
|
+
puts " - #{org['organizationId']} (roles: #{org['roles'].join(', ')})"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
if result[:applications]&.any?
|
157
|
+
puts "Aplicaciones disponibles: #{result[:applications].map { |app| app['name'] }.join(', ')}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
162
|
+
### Factory Method para Configuración Simplificada (Nuevo v0.3.0)
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
# Crear validador con una línea
|
166
|
+
validator = JwtAuthCognito.create_cognito_validator(
|
167
|
+
region: 'us-east-1',
|
168
|
+
user_pool_id: 'us-east-1_ExamplePool',
|
169
|
+
client_id: 'your-client-id',
|
170
|
+
redis_config: {
|
171
|
+
host: 'localhost',
|
172
|
+
port: 6379,
|
173
|
+
tls: true
|
174
|
+
},
|
175
|
+
enable_user_data_retrieval: true
|
176
|
+
)
|
177
|
+
|
178
|
+
# Usar inmediatamente
|
179
|
+
result = validator.validate_token_enriched(token)
|
180
|
+
```
|
181
|
+
|
182
|
+
### Manejo Mejorado de Errores (Nuevo v0.3.0)
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
begin
|
186
|
+
result = validator.validate_token(token)
|
187
|
+
rescue => error
|
188
|
+
# ErrorUtils proporciona mensajes consistentes
|
189
|
+
error_details = JwtAuthCognito::ErrorUtils.extract_error_details(error)
|
190
|
+
|
191
|
+
puts "Error: #{error_details[:message]}"
|
192
|
+
puts "Código: #{error_details[:code]}" if error_details[:code]
|
193
|
+
|
194
|
+
# Para APIs - respuesta estandarizada
|
195
|
+
api_response = JwtAuthCognito::ErrorUtils.format_validation_error(error)
|
196
|
+
# Retorna: { valid: false, error: "mensaje", error_code: "CODIGO" }
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
123
200
|
### Opciones Avanzadas de Validación
|
124
201
|
|
125
202
|
```ruby
|
@@ -382,3 +459,72 @@ Esto generará automáticamente:
|
|
382
459
|
- `config/initializers/jwt_auth_cognito.rb` - Archivo de configuración
|
383
460
|
- `.env.example` - Variables de entorno de ejemplo
|
384
461
|
- Configuración optimizada para tu proyecto Rails
|
462
|
+
|
463
|
+
## Deployment y CI/CD
|
464
|
+
|
465
|
+
### Configuración de Deployment Automático
|
466
|
+
|
467
|
+
Este gem utiliza Bitbucket Pipelines para deployment automático a RubyGems.org:
|
468
|
+
|
469
|
+
#### 1. Configurar Token de RubyGems
|
470
|
+
|
471
|
+
```bash
|
472
|
+
# Obtener instrucciones para el token
|
473
|
+
ruby scripts/generate_rubygems_token.rb
|
474
|
+
|
475
|
+
# Probar configuración local (opcional)
|
476
|
+
export RUBYGEMS_API_KEY='tu_token_aqui'
|
477
|
+
ruby scripts/test_rubygems_token.rb
|
478
|
+
```
|
479
|
+
|
480
|
+
#### 2. Variables de Bitbucket
|
481
|
+
|
482
|
+
En tu repositorio de Bitbucket:
|
483
|
+
- Settings → Repository variables
|
484
|
+
- Añadir variable: `RUBYGEMS_API_KEY` (marcada como secured)
|
485
|
+
|
486
|
+
#### 3. Comandos de Release
|
487
|
+
|
488
|
+
```bash
|
489
|
+
# Release Beta
|
490
|
+
git tag v0.3.0-beta.1
|
491
|
+
git push origin v0.3.0-beta.1
|
492
|
+
|
493
|
+
# Release RC
|
494
|
+
git tag v0.3.0-rc.1
|
495
|
+
git push origin v0.3.0-rc.1
|
496
|
+
|
497
|
+
# Release Estable (requiere confirmación manual)
|
498
|
+
git tag v0.3.0
|
499
|
+
git push origin v0.3.0
|
500
|
+
```
|
501
|
+
|
502
|
+
#### 4. Pipelines Manuales
|
503
|
+
|
504
|
+
En Bitbucket Pipelines → Run custom pipeline:
|
505
|
+
- `full-release-beta` - Release completo beta
|
506
|
+
- `full-release-rc` - Release completo RC
|
507
|
+
- `full-release-stable` - Release completo estable (requiere confirmación)
|
508
|
+
- `test-build` - Solo testing del build
|
509
|
+
|
510
|
+
#### 5. Helper de Deployment
|
511
|
+
|
512
|
+
```bash
|
513
|
+
# Ver estado y comandos disponibles
|
514
|
+
ruby scripts/deployment_helper.rb
|
515
|
+
|
516
|
+
# Ver comandos específicos
|
517
|
+
ruby scripts/deployment_helper.rb commands
|
518
|
+
|
519
|
+
# Ver configuración necesaria
|
520
|
+
ruby scripts/deployment_helper.rb setup
|
521
|
+
```
|
522
|
+
|
523
|
+
### Flujo de Trabajo Recomendado
|
524
|
+
|
525
|
+
1. **Desarrollo**: Trabajo en feature branches
|
526
|
+
2. **Beta**: Merge a `develop` → Tag beta → Deploy automático
|
527
|
+
3. **RC**: Release branch → Tag RC → Deploy automático
|
528
|
+
4. **Producción**: Merge a `main` → Tag estable → Deploy manual
|
529
|
+
|
530
|
+
Para más detalles, ver: `scripts/setup_rubygems_deployment.md`
|
data/Rakefile
CHANGED
@@ -1,11 +1,114 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
6
|
|
7
7
|
RSpec::Core::RakeTask.new(:spec)
|
8
8
|
RuboCop::RakeTask.new
|
9
9
|
|
10
|
-
desc
|
11
|
-
task default: %i[spec rubocop]
|
10
|
+
desc 'Run tests'
|
11
|
+
task default: %i[spec rubocop]
|
12
|
+
|
13
|
+
# Version management tasks (Git Flow compatible)
|
14
|
+
namespace :version do
|
15
|
+
desc 'Create alpha version from feature branches'
|
16
|
+
task :alpha do
|
17
|
+
system('ruby scripts/version_manager.rb alpha')
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Create beta version from develop branch'
|
21
|
+
task :beta do
|
22
|
+
system('ruby scripts/version_manager.rb beta')
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Create release candidate from release/ branches'
|
26
|
+
task :rc do
|
27
|
+
system('ruby scripts/version_manager.rb rc')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Release tasks
|
32
|
+
namespace :release do
|
33
|
+
desc 'Release development beta version (versioning + build + publish)'
|
34
|
+
task develop: ['version:beta'] do
|
35
|
+
Rake::Task['build'].invoke
|
36
|
+
puts '📦 Gema construida exitosamente'
|
37
|
+
puts ''
|
38
|
+
puts '🚀 Para publicar en RubyGems:'
|
39
|
+
version = get_current_version
|
40
|
+
puts " gem push jwt_auth_cognito-#{version}.gem"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Release candidate version (versioning + build + publish)'
|
44
|
+
task rc: ['version:rc'] do
|
45
|
+
Rake::Task['build'].invoke
|
46
|
+
puts '📦 Gema construida exitosamente'
|
47
|
+
puts ''
|
48
|
+
puts '🚀 Para publicar en RubyGems:'
|
49
|
+
version = get_current_version
|
50
|
+
puts " gem push jwt_auth_cognito-#{version}.gem"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Release stable version (versioning + build + confirm + publish)'
|
54
|
+
task :stable do
|
55
|
+
puts '⚠️ Esta es una release estable. ¿Continuar? (y/N)'
|
56
|
+
response = $stdin.gets.chomp
|
57
|
+
|
58
|
+
if %w[y yes].include?(response.downcase)
|
59
|
+
system('ruby scripts/version_manager.rb stable')
|
60
|
+
Rake::Task['build'].invoke
|
61
|
+
puts '📦 Gema construida exitosamente'
|
62
|
+
puts ''
|
63
|
+
puts '🚀 Para publicar en RubyGems:'
|
64
|
+
version = get_current_version
|
65
|
+
puts " gem push jwt_auth_cognito-#{version}.gem"
|
66
|
+
else
|
67
|
+
puts '❌ Release cancelada'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Build and publish tasks
|
73
|
+
namespace :publish do
|
74
|
+
desc 'Build and publish beta version'
|
75
|
+
task :beta do
|
76
|
+
Rake::Task['build'].invoke
|
77
|
+
version = get_current_version
|
78
|
+
system("gem push jwt_auth_cognito-#{version}.gem")
|
79
|
+
end
|
80
|
+
|
81
|
+
desc 'Build and publish RC version'
|
82
|
+
task :rc do
|
83
|
+
Rake::Task['build'].invoke
|
84
|
+
version = get_current_version
|
85
|
+
system("gem push jwt_auth_cognito-#{version}.gem")
|
86
|
+
end
|
87
|
+
|
88
|
+
desc 'Build and publish alpha version'
|
89
|
+
task :alpha do
|
90
|
+
Rake::Task['build'].invoke
|
91
|
+
version = get_current_version
|
92
|
+
system("gem push jwt_auth_cognito-#{version}.gem")
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'Build and publish stable version'
|
96
|
+
task :stable do
|
97
|
+
puts '⚠️ Esta es una publicación estable. ¿Continuar? (y/N)'
|
98
|
+
response = $stdin.gets.chomp
|
99
|
+
|
100
|
+
if %w[y yes].include?(response.downcase)
|
101
|
+
Rake::Task['build'].invoke
|
102
|
+
version = get_current_version
|
103
|
+
system("gem push jwt_auth_cognito-#{version}.gem")
|
104
|
+
else
|
105
|
+
puts '❌ Publicación cancelada'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Helper method to get current version
|
111
|
+
def get_current_version
|
112
|
+
require_relative 'lib/jwt_auth_cognito/version'
|
113
|
+
JwtAuthCognito::VERSION
|
114
|
+
end
|