You've already forked oauth2-proxy
							
							
				mirror of
				https://github.com/oauth2-proxy/oauth2-proxy.git
				synced 2025-10-30 23:47:52 +02:00 
			
		
		
		
	Embed static stylesheets and dependencies
Embedding css and webfont dependencies allows the application to present itself correctly in an environment that does not allow downloading the files from a cdn. Inspiration taken from #1492 but reworked to make use of embed.FS simplifying the approach.
This commit is contained in:
		| @@ -2,6 +2,7 @@ package main | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"embed" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| @@ -50,6 +51,7 @@ const ( | ||||
| 	oauthCallbackPath = "/callback" | ||||
| 	authOnlyPath      = "/auth" | ||||
| 	userInfoPath      = "/userinfo" | ||||
| 	staticPathPrefix  = "/static/" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| @@ -58,6 +60,9 @@ var ( | ||||
|  | ||||
| 	// ErrAccessDenied means the user should receive a 401 Unauthorized response | ||||
| 	ErrAccessDenied = errors.New("access denied") | ||||
|  | ||||
| 	//go:embed static/* | ||||
| 	staticFiles embed.FS | ||||
| ) | ||||
|  | ||||
| // allowedRoute manages method + path based allowlists | ||||
| @@ -320,6 +325,9 @@ func (p *OAuthProxy) buildProxySubrouter(s *mux.Router) { | ||||
| 	s.Path(oauthStartPath).HandlerFunc(p.OAuthStart) | ||||
| 	s.Path(oauthCallbackPath).HandlerFunc(p.OAuthCallback) | ||||
|  | ||||
| 	// Static file paths | ||||
| 	s.PathPrefix(staticPathPrefix).Handler(http.StripPrefix(p.ProxyPrefix, http.FileServer(http.FS(staticFiles)))) | ||||
|  | ||||
| 	// The userinfo endpoint needs to load sessions before handling the request | ||||
| 	s.Path(userInfoPath).Handler(p.sessionChain.ThenFunc(p.UserInfo)) | ||||
| } | ||||
|   | ||||
| @@ -5,8 +5,8 @@ | ||||
| <meta charset="utf-8"> | ||||
| <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | ||||
|   <title>{{.StatusCode}} {{.Title}}</title> | ||||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"> | ||||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"> | ||||
| <link rel="stylesheet" href="{{.ProxyPrefix}}/static/css/bulma.min.css"> | ||||
| <link rel="stylesheet" href="{{.ProxyPrefix}}/static/css/all.min.css"> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|   document.addEventListener('DOMContentLoaded', function() { | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
|     <meta charset="utf-8"> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | ||||
|     <title>Sign In</title> | ||||
|     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"> | ||||
|     <link rel="stylesheet" href="{{.ProxyPrefix}}/static/css/bulma.min.css"> | ||||
|  | ||||
|     <style> | ||||
|       body { | ||||
|   | ||||
							
								
								
									
										9
									
								
								static/css/all.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								static/css/all.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1
									
								
								static/css/bulma.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								static/css/bulma.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								static/webfonts/fa-solid-900.woff2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/webfonts/fa-solid-900.woff2
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user