mirror of
				https://github.com/steveiliop56/tinyauth.git
				synced 2025-10-30 21:55:43 +00:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			v4.0.0-rc.
			...
			ae8347fd28
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | ae8347fd28 | ||
|   | 76f2014444 | ||
|   | 5b7bda3378 | 
							
								
								
									
										2
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -23,7 +23,7 @@ jobs: | ||||
|       - name: Install frontend dependencies | ||||
|         run: | | ||||
|           cd frontend | ||||
|           bun install | ||||
|           bun install --frozen-lockfile | ||||
|  | ||||
|       - name: Set version | ||||
|         run: | | ||||
|   | ||||
							
								
								
									
										8
									
								
								.github/workflows/nightly.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/nightly.yml
									
									
									
									
										vendored
									
									
								
							| @@ -66,7 +66,7 @@ jobs: | ||||
|       - name: Install frontend dependencies | ||||
|         run: | | ||||
|           cd frontend | ||||
|           bun install | ||||
|           bun install --frozen-lockfile | ||||
|  | ||||
|       - name: Install backend dependencies | ||||
|         run: | | ||||
| @@ -112,7 +112,7 @@ jobs: | ||||
|       - name: Install frontend dependencies | ||||
|         run: | | ||||
|           cd frontend | ||||
|           bun install | ||||
|           bun install --frozen-lockfile | ||||
|  | ||||
|       - name: Install backend dependencies | ||||
|         run: | | ||||
| @@ -396,6 +396,8 @@ jobs: | ||||
|         uses: docker/metadata-action@v5 | ||||
|         with: | ||||
|           images: ghcr.io/${{ github.repository_owner }}/tinyauth | ||||
|           flavor: | | ||||
|             latest=false | ||||
|           tags: | | ||||
|             type=raw,nightly | ||||
|  | ||||
| @@ -433,6 +435,8 @@ jobs: | ||||
|         uses: docker/metadata-action@v5 | ||||
|         with: | ||||
|           images: ghcr.io/${{ github.repository_owner }}/tinyauth | ||||
|           flavor: | | ||||
|             latest=false | ||||
|           tags: | | ||||
|             type=raw,nightly-distroless | ||||
|  | ||||
|   | ||||
							
								
								
									
										23
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							| @@ -44,7 +44,7 @@ jobs: | ||||
|       - name: Install frontend dependencies | ||||
|         run: | | ||||
|           cd frontend | ||||
|           bun install | ||||
|           bun install --frozen-lockfile | ||||
|  | ||||
|       - name: Install backend dependencies | ||||
|         run: | | ||||
| @@ -87,7 +87,7 @@ jobs: | ||||
|       - name: Install frontend dependencies | ||||
|         run: | | ||||
|           cd frontend | ||||
|           bun install | ||||
|           bun install --frozen-lockfile | ||||
|  | ||||
|       - name: Install backend dependencies | ||||
|         run: | | ||||
| @@ -359,10 +359,13 @@ jobs: | ||||
|         uses: docker/metadata-action@v5 | ||||
|         with: | ||||
|           images: ghcr.io/${{ github.repository_owner }}/tinyauth | ||||
|           flavor: | | ||||
|             latest=true | ||||
|             prefix=v,onlatest=false | ||||
|           tags: | | ||||
|             type=semver,pattern={{version}},prefix=v | ||||
|             type=semver,pattern={{major}},prefix=v | ||||
|             type=semver,pattern={{major}}.{{minor}},prefix=v | ||||
|             type=semver,pattern={{version}} | ||||
|             type=semver,pattern={{major}} | ||||
|             type=semver,pattern={{major}}.{{minor}} | ||||
|  | ||||
|       - name: Create manifest list and push | ||||
|         working-directory: ${{ runner.temp }}/digests | ||||
| @@ -398,10 +401,14 @@ jobs: | ||||
|         uses: docker/metadata-action@v5 | ||||
|         with: | ||||
|           images: ghcr.io/${{ github.repository_owner }}/tinyauth | ||||
|           flavor: | | ||||
|             latest=false | ||||
|             prefix=v,onlatest=false | ||||
|             suffix=-distroless,onlatest=false | ||||
|           tags: | | ||||
|             type=semver,pattern={{version}},prefix=v,suffix=-distroless | ||||
|             type=semver,pattern={{major}},prefix=v,suffix=-distroless | ||||
|             type=semver,pattern={{major}}.{{minor}},prefix=v,suffix=-distroless | ||||
|             type=semver,pattern={{version}} | ||||
|             type=semver,pattern={{major}} | ||||
|             type=semver,pattern={{major}}.{{minor}} | ||||
|  | ||||
|       - name: Create manifest list and push | ||||
|         working-directory: ${{ runner.temp }}/digests | ||||
|   | ||||
| @@ -6,7 +6,7 @@ WORKDIR /frontend | ||||
| COPY ./frontend/package.json ./ | ||||
| COPY ./frontend/bun.lock ./ | ||||
|  | ||||
| RUN bun install | ||||
| RUN bun install --frozen-lockfile | ||||
|  | ||||
| COPY ./frontend/public ./public | ||||
| COPY ./frontend/src ./src | ||||
|   | ||||
| @@ -6,7 +6,7 @@ WORKDIR /frontend | ||||
| COPY ./frontend/package.json ./ | ||||
| COPY ./frontend/bun.lock ./ | ||||
|  | ||||
| RUN bun install | ||||
| RUN bun install --frozen-lockfile | ||||
|  | ||||
| COPY ./frontend/public ./public | ||||
| COPY ./frontend/src ./src | ||||
|   | ||||
| @@ -1,10 +1,12 @@ | ||||
| package middleware | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"io/fs" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| 	"tinyauth/internal/assets" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| @@ -27,14 +29,16 @@ func (m *UIMiddleware) Init() error { | ||||
| 	} | ||||
|  | ||||
| 	m.uiFs = ui | ||||
| 	m.uiFileServer = http.FileServer(http.FS(ui)) | ||||
| 	m.uiFileServer = http.FileServerFS(ui) | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *UIMiddleware) Middleware() gin.HandlerFunc { | ||||
| 	return func(c *gin.Context) { | ||||
| 		switch strings.Split(c.Request.URL.Path, "/")[1] { | ||||
| 		path := strings.TrimPrefix(c.Request.URL.Path, "/") | ||||
|  | ||||
| 		switch strings.SplitN(path, "/", 2)[0] { | ||||
| 		case "api": | ||||
| 			c.Next() | ||||
| 			return | ||||
| @@ -42,12 +46,19 @@ func (m *UIMiddleware) Middleware() gin.HandlerFunc { | ||||
| 			c.Next() | ||||
| 			return | ||||
| 		default: | ||||
| 			_, err := fs.Stat(m.uiFs, strings.TrimPrefix(c.Request.URL.Path, "/")) | ||||
| 			_, err := fs.Stat(m.uiFs, path) | ||||
|  | ||||
| 			// Enough for one authentication flow | ||||
| 			maxAge := 15 * time.Minute | ||||
|  | ||||
| 			if os.IsNotExist(err) { | ||||
| 				c.Request.URL.Path = "/" | ||||
| 			} else if strings.HasPrefix(path, "assets/") { | ||||
| 				// assets are named with a hash and can be cached for a long time | ||||
| 				maxAge = 30 * 24 * time.Hour | ||||
| 			} | ||||
|  | ||||
| 			c.Writer.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(maxAge.Seconds()))) | ||||
| 			m.uiFileServer.ServeHTTP(c.Writer, c.Request) | ||||
| 			c.Abort() | ||||
| 			return | ||||
|   | ||||
		Reference in New Issue
	
	Block a user